I am loving this new template editor and if it knows what your changes are, like I believe is how it is supposed to work, to avoid conflicts in future upgrades, it is totally awesome.
Anyway, this took me all of about 3 minutes to find and edit. It’s taking me longer to post it. LOL
EDIT THIS AND ALL OF YOUR FUTURE TEMPLATE EDITS VIA DEMO MODE IF POSSIBLE
Activate Demo mode and go to your store and select a product. Hover on the icon for the product box. You want to select views/products/components/buy_now.tpl and make the changes below in [COLOR=“Blue”]blue[/COLOR].
You can edit it how you like but you will also need to create language variables as well:
stock - need to create - I replace in stock
available - already in languages - Can substitute for Yes
unavailable - need to create - Can substitute for No
Customization mode works well for helping to find your way around the the templates and making changes. Unfortunately, those changes are made to the base TPL file which means that they will need to be reconciled when any future updates replace that TPL file.
The better approach would be to make changes using the ‘hooks’ feature which is vaguely documented at [url]http://docs.cs-cart.com/cscart-architecture[/url] (see the Template Hook section). tbirnseth does a better job of explaining it in this post:
This will tell the system to replace the content inside of the ‘hook’ template tag
{hook name=“index:bottom”}
Standard content
{/hook}
with the content contained within the bottom.override.tpl file.[/QUOTE]
There is a hook starting at line 107 and ending at line 128 which deals with displaying the stock quantity:
{hook name="products:options_advanced"}
If you make your changes using a hook, future upgrades won’t overwrite your mod which is in a local file.
The real problem, at this point, is that we have a real, working solution using tbirseth’s Local add-on but it has not been ‘blessed’ by the developers who seem to be doing there own thing with the “My changes” add-on. Any changes using tbirnseth’s add-on should be easily ported to the “My changes” add-on when it becomes available - well, at least in theory.
[quote name=‘moka’]This works if there are no options. It shows as “available” for a split second until the page fully loads on products with options.[/QUOTE]
Same problem here. I also use Options, and I would like to show “Available” only, not the number of items. How can I do this?
If you are not using options, you need to add your additional if statements and change the result to display to your image in /skins/YOURSKIN/customer/views/products/components/buy_now.tpl. You want the following block of code:
However, there seems to be one problem. I am using Options. New language I added cannot seems to be displayed in the options. For example, I added text_stock_available in Language. Then I added
Then I added pstock.html(‘’ + lang.text_stock_available + ‘’);
in exceptions.js. But it displays as “Undefined” on the webpage. Why? My temporary solution is to hardcode the text in exceptions.js and also buy_now.tpl.
After doing changes in post #9 above for items with inventory tracking with options, the in-stock products indicated “undefined” in the front end. So I made the following changes:
Instead of putting:
pstock.html(‘’ + lang.available + ‘’);
I put:
pstock.html(‘’ + {$lang.available} + ‘’);
and instead of:
pstock.html(‘’ + lang.unavailable + ‘’);
I put:
pstock.html(‘’ + {$lang.unavailable} + ‘’);
Note I just added the {$ and }
Now product with options display same a those without.
OK: One little note. I checked to make sure before posting. Turns out the product with options that are out of stock show as “Available”
Oh well, I can live with that until someone figures it out.
OK: One little note. I checked to make sure before posting. Turns out the product with options that are out of stock show as “Available”
Oh well, I can live with that until someone figures it out.[/QUOTE]
Weird, double check the logic and make sure you entered the correct code at the correct condition.
For me available/not available displays fine. Just that I hardcoded the text instead of using $lang… now since it works, I am lazy to change to $lang already, haha.
I have the same Undefined problem using 2.0.10 electro skin. if anyone stumbles across a good solution please post. I have just switched to track without options for now.