Hello,
This is for the latest cs-cart version.
I’ve been working through the structure of cs-cart and have gotten so far. The way I understand it there are 3 ways to make changes the first being editing template files (bad for upgrades), the second is to override template files in a generic addon (usually referred to as my_changes) and the 3rd is to create your own addon for each piece of functionality.
It is the 3rd method I am interested in for my own knowledge but of course it is also the hardest.
In my case all as I want to do is add a “Request a Quote” button underneath the “Add to cart” button on the product pages and the product listing pages.
There is no PHP coding really required for this except in the URL I’ll need add “?item=[the product id]” but I can handle that part in the template so it’s still not coding per se.
What I am unsure of is the template file itself so if someone could show me how to set it up I would appreciate it.
Here is what I have so far:
Under addons/request_quote/ I have addon.xml. Of that the only questions I have are:
Do I need to do anything with or ? I’m guessing “no” because there is no code to process which is why I set them to zero. In the file I got them from they much larger numbers.
I am assuming that “request_a_quote” will be automatically accessible in the .tpl files via “$lang.request_a_quote” - please let me know if this not is correct.
Under addons/request_quote/controllers/customer/ I have: init.post.php which has:
```php
if ( !defined(‘AREA’) ) { die(‘Access denied’); }
Registry::get(‘view’)->assign(‘request_quote’, array( ‘allowed’ => 1));
?>
```
As you can see it doesn't do anything at the moment except the first line which seems to be universal and I assume is a line of security code. The 2nd line is just commented out. I don't think this file is needed but I am keeping there just as placeholder (as a reminder) in case I find I do need some coding.
The last file I'm working on and haven't figured out at all is under: skins/basic/customer/addons/request_quote/ and all as I got is: view.tpl.
Of this I just copied over "add_to_wish_list.tpl" which is a single button like this:
```php {include file="buttons/button.tpl" but_id=$but_id but_name=$but_name but_text=$lang.add_to_wishlist but_role="text" but_onclick=$but_onclick but_href=$but_href}
```
For readability here I'll split that line up (and change the button text to mine) and in doing so we get:
```php {include file="buttons/button.tpl"
but_id=$but_id
but_name=$but_name
but_text=$lang.request_a_quote
but_role="text"
but_onclick=$but_onclick
but_href=$but_href
}
```
And here is where I am stuck because I don't have a clue where $but_id, $but_name etc. is coming from and therefore if I need to do anything with them. Also, perhaps I've used the wrong template to get a button and there is a better way. And, I probably have to setup some hooks to put this in the right place once the template is coded correctly... so as you can see I'm a bit lost at the moment.
Can anyone give me a direction on this? Help appreciated!
I understand that setting up a whole addon by itself for just a button is almost certainly overkill but it's as much an exercise in understanding creating new addons as it is creating the functionality.
Reg