Math IF/ELSE in version 5
I am attempting to display the stock level only if it is a low number, (i.e.. below 10) so items which have 431 in stock, is not necessary to display this information.
In version 4 it was quite straightforward, however I cannot work out how to do this in version 5. Can anybody help? This is the pieces of code from the product/details/stock/body.tpl ({t(#X items available#,_ARRAY_(#count#^getAvailableAmount()))} ) |
Re: Math IF/ELSE in version 5
Hello Richard,
Here is how I would do this to retain the compatibility with future X-Cart 5 versions: 1. Create a custom module 2. Copy the skins/default/en/product/details/stock/body.tpl file to skins/default/en/modules/[YOUR_DEV_ID]/[YOUR_MODULE_ID]/product/details/stock/body.tpl and change it as follows: HTML Code:
3. Decorate \XLite\View\Product\Details\Customer\Stock class as follows: classes/XLite/Module/[YOUR_DEV_ID]/[YOUR_MODULE_ID]/View/Product/Details/Customer/Stock.php PHP Code:
Haven't tested the code, but it should work as is. |
Re: Math IF/ELSE in version 5
Great thank you. I will add it. How can I set it to display the amount in stock only if there are less than 10 in stock.
|
Re: Math IF/ELSE in version 5
You need to add the following method into the class suggested by Alex:
PHP Code:
and it should do the trick. Did not test the code though. |
Re: Math IF/ELSE in version 5
Thank you Tony, it almost works perfectly, however it is disabling the the whole class. Is it possible to display an alternate message instead of disabling the class? Maybe it is with the if/else statement in the code.
For example it has; In stock (8 available) or it won't show anything. I would prefer to have another message; In stock (more than 10 available) Thanks in advance |
Re: Math IF/ELSE in version 5
Hello Richard,
Just combine the code provided by Tony with mine :-) PHP Code:
This way you keep the widget visible (isVisible() is not modified), but use a different template file that hides the portion of the message when isItemsAvailableVisible() method returns FALSE. Don't forget to add the modified template to your module. |
Re: Math IF/ELSE in version 5
Great thanks a lot both for the help !
|
Re: Math IF/ELSE in version 5
Try this:
HTML Code:
|
Re: Math IF/ELSE in version 5
Perfect thank you
|
All times are GMT -8. The time now is 11:36 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.