shopp_product_variant_set_price()

set the regular pricetag on a product, variant, or addon.

shopp_product_variant_set_price ( $variant, $price, $context )

@param int/Price $variant (required) The priceline id to set the price on, or the Price object to change.  If Price object is specified, the object will be returned, but not saved to the database.
@param float $price the price to be set
@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

set the regular pricetag on a product, variant, or addon.

Examples

Single Product

No variants.

// Get the product Price object for single product 1
$Price = shopp_product_variant(array('product' => 1), 'product');

// Set the regular price to $4.99
shopp_product_variant_set_price($Price->id, 4.99, 'product');

Variant

// Get the variant Price object for product with variants
// Color: Blue and Size: Large
$Price = shopp_product_variant( array('product' => 12, 
    'option'=>array('Color'=>'Blue', 'Size'=>'Large')), 'variant' );

// Set the regular price to $10.00
shopp_product_variant_set_price($Price->id, 10.00, 'variant');

Addon

// Get the variant Price object for product with variants
// Services: Gift-wrapping
$Price = shopp_product_variant( array('product' => 12, 
    'option'=>array('Services'=>'Gift-wrapping')), 'addon' );

// Set the regular price to $1.50
shopp_product_variant_set_price($Price->id, 1.50, 'addon');

See Also

You must be logged in to post a comment.

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

Skip to toolbar