shopp_product_variant_set_subscription()

sets the subscription settings for a product, product variant, or addon of type Subcription.

shopp_product_variant_set_subscription ( $variant, $settings, $context )

@param int/Price $variant (required) The priceline id to set donation settings on, or the Price object to change.  If Price object is specified, the object will be returned, but not saved to the database.
@param array $settings (required) The array of settings. Specify any trial period pricing, and the define the billing cycle.
@param string $context (optional default:variant) enforces the priceline is a 'product','variant', or 'addon'
@return bool/Price false on failure, true if Price saved, else the modified Price object.

Description

This function sets the subscription settings for a product, product variant, or addon of type Subcription.

Example

// subscription settings array
$settings = array();

// setup the trial period and price (optional)
$settings['trial'] = array();
$settings['trial']['price'] = 0.00;

// setup the trial cycle
$settings['trial']['price']['cycle'] = array();
// 7 day trial
$settings['trial']['price']['cycle']['interval'] = 7;
$settings['trial']['price']['cycle']['period'] = 'd';

// setup the billing cycle
$settings['billcycle'] = array();
// 0 for infinite cycles, integer number for # of cycles to repeat
$settings['billcycle']['cycles'] = 0;
$settings['billcycle']['cycle'] = array();
// repeat the billing cycles ever 12 months
// d for days, w or weeks, m for months, and y for years
$settings['billcycle']['cycle']['interval'] = 12;
$settings['billcycle']['cycle']['period'] = 'm';

// Product 31 has several variants
// lookup the Premium Access subscription, billing Annually
$Variant = shopp_product_variant( array('product' => 31, 'option' => array('Access'=>'Premium', 'Billing'=>'Annual') );

// configure the subscription settings for this variant
shopp_product_variant_set_subscription ( $Variant->id, $settings );

See Also

You must be logged in to post a comment.

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

Skip to toolbar