How would I implement this: If (field) = (text) then...

Questions and answers about ShopSite Custom Templates

How would I implement this: If (field) = (text) then...

Postby elsparkodiablo » Sat Oct 22, 2011 7:23 pm

Hey guys

Upgraded to 11sp1 and love the new features.

We occasionally have issues where we'd like to list a product, but hide the sale price to comply with our vendor's Minimum Allowable Advertising Policies (MAAP). I'm running into an issue that should be easy to solve, but I must be exhausted and am not getting this right.

How am I screwing this up:
Code: Select all
[-- IF Product.Field10 "maap" --]
Add to cart to see our low price!
[-- ELSE --]
(standard Add to Cart code)
[-- END_IF --]


Eventually I'm going to use Product.Field10 for several different codes with resulting outputs in a series of IF ELSE statements... but getting this first one right is screwing me up.
elsparkodiablo
 
Posts: 32
Joined: Sat May 05, 2007 9:17 pm

Re: How would I implement this: If (field) = (text) then...

Postby Jim » Sat Oct 22, 2011 9:43 pm

I know about "maap" pricing and what you have should work fine. What you need to do is not display the price instead of not displaying the add to cart button.

[-- IF Product.Field10 "maap" --]
Price = Add to cart to see our low price!
Add to cart button here
[-- ELSE --]
[-- product.price --]
(standard Add to Cart code)
[-- END_IF --]

You will want to code the add to cart link using a method other than the [-- PRODUCT.OrderCheckout --] which displays order options and may include the price.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Re: How would I implement this: If (field) = (text) then...

Postby elsparkodiablo » Sun Oct 23, 2011 12:00 pm

I figured out what I was doing wrong - had the product loop building each product using a specific template instead of the testing template I was coding. This was a workaround since prior to 11sp1 if you didn't specify the template when adding products, it'd default to a stripped down version. Removed that code segment and my test template is displaying just fine.

Thanks for the response.
elsparkodiablo
 
Posts: 32
Joined: Sat May 05, 2007 9:17 pm

Re: How would I implement this: If (field) = (text) then...

Postby Jim » Sun Oct 23, 2011 1:15 pm

Glad you got it working.

Regarding this sentence in your post.
"This was a workaround since prior to 11sp1 if you didn't specify the template when adding products, it'd default to a stripped down version"

The "it defaults to a stripped down version" isn't quite right. If a template isn't specified in the loop products [-- product --] tag it uses the template that is assigned to the product on the Edit Product Layout screen. The default product template depends on which theme is active so it could be very complex, as in the Awesome theme or very plain as in the Plain theme. This behavior has never changed since the custom templates first implemented, and is still the same in ShopSite 11 sp1.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah


Return to Custom Template Questions

Who is online

Users browsing this forum: No registered users and 15 guests