Custom Product Templates: Subproducts

There are two separate parts of a custom product template for subproducts: defining how subproducts will look, and setting where subproducts will be displayed in the current template.

Defining the Look of Subproducts
At the top of your custom product template -- before the [-- DEFINE PRODUCT --] tag -- you must put a [-- DEFINE SUBPRODUCT --] section to define how subproducts will look. This includes what product attributes will be displayed (name, price, etc.) and the layout of those attributes.

  • If the subproduct has a More Info page defined, your template should link the subproduct name to that page.
  • Subproducts can be used for several different purposes, and each purpose may need a different layout. For example, using subproducts to sell different sizes of the same product may require a different layout than using subproducts for upsell or cross-sell purposes.

Putting Subproducts in the Product Template
As a general rule, if a product has subproducts, most of the information for the main product is not displayed. You can stick to this rule or ignore it, but the built-in ShopSite templates only display a product's name, graphic and description if it has subproducts. You can use an IF tag to test whether a product has subproducts.

Placing subproducts in your product template is done with a loop:

[-- LOOP SUBPRODUCTS --]
<br>[-- SUBPRODUCTS --]
[-- END_LOOP SUBPRODUCTS --]

  • Every time the template parser cycles through the loop, it will replace the [-- SUBPRODUCTS --] tag with the subproduct definition.
  • You don't have to know what subproducts are assigned to the product; the [-- LOOP SUBPRODUCTS --] tags cycle through all of them.

Subproduct Example
This example defines the subproduct to display the subproduct name, price, and an Add to Cart button. It does not display sale prices or alternate currency prices for subproducts. In the product definition, there is a test for whether a product has subproducts, and if it does, only the product name, graphic and description are displayed before the subproducts.

Rose Bouquet
1doz Roses $29.99 Add To Cart
2doz Roses $44.99 Add To Cart
3doz Roses $59.99 Add To Cart
    [-- DEFINE SUBPRODUCT --]
    [-- IF PRODUCT.DisplayMoreInformationPage--]
    <a href="[-- PRODUCT.MoreInfoURL --]">[-- PRODUCT.Name --]</a>
    [-- ELSE --]
    [-- PRODUCT.Name --]
    [-- END_IF --]
    [-- PRODUCT.PriceSize Begin --][-- PRODUCT.PriceStyle Begin --][-- PRODUCT.Price --][-- PRODUCT.PriceStyle End --][-- PRODUCT.PriceSize End --]
    <a href="[-- PRODUCT.AddToCartURL --]">Add to Cart</a>
    [-- END_DEFINE SUBPRODUCT --]

    [-- DEFINE PRODUCT --]

    [-- IF PRODUCT.DisplayName --]
    [-- PRODUCT.NameSize Begin --][-- PRODUCT.NameStyle Begin --]
    [-- PRODUCT.Name --]
    [-- PRODUCT.NameStyle End --][-- PRODUCT.NameSize End --]
    [-- END_IF --]

    [-- IF PRODUCT.Subproduct --]
    [-- LOOP SUBPRODUCTS --]
    <br>[-- SUBPRODUCTS --]
    [-- END_LOOP SUBPRODUCTS --]

    [-- ELSE --]
    <br>[-- PRODUCT.PriceSize Begin --][-- PRODUCT.PriceStyle Begin --][-- PRODUCT.Price --][-- PRODUCT.PriceStyle End --][-- PRODUCT.PriceSize End --]
    <a href="[-- PRODUCT.AddToCartURL --]">Add to Cart</a>
    [-- END_IF --]

    [-- END_DEFINE PRODUCT --]
Return To: Product Template Home Page