subproduct a subproduct of itself?

Questions and answers about ShopSite Custom Templates

subproduct a subproduct of itself?

Postby DavidLM » Tue Feb 02, 2021 1:56 pm

Hello all,
ShopSite® Pro 14.0 r3.1
I use a custom template (purchased long ago) but I am not an HTML person.
Trying to find out if there is a way to detect if a subproduct is a subproduct of itself. Hopefully some IF statements that I can insert.
Example page:
https://www.pumpvendor.com/Sherwood_G907P_G-907P.html
The first sub on this page is of course a sub of itself but I do not want the "Product Details" link to be displayed because it just links back to this same page and customers complain the site is broken.
The other 3 subs on this page I do want the "Product Details link to be displayed.
The current code in the [--DEFINE SUBPRODUCT--] section of my template:
[-- IF Product.DisplayMoreInformationPage --]
<br><a href="[-- Product.MoreInfoURL --]"><strong>Product&nbsp;Details</strong></a><br>

Thanks in advance for any help with this!
Dave
DavidLM
 
Posts: 3
Joined: Thu May 14, 2015 10:39 am

Re: subproduct a subproduct of itself?

Postby ShopSite Lauren » Tue Feb 02, 2021 3:25 pm

You can create a VAR tag in the DEFINE PRODUCT section just before the LOOP SUBPRODUCTS that has a field for the parent product, such as the SKU (if all products have SKUs) or the product record number (a ShopSite-generated product number). Then in the DEFINE SUBPRODUCT section, you would have an IF statement to see if the subproduct value matches the parent product value. If so, skip.

Here is a tag you might put in front of the [-- LOOP SUBPRODUCTS --] tag: [-- VAR.ParentRecordNumber PRODUCT.RecordNumber --]

Then in your DEFINE SUBPRODUCT section, around the "product details" link would be an IF statement that goes something like (NE means "not equal"):
[-- IF PRODUCT.RecordNumber NE VAR.ParentRecordNumber --]
[-- IF Product.DisplayMoreInformationPage --]
<br><a href="[-- Product.MoreInfoURL --]"><strong>Product&nbsp;Details</strong></a><br>
[-- END_IF --]
[-- END_IF --]
- ShopSite Lauren
Contact me for help with any of your
custom ShopSite template questions.
ShopSite Lauren
 
Posts: 889
Joined: Fri Aug 11, 2006 1:35 pm
Location: Orem, UT

Re: subproduct a subproduct of itself?

Postby DavidLM » Tue Feb 02, 2021 4:27 pm

Thank you for the speedy reply!
Your code works perfectly!!!
And it was only 3 lines of code to do the job.
Thanks again,
Dave
DavidLM
 
Posts: 3
Joined: Thu May 14, 2015 10:39 am


Return to Custom Template Questions

Who is online

Users browsing this forum: No registered users and 3 guests

cron