shopp('cartitem.addon')

Displays one or more properties of the current cart item addon.

shopp('cartitem', 'addon', '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, the addon property or property list if the return option is used.

Alternative Forms

shopp('cartitem.addon', 'options');

Description

Displays one or more properties of the current cart item addon.

If no options are specified, the theme api call will display the cart item option label.

Universal Options

All Theme API calls have these options.

  • return: when set to true, 1, or on, this option forces the tag to return the value instead of displaying/echoing the value to the page. Alternatively, prefix the tag parameter with get to get the same effect. All theme api tags that return a boolean value will return by default.
  • echo: when set to false, 0, or off, this option forces the tag to display the value to the page. This is the default for all non-boolean tags.
  • is: when set to true, 1, or on, this option will evaluate the return of the theme api call as a boolean true or false value. See how values are converted to boolean.

Options

The following options are valid.

  • separator: Character(s) to separate the cart item addon fields. Defaults to ‘ ‘ (space).
  • currency: Set to currency=on (or 1,true) to output prices/fees with currency symbols. Set to currency=off (or 0,false) to disable currency symbols.
  • id: Set to id=on (or 1,true) to include the cart item addon id in the output.
  • type: Set to type=on (or 1,true) to include the cart item addon type (Shipped, Download, etc.) in the output.
  • label: Set to label=on (or 1,true) to include the cart item option label in the output.
  • price: Set to price=on (or 1,true) to include the cart item price in the output.
  • sale: Set to sale=on (or 1,true) to include the cart item sale status flag in the output.
  • saleprice: Set to saleprice=on (or 1,true) to include the cart item saleprice in the output.
  • unitprice: Set to unitprice=on (or 1,true) to include the cart item unitprice in the output.
  • shipfee: Set to shipfee=on (or 1,true) to include the cart item shipfee in the output.
  • weight: Set to weight=on (or 1,true) to include the cart item weight in the output. No unit is displayed.
  • inventory: Set to inventory=on (or 1,true) to include the cart inventory flag in the output.
  • stock: Set to stock=on (or 1,true) to include the cart item stock level in the output.
  • sku: Set to sku=on (or 1,true) to include the cart item SKU (Stock Keeping Unit) identifier in the output.

Examples

// Display list of cart item addon option labels
if ( shopp('cartitem.has-addons') ) {
    while ( shopp('cartitem.addons') ) {
        shopp('cartitem', 'addon');
        echo "<br />";
    }
}

Use the cartitem addon tag within the loop

if ( shopp('cartitem.has-addons') ) {
    while ( shopp('cartitem.addons') ) {
        // Display ,&nbsp separated list of cart item properties
        shopp('cartitem.addon', array(
            'separator' => ',&nbsp;', // comma and nonbreaking space separator
            'id'=>'on', // include id
            'type'=>'on', // include type
            'label'=>'on', // include label
            'sale'=>'on', // include sale flag
            'currency'=>'on', // include currency symbols
            'saleprice'=>'on', // include sale price
            'price'=>'on', // include price
            'inventory'=>'on', // include inventory flag
            'stock'=>'on', // include stock figure
            'sku'=>'on', // include sku id
            'weight'=>'on', // include wight figure
            'shipfee'=>'on', // include shipfee
            'unitprice'=>'on' // include unitprice
        ));
    }
}

Test for cart item inventory flag

if ( shopp('cartitem.has-addons') ) {
    while ( shopp('cartitem.addons') ) {
        if ( shopp('cartitem.get-addon','inventory=on') ) {
            // display sku and stock
            shopp('cartitem.addon',array(
                'separator' => ':',
                'stock' => 'on',
                'sku' => 'on'
            ));
        }
    }
}

Test for cart item sale flag

if ( shopp('cartitem.has-addons') ) {
    while ( shopp('cartitem.addons') ) {
        if ( shopp('cartitem.get-addon','sale=on') ) {
            shopp('cartitem.addon','saleprice=on');
        } else {
            shopp('cartitem.addon','price=on');
        }
    }
}

See Also

You must be logged in to post a comment.

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

Skip to toolbar