shopp('product.addon')

Used inside the product addons loop to display addon inputs.

shopp('product', '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 mixed when the return value of the function is a string, it is echoed by default. If the return value is boolean true of false, it is returned. The function will always return a value if the return option is used.

Alternative Forms

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

Description

Used inside the product addons loop to display addon inputs.

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.

Default Form Input Options

These options are used on theme api calls that output form input tags, to specify attributes.

  • class: option for the class input attribute. The option’s value added to the class attribute.
  • format: option for the format input attribute. The option’s value is output as the attribute.
  • disabled: option for the disabled input attribute. Outputs a ‘disabled’ class and attribute if option is set to ‘true’,’on’,’1′.
  • minlength: option for the minlength input attribute. The option’s numeric value is output a class. (ie. min1)
  • maxlength: option for the maxlength input attribute. The option’s numeric value is output a class. (ie. max1)
  • readonly: option for the readonly input attribute. Outputs a ‘readonly’ class and attribute if option is set to ‘true’,’on’,’1′.
  • required: option for the required input attribute. Output a ‘required’ class if option is set to ‘true’,’on’,’1′.
  • autocomplete: option for the autocomplete input attribute. The option’s value is output as the attribute.
  • accesskey: option for the accesskey input attribute. The option’s value is output as the attribute.
  • alt: option for the alt input attribute. The option’s value is output as the attribute.
  • checked: option for the checked input attribute. Output if option is set to ‘true’,’on’,’1′.
  • size: option for the size input attribute. The option’s value is output as the attribute.
  • src: option for the src input attribute. The option’s value is output as the attribute.
  • tabindex: option for the tabindex input attribute. The option’s value is output as the attribute.
  • cols: option for the cols input attribute. The option’s value is output as the attribute.
  • rows: option for the rows input attribute. The option’s value is output as the attribute.
  • title: option for the title input attribute. The option’s value is output as the attribute.
  • value: option for the value input attribute. The option’s value is output as the attribute.
  • label: option for the label input attribute. Can be used instead of value for the value attribute as well.

Display Options

The following options are valid.

  • input: (default false) when set and not false, will display a form input for the addon. Valid values are hidden, checkbox, and radio.
  • weight: When set to on, true, or 1 value, the weight of the addon is displayed.
  • units: Used with weight option. When set to on, true, 1 value, the system weight unit will be included in the weight string.
  • price: When set to on, true, or 1 value, the price of the addon is displayed.
  • saleprice: When set to on, true, or 1 value, the sales price of the addon is displayed.
  • taxes: Used with price and saleprice options. When set to on, true, or 1 value, the prices will include taxes, if the addon is taxable.
  • promos: Used with saleprice option. When set to on, true, or 1 value, the promotional sales price of the addon is displayed.
  • id: When set to on, true, or 1 value, the id of the addon is displayed.
  • label: When set to on, true, or 1 value, the label of the addon is displayed.
  • type: When set to on, true, or 1 value, the type of the addon is displayed. For example Shipped, Download, Donations, Virtual, Subscription.
  • sku: When set to on, true, or 1 value, the SKU (Stock Keeping Unit) of the addon is displayed.
  • stock: When set to on, true, or 1 value, the stock of the addon is displayed.
  • shipfee: When set to on, true, or 1 value, the added shipping fee of the addon is displayed.

Boolean Options

If one of the following options are used, a boolean (true/false) value will be returned.

  • sale: When set to on, true, or 1 value, the theme api function will return true if the addon is on sale, and false if it is not on sale.
  • shipping: When set to on, true, or 1 value, the theme api function will return true if the addon has shipping fees, and false if it does not.
  • tax: When set to on, true, or 1 value, the theme api function will return true if the addon is taxable, and false if it is not.
  • inventory: When set to on, true, or 1 value, the theme api function will return true if the addon has a tracked inventory, and false if it does not.

Examples

Display a list of radio buttons to select one addon

<?php if ( shopp('product','has-addons') ): ?>
    <div class="addons"><ul>
    <?php while ( shopp('product', 'addons') ): ?>
    <li><label><?php shopp('product','addon','input=radio'); ?>&mdash;&nbsp;<?php shopp('product','addon','label=on'); ?></label></li>
    <?php endwhile; ?>
    </ul></div>
<?php endif; ?>

Display a list of checkboxes to select multiple addons

<?php if ( shopp('product','has-addons') ): ?>
    <div class="addons"><ul>
    <?php while ( shopp('product', 'addons') ): ?>
    <li><label><?php shopp('product','addon','input=checkbox'); ?>&mdash;&nbsp;<?php shopp('product','addon','label=on'); ?></label></li>
    <?php endwhile; ?>
    </ul></div>
<?php endif; ?>

Display a list addons and attributes, with hidden input

<?php if ( shopp('product','has-addons') ): ?>
    <div class="addons">
    <?php while ( shopp('product', 'addons') ): ?>
    <ul>
        <li><?php shopp('product','addon','input=hidden'); ?>Addon: <?php shopp('product','addon','label=on'); ?></li>

        <?php if ( shopp('product','addon','inventory=1') ): ?>
        <li>SKU: <?php shopp('product','addon','sku=1') ?></li>
        <li>In Stock: <?php shopp('product','addon','stock=1') ?></li>
        <?php endif; ?>

        <?php if ( shopp('product','addon','sale=1') ): ?>
        <li>Sale Price: <?php shopp('product','addon','saleprice=1') ?></li>        
        <?php else: ?>
        <li>Regular Price + Tax: <?php shopp('product','addon','stock=1&taxes=on') ?></li>
        <?php endif; ?>
    </ul>
    <?php endwhile; ?>
    </div>
<?php endif; ?>

See Also

  1. Avatar of wbickley

    It’s worth noting that the last example on this page has an error on the final “else” statement, with a “;” as opposed to the correct “:”

    July 10th   #

  2. Avatar of Jonathan Davis

    Corrected. Thanks for the heads up!

    July 22nd   #

You must be logged in to post a comment.

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

Skip to toolbar