shopp_product_set_variant_options()

creates a complete set of variant product options on a specified product.

shopp_product_set_variant_options ( $product, $options, $summary )

@param int $product (required) The product id of the product that you wish to add the variant options to.
@param array $options (Description...) A two dimensional array describing the options. The outer array is keyed on the name of the option type (Color, Size, Gender, etc.) The inner contains the corresponding option values.
@return array variant Price objects that have been created on the product.

Description

creates a complete set of variant product options on a specified product.

This function will create new variant options in the database and will attach them to the specified product.

Example

// Set variant options to Color and Gender
// produces Red/Male, Red/Female, Blue/Mail, Blue/Female options
$options = array( 
    'Color' => array('Red','Blue'), 
    'Gender' => array('Male', 'Female') 
);

// creates product variants on product 6
shopp_product_set_variant_options ( 6, $options );

// You can access a particular variant like so...
// for Red/Male
$options = 
    array(
        // pick one from each option set
        'Color' => 'Red',
        'Gender' => 'Male'
    );

$RedMaleVariant = shopp_product_variant(array('product'=>6, 'option'=>$options));

See Also

You must be logged in to post a comment.

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

Skip to toolbar