shopp_product_addon_set_type()

sets the type of a product addon.

shopp_product_addon_set_type ( $addon, $type )

@param int/Price $addon (required) The priceline id to set the type on, or the Price object to change.  If Price object is specified, the object will be returned, but not saved to the database.
@param string $type (optional default:N/A) The product price type, ex Shipped, Download, Virtual, Subscription.  N/A is a disabled priceline.
@param string $context (optional default:addon) enforces the priceline is a 'product','variant', or 'addon'

Description

sets the type of a product addon.

Default Product Types
* Shipped – the product, product variant, or addon is shipped.
* Download – the product, product variant, or addon is a digital download.
* Virtual – the product, product variant, or addon is non-tangible.
* Subscription – the product, product variant, or addon is a type of subscription, with recurring payment.
* N/A – the product, product variant, or addon is disabled.

Example

$data = array(
    'name' => "Music Album",
    'single' => array(),
    'publish' => array( 'flag' => true ),
    'description' =>
        "My Music Track"
);
$Product = shopp_add_product($data);

// set the product type to Download
shopp_product_set_type ( $Product->id, 'Download');

// Setup some addon options for this product
$options = array(
    'Bonus' => array('Call from Artist', 'Magazine Subscription')
);
shopp_product_set_addon_options ( $Product->id, $options, 'save' );

// Say we have a premium intangible addon
// such as a personal telephone call from the music artist.
// We set the product type to Virtual
$Call = shopp_product_variant(
    array(
        'product'=>$Product->id,
        'option' => 
        array(
            'Bonus'=>'Call from Artist'
        )
    ), 'addon'
);
shopp_product_addon_set_type ( $Call->id, 'Virtual' );

// Another addon to the music download could
// a magazine subscription.
$Mag = shopp_product_variant(
    array(
        'product'=>$Product->id,
        'option' => 
        array(
            'Bonus'=>'Magazine Subscription'
        )
    ), 'addon'
);
shopp_product_addon_set_type ( $Mag->id, 'Subscription' );

See Also

You must be logged in to post a comment.

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

Skip to toolbar