Price Modifiers FieldType

See also: item options dedicated tag. The dedicated tag does not care about field name, and will output all item options found in your channel entry, regardless of name. The syntax is a bit easier to understand, so we highly recommend skipping right on over to it instead.

See also: price modifiers overview

CartThrob's price modifiers custom fieldtype is used to display options from configurable products. These modifiers can be no-cost options, or they can add cost to the product. For more information, please see this article on configuring price_modifiers.

Make sure you are using the short name of your price modifiers field. For this example we're using "price_modifier" as the name of the custom field.

Although the price_modifier "tag" is really a standard channel custom field, we're treating it like a tag here. You can output some basic information about the structure and content of the price_modifier field.

Table of Contents

Variables

YOUR_FIELD:label

The full name of the price modifier field.

{product_color:label}

YOUR_FIELD:total_results

The total number of options to choose from.

{product_color:total_results}

Variable Pairs

YOUR_FIELD

You can use your item_options field as a variable pair to output your item_options data.

{product_color} {option_value} {option_name} {price} {/product_color}

Conditionals

{if first_row}

Checks to see if this is the first option

{product_color}{if first_row}<select name="item_options[product_color]">{/if}{/product_color}

{if last_row}

Checks to see if this is the last option

{product_color}{if last_row}</select>{/if}{/product_color}

Examples

{exp:channel:entries channel="shirts" }
    {if product_color:total_results}
        {product_color:label} has {product_color:total_results} options available
        {product_color}
            {if first_row}
            <select name="item_options[product_color]">
            {/if}
            <option value="{option_value}">{option_name} $ {price}</option>
            {if last_row}
            </select>
            {/if}
        {/product_color}

        <ul>
            {product_color}
                <li>{option_value} {option_name} {price}</li>
            {/product_color}
        </ul>
    {/if}
{/exp:channel:entries}