Page 1 of 1

subproduct a subproduct of itself?

PostPosted: Tue Feb 02, 2021 1:56 pm
by DavidLM
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

Re: subproduct a subproduct of itself?

PostPosted: Tue Feb 02, 2021 3:25 pm
by ShopSite Lauren
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 --]

Re: subproduct a subproduct of itself?

PostPosted: Tue Feb 02, 2021 4:27 pm
by DavidLM
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