Display the item addon’s unit price, or another specified parameter.

shopp('purchase', 'item-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 selected parameter of the current purchased item addon if the return option is used.

Alternative Forms

shopp('purchase.item-addon', 'options');


Display the item addon’s unit price, or another specified parameter.

If not looping through purchased items, or if the current purchased item has no addons, shopp(‘purchase’,’item-addon’) will display nothing. You should loop through purchased items, test for item addons, and then loop through purchased item addons to use this function. See below.

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.


The following options are valid.

  • id: set to true,1,on to display the addon id parameter.
  • name: set to true,1,on to display the addon name parameter.
  • label: set to true,1,on to display the addon label parameter.
  • type: set to true,1,on to display the addon type parameter.
  • onsale: set to true,1,on to display the addon onsale parameter.
  • inventory: set to true,1,on to display the addon inventory parameter.
  • sku: set to true,1,on to display the addon sku parameter.
  • unitprice: set to true,1,on to display the addon unitprice parameter.
  • download: set to true,1,on to display the addon download link (for downloadable addons).
  • linktext: Defaults to ‘Download’, the link text for the download link, if applicable.


shopp('purchase', 'item-addon', 'options...');

Collect a list of Addons

// test for purchased items
if ( shopp('purchase','has-items') ) {
    // loop through purchased items
    while ( shopp('purchase', 'items') ) {
        // test for purchased item addons
        if ( shopp('purchase', 'item-has-addons') ) {
            $Addons = array();
            $i = 0;

            //loop through purchased item addons
            while ( shopp('purchase', 'items-addons') ) {
                // create a new object to collection addon info
                $Addons[$i] = new stdClass;

                // collection the addon parameters
                $Addons[$i]->id = shopp('purchase','get-item-addon','id=on');
                $Addons[$i]->name = shopp('purchase','get-item-addon','name=on');
                $Addons[$i]->label = shopp('purchase','get-item-addon','label=on');
                $Addons[$i]->type = shopp('purchase','get-item-addon','type=on');
                $Addons[$i]->onsale = shopp('purchase','get-item-addon','onsale=on');
                $Addons[$i]->inventory = shopp('purchase','get-item-addon','inventory=on');
                $Addons[$i]->sku = shopp('purchase','get-item-addon','sku=on');
                $Addons[$i]->unitprice = shopp('purchase','get-item-addon','unitprice=on');

                if ('Download' == $Addons[$i]->type)
                    $Addons[$i]->download = shopp('purchase','get-item-addon','download=on');

Display a table of addons

<?php if ( shopp('purchase','has-items') ): ?>
<?php   while ( shopp('purchase', 'items') ): ?>
    ...various purchase item markup...

<?php       if ( shopp('purchase', 'item-has-addons') ): ?>

<td>Addon Id</td>
<td>Addon Name</td>
<td>Addon Label</td>
<td>Addon Type</td>
<td>Addon Onsale</td>
<td>Addon Inventory</td>
<td>Addon SKU</td>
<td>Addon Unitprice</td>
<td>Addon URL</td>
<?php           while ( shopp('purchase', 'items-addons') ): ?>
    <td><?php shopp('purchase','item-addon','id=on'); ?></td>
    <td><?php shopp('purchase','item-addon','name=on'); ?></td>
    <td><?php shopp('purchase','item-addon','label=on'); ?></td>
    <td><?php shopp('purchase','item-addon','type=on'); ?></td>
    <td><?php shopp('purchase','item-addon','onsale=on'); ?></td>
    <td><?php shopp('purchase','item-addon','inventory=on'); ?></td>
    <td><?php shopp('purchase','item-addon','sku=on'); ?></td>
    <td><?php shopp('purchase','item-addon','unitprice=on'); ?></td>
    <td><?php if( 'Download' == shopp('purchase','get-item-addon', 'type=on') ): ?>
        <?php $name = shopp('purchase','get-item-addon','id=on'); ?>
        <?php shopp('purchase.item-addon', array('download'=>true, 'linktext'=>'Download '.$name)); ?>
    <?php endif; ?></td>
<?php           endwhile; ?>

<?php       endif; ?>
<?php   endwhile; ?>
<?php endif; ?>

See Also

  1. Just for reference, there is an error in the example. Replace:

    while ( ‘purchase’, ‘items-addons’ ):


    while ( shopp(‘purchase’, ‘item-addons’) ):

    December 23rd   #

  2. Corrected now, thanks!

    January 13th   #

You must be logged in to post a comment.

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