shopp_product_variant_set_saleprice()

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

shopp_product_variant_set_saleprice ( $variant, $flag, $price, $context )

@param int/Price $variant (required) The priceline id to set the sale 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 bool $flag (optional default:false) true for on, false for off. Turns on or off the sale flag on the variant.  If false, price is ignored.
@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 sale 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 sale price to $1.99
shopp_product_variant_set_saleprice($Price->id, true, 1.99, 'product');

// Disable sale on product 2
$Price = shopp_product_variant(array('product' => 2), 'product');
shopp_product_variant_set_saleprice($Price->id, false, 0.00, '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 sale price to $5.00
shopp_product_variant_set_saleprice($Price->id, true, 5.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 sale price to $0.50
shopp_product_variant_set_saleprice($Price->id, true, 0.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