Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Create custom IF function

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 04-20-2015, 08:57 AM
 
bob@n-flatables bob@n-flatables is offline
 

Member
  
Join Date: Nov 2012
Posts: 26
 

Default 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.
__________________
X-cart v 5.2
Reply With Quote
  #2  
Old 05-01-2015, 08:34 AM
 
cvaughan02 cvaughan02 is offline
 

Member
  
Join Date: Mar 2014
Location: st. louis, mo
Posts: 22
 

Default Re: Create custom IF function

have you tried wrapping the image tag in an if statement?

{if:product.getMyField() == 'test'}
<img>
{end:}
__________________
SEEK HAPPINESS. EVERYTHING ELSE IS DETAILS.
Reply With Quote
  #3  
Old 05-04-2015, 04:57 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default 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?
__________________
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

Last edited by qualiteam : 05-04-2015 at 05:00 AM.
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 09:08 AM.

   

 
X-Cart forums © 2001-2020