X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Create custom IF function (https://forum.x-cart.com/showthread.php?t=71878)

bob@n-flatables 04-20-2015 08:57 AM

Create custom IF function
 
We created a custom product property field (string) that displays on the product page. What I want to do it have an image display ONLY IF the value of the custom property field ($MyField) equals a specific string "Test".

I can have an image display on the product page if I use <img IF="{product.getMyField())" /> but this displays it as long as the field is not empty.

cvaughan02 05-01-2015 08:34 AM

Re: Create custom IF function
 
have you tried wrapping the image tag in an if statement?

{if:product.getMyField() == 'test'}
<img>
{end:}

qualiteam 05-04-2015 04:57 AM

Re: Create custom IF function
 
Try the following:
1. Create a custom module
2. Decorate the \XLite\View\Product\Details\Customer\Image class
3. Add isVisible() method that checks for the field as follows:
Code:

    protected function isVisible()
    {
        return parent::isVisible() && ($this->getProduct()->getYourField() === 'your value');
    }


Will this work?


All times are GMT -8. The time now is 11:25 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.