Show certain product fileds depending on string

General ShopSite user discussion

Show certain product fileds depending on string

Postby natez311 » Tue Dec 01, 2009 6:09 pm

Hi all,

I am having issues with the homepage that is specifically occurring in the product thumb portion within my product template.

Issue:
I am trying to use an if statement to determine what information to display depending on the string of text for product field 1. For example, the store has 2 product types: "Cigar" and "Accessory". The code below would output the exact fields I want to display if the string in field 1 is "cigars". Field 2, the string would be "accessories". Is this possible or is there a better way to do this? Let me know if this doesn't make any sense. Check out the code below



<ul>
[-- IF STORE.ProductField1 "cigar" --]
<li><strong>[-- STORE.ProductField1 --]</strong>: [-- PRODUCT.Field1 --]</li>
<li><strong>[-- STORE.ProductField2 --]</strong>: [-- PRODUCT.Field2 --]</li>
<li><strong>[-- STORE.ProductField3 --]</strong>: [-- PRODUCT.Field3 --]</li>
[-- ELSE_IF STORE.ProductField1 "accessory" --]
<li><strong>[-- STORE.ProductField2 --]</strong>: [-- PRODUCT.Field2 --]</li>
<li><strong>[-- STORE.ProductField7 --]</strong>: [-- PRODUCT.Field7 --]</li>
[-- ELSE --]
<li><strong>[-- STORE.ProductField2 --]</strong>: [-- PRODUCT.Field2 --]</li>
[-- END_IF --]

</ul>
Thanks!

-Nate
natez311
 
Posts: 26
Joined: Fri Oct 30, 2009 10:52 am
Location: New York

Postby Jim » Wed Dec 02, 2009 8:09 am

I'm not exactly sure on what you want to do.
The fields [-- Store.productfieldx--] are just text fields and will be set to what you have assigned to the value on the Preferences > Extra Fields screen and will not change based on the product.

You probably want to check the content of a product field for your if statement.
Code: Select all
[-- IF PRODUCT.FIELD10 "cigar" --]
<li><strong>[-- STORE.ProductField1 --]</strong>: [-- PRODUCT.Field1 --]</li>
<li><strong>[-- STORE.ProductField2 --]</strong>: [-- PRODUCT.Field2 --]</li>
<li><strong>[-- STORE.ProductField3 --]</strong>: [-- PRODUCT.Field3 --]</li>
[-- ELSE_IF PRODUCTFIELD10 "accessory" --]
<li><strong>[-- STORE.ProductField2 --]</strong>: [-- PRODUCT.Field2 --]</li>
<li><strong>[-- STORE.ProductField7 --]</strong>: [-- PRODUCT.Field7 --]</li>
[-- ELSE --]
<li><strong>[-- STORE.ProductField2 --]</strong>: [-- PRODUCT.Field2 --]</li>
[-- END_IF --]
[/code]
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah


Return to User Forum

Who is online

Users browsing this forum: No registered users and 32 guests