Displaying Sub Product Info

Questions and answers about ShopSite Custom Templates

Displaying Sub Product Info

Postby posty27 » Fri Jan 14, 2011 9:23 am

So, I'm trying to create my own Page & Product templates to display my products in 3 columns across the page. Here's a mockup of what I'm trying to accomplish - http://www.lifeloc.com/staging_2/supplies.jpg.

I figured out how to get the products to display 3 across the page but I'm having trouble with displaying the subproduct information in the price box. If I want to only display the subproducts item #, description, and price do I need to have a separate [-- Define Subproduct --] & then call that with an IF statement from the [--Define Product --] template? Am I on the right path?

Code: Select all
[-- DEFINE PRODUCT --]

<!-- Format product as one column using CSS Divs -->

<div class="supply_outline">
<h2>[-- PRODUCT.Name --]</h2>
[-- IF Product.Graphic --][-- Product.Graphic --][-- END_IF --]
<p>[-- Product.ProductDescription --]</p>
<table width="315" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th width="17%" scope="col">Item #</th>
    <th width="44%" scope="col">Description</th>
    <th width="24%" scope="col">Price</th>
    <th width="15%" scope="col">&nbsp;</th>
  </tr>
  <tr>
    <td>[-- PRODUCT.SKU --]</td>
    <td>[-- PRODUCT.Name --]</td>
    <td>[-- PRODUCT.Price --]</td>
    <td>&nbsp;</td>
  </tr>
[-- IF SUBPRODUCTS --]
[--LOOP SUBPRODUCTS --]
   [-- SUBPRODUCT --]
[-- END LOOP_SUBPRODUCTS --]
</table>
</div>
[-- END_DEFINE PRODUCT --]


Code: Select all
[-- DEFINE SUBPRODUCT --]
<tr>
    <td>[-- PRODUCT.SKU --]</td>
    <td>[-- PRODUCT.Name --]</td>
    <td>[-- PRODUCT.Price --]</td>
    <td>&nbsp;</td>
  </tr>
[-- END_DEFINE SUBPRODUCT --}
Last edited by posty27 on Fri Jan 14, 2011 11:03 am, edited 1 time in total.
posty27
 
Posts: 15
Joined: Tue Jan 26, 2010 8:26 am
Location: Denver

Re: Displaying Sub Product Info

Postby Jim » Fri Jan 14, 2011 11:01 am

Note that we can not see the preview view of the page since that requires your login name and password. You should probably edit the post and remove it.

I think what you need to do is reorder parts of the product template like this
[-- DEFINE PRODUCT --]

<!-- Format product as one column using CSS Divs -->

<div class="supply_outline">
<h2>[-- PRODUCT.Name --]</h2>
[-- IF Product.Graphic --][-- Product.Graphic --][-- END_IF --]
<p>[-- Product.ProductDescription --]</p>
<table width="315" border="0" cellspacing="0" cellpadding="0">
<tr>
<th width="17%" scope="col">Item #</th>
<th width="44%" scope="col">Description</th>
<th width="24%" scope="col">Price</th>
<th width="15%" scope="col">&nbsp;</th>
</tr>
[-- IF SUBPRODUCTS --]
[--LOOP SUBPRODUCTS --]
[-- SUBPRODUCT --]
[-- END LOOP_SUBPRODUCTS --]
[-- ELSE --]
<tr>
<td>[-- PRODUCT.SKU --]</td>
<td>[-- PRODUCT.Name --]</td>
<td>[-- PRODUCT.Price --]</td>
<td>&nbsp;</td>
</tr>
[-- END_IF --]
</table>
</div>
[-- END_DEFINE PRODUCT --]

That way you will always output the header part of the table and if the product has subproducts it will output all of the subproducts in the table and if the product doesn't have subproducts it will output the main product sku, name and price.

your sample shows an add to cart button which you have not included in your template.

The subproduct template looks ok.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Re: Displaying Sub Product Info

Postby posty27 » Fri Jan 14, 2011 12:09 pm

I reordered my product template but the subproducts still aren't displaying in the price box when I preview the page.

I created a main product & then selected the subproducts according to Shopsite Help instructions. Is this all that needs to be done? In the Product Layout Info, does the sub-products need to have the subproduct template selected?

So far, the price box will only display the main product and neither of the 2 subproducts.

I'm using ShopSite® Pro 10 r7
posty27
 
Posts: 15
Joined: Tue Jan 26, 2010 8:26 am
Location: Denver

Re: Displaying Sub Product Info

Postby Jim » Fri Jan 14, 2011 12:18 pm

The subproduct template code
[-- DEFINE SUBPRODUCT --]
<tr>
<td>[-- PRODUCT.SKU --]</td>
<td>[-- PRODUCT.Name --]</td>
<td>[-- PRODUCT.Price --]</td>
<td>&nbsp;</td>
</tr>
[-- END_DEFINE SUBPRODUCT --}
must be part of the product template not a separate template file. (Note: As I copied and pasted the above from your earlier post I noticed that you have a curly brace "}" instead of the square brace "]"at the end of the tag. Was that just a typo in the forum post or is that also in your template?)

The subproducts should have the same product template selected as the parent product.

Are you seeing any errors on the publish screen when the pages are being published?
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Re: Displaying Sub Product Info

Postby posty27 » Fri Jan 14, 2011 2:30 pm

I added the subproduct template code to the product template. The subproducts have the same product template as the main product.

The curly brace was just a typo in the forum. It's correct in my template.

There are no errors on the publish screen.

Do the [-- PRODUCT.Parent --] or [-- LOOP SUBPRODUCTS VAR.somename --] tags need to be added somewhere? I saw that [-- PRODUCT.Parent --] needs to be included on all subproducts. From Shopsite Template Tag Cheatsheet" "All subproducts must include this tag as a hidden form field with the name 'super'". I'm not even sure where that would be placed.

Here's the published page: http://www.lifeloc.com/store/accessories_new.html
Test_Product_2 should have the information of 2 subproducts displayed in the price box.
posty27
 
Posts: 15
Joined: Tue Jan 26, 2010 8:26 am
Location: Denver

Re: Displaying Sub Product Info

Postby Jim » Fri Jan 14, 2011 3:42 pm

Instead of this code
[-- IF SUBPRODUCTS --]
[--LOOP SUBPRODUCTS --]
[-- SUBPRODUCT --]
[-- END LOOP_SUBPRODUCTS --]
[-- ELSE --]
<tr>
<td>[-- PRODUCT.SKU --]</td>
<td>[-- PRODUCT.Name --]</td>
<td>[-- PRODUCT.Price --]</td>
<td>&nbsp;</td>
</tr>
[-- END_IF --]

Try this

[-- IF PRODUCT.NumSubproducts 0 --]
<tr>
<td>[-- PRODUCT.SKU --]</td>
<td>[-- PRODUCT.Name --]</td>
<td>[-- PRODUCT.Price --]</td>
<td>&nbsp;</td>
</tr>
[-- ELSE --]
[--LOOP SUBPRODUCTS --]
[-- SUBPRODUCT --]
[-- END LOOP_SUBPRODUCTS --]
[-- END_IF --]


The [-- LOOP SUBPRODUCTS VAR.somename --] tag would allow you to have multiple columns of subproducts such as
[-- LOOP SUBPRODUCTS 3 --] would make 3 columns (as long as you format the html around it). VAR.somename could be any numeric value and is set by [-- VAR.somename 3 --]

It works similar to the [-- Loop products --] or [-- Loop links --]

The [-- PRODUCT.Parent --] tag allows the parent name of the product to be passed to the cart so you can display both the parent name and the subproduct name in the cart. The best way to see how this works is to look at a template that uses it. The core_001_pr_basic_subproduct.sst template in the includes area has this format. You would add the code to the define subproduct section of the product template where you want the add to cart button to be.

The
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Re: Displaying Sub Product Info

Postby posty27 » Mon Jan 17, 2011 3:50 pm

That worked!

Thanks for your help Jim.
posty27
 
Posts: 15
Joined: Tue Jan 26, 2010 8:26 am
Location: Denver


Return to Custom Template Questions

Who is online

Users browsing this forum: No registered users and 142 guests