shopp('product.variations')

By default, this tag loops through each variation of the product available allowing custom display of variation properties through the shopp('product','variation') tag.

shopp('product.variations', 'options')

@param string $object the object or object.tag combination, if object.tag is used, the tag parameter can be omitted
@param string $tag the tag, can be hyphenated or not. Prefix with 'get' as shorthand for the return=true option
@param mixed $options associative array, or url-style name=value pairs separated by ampersands (&). Each pair is passed to the theme api tag as an option.
@returns void by default, HTML markup for variations with return option.

Generates HTML markup for product variants.

Using the mode option this tag can instead display variation selection controls.

In single mode it will display a single drop-down menu with each variation as a separate, selectable option. In multiple mode (the default used in the built-in product.php template file), this tag displays multiple menus for each variation option (the options that build to make a single variation) for a more natural option selection experience.

In multiple mode, a selection must be made from each menu in order to add the product to the cart. Additionally, the final price of the product cannot be determined until the last option is selected and as such, the price will only be displayed in the last menu.

Options

  • after_menu: No default value. Allows you to specify a string of characters or HTML markup to display after the the menu is displayed.
  • before_menu: No default value. Allows you to specify a string of characters or HTML markup to display before the label (if enabled) and the menu are displayed.
  • defaults: No default value. Allows you to specify a default option that is displayed as the initial selection for the menu.
  • disabled: Default is show. Shows out-of-stock or disabled variations in the menu but makes them disabled and unable to be selected. When set to hide, excludes out-of-stock or disabled variations from the menu.
  • format: Default is %l (%p). Set the format of the options shown in drop-down menus when mode is set to single or multiple. See Format Options below for available formatting tokens.
  • label: Default is on. Displays a label with the name of the menu as entered in the product editor before the menu.
  • mode: Default is multiple. Accepts single or multiple. The mode option allows you to choose between displaying a single drop-down menu with all of the product variation options merged together, or multiple menus with each option set available in separate menus. Note that using multiple menus relies on JavaScript. If your visitor does not use JavaScript, they will not be able to select product variations to add to the cart. If the mode is not set, this tag can be used for looping through individual variations to use the shopp('product','variation') .
  • required: Default is You must select the options for this item before you can add it to your shopping cart.. Specifies the warning error when attempting to add a product to the cart without selecting all of the necessary variation options.
  • taxes: Default behavior depends on the base of operations. This setting can override the default. When set to true, includes the tax in the price(s) shown. When set to false, excludes tax from the price(s) displayed.

Format Options

  • %p — shows the current variant price including available discounts.
  • %l — show the option label.
  • %s — show the stock amount of a product in inventory
  • %d — show the discount amount of an on sale variant.
  • %r — show the original price (the non-sale price) of the product variant.
  • %u — show the SKU for the product variant.

Examples

<?php shopp('product','variations'); ?>

Show multiple menus for complex variants with a label format that looks like Name: $10.00

<?php shopp('product.variations', 'mode=multiple&format=%l: %p'); ?>

Show a single menu for all variant options with a label format that looks like SKU1592 - Name: $10.00 (-$5.00) which shows the SKU, name, price and the discount amount in parentheses

<?php shopp('product.variations', 'mode=single&format=%u - %l: %p (-%d)'); ?>

See Also

  1. Avatar of Clifton Griffin

    You can hide prices by passing pricetags=hide:

    shopp('product','variations','pricetags=hide');
    
    July 18th   #

You must be logged in to post a comment.

© Ingenesis Limited. Shopp™ is a registered trademark of Ingenesis Limited.

Skip to toolbar