| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Math IF/ELSE in version 5 | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||||
|
|||||||||
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()))} )
__________________
Richard Ultimate 5.4 testing |
|||||||||
#2
|
|||||||||
|
|||||||||
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.
__________________
Alex Solovev, Qualiteam --- User manual Video tutorials X-Cart FAQ You are welcome to press "Thanks" button if you find this post useful Click here to learn how to apply patches X-Cart Extensions |
|||||||||
|
#3
|
|||||||||
|
|||||||||
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.
__________________
Richard Ultimate 5.4 testing |
|||||||||
#4
|
|||||||||
|
|||||||||
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.
__________________
Found a bug in X-Cart? Post it to our bug tracker! Know how to make X-Cart better? Suggest an idea! |
|||||||||
|
#5
|
|||||||||
|
|||||||||
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
__________________
Richard Ultimate 5.4 testing |
|||||||||
#6
|
|||||||||
|
|||||||||
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.
__________________
Alex Solovev, Qualiteam --- User manual Video tutorials X-Cart FAQ You are welcome to press "Thanks" button if you find this post useful Click here to learn how to apply patches X-Cart Extensions |
|||||||||
|
#7
|
|||||||||
|
|||||||||
Re: Math IF/ELSE in version 5
Great thanks a lot both for the help !
__________________
Richard Ultimate 5.4 testing |
|||||||||
#8
|
|||||||||
|
|||||||||
Re: Math IF/ELSE in version 5
Try this:
HTML Code:
__________________
Alex Solovev, Qualiteam --- User manual Video tutorials X-Cart FAQ You are welcome to press "Thanks" button if you find this post useful Click here to learn how to apply patches X-Cart Extensions |
|||||||||
#9
|
|||||||||
|
|||||||||
Re: Math IF/ELSE in version 5
Perfect thank you
__________________
Richard Ultimate 5.4 testing |
|||||||||
|
|||
X-Cart forums © 2001-2020
|