add a product to the cart

shopp_add_cart_product ( $product, $quantity, $variant )

@param int $product (required) product id to add
@param int $quantity (optional default: 1) quantity of product to add
@param int $variant (optional) variant id to use
@return bool true on success, false on failure


add a product to the cart


// get my product
$Product = shopp_product('My Product', 'name');

// Add quantity 2 of My Product to the cart
shopp_add_cart_product($Product->id, 2);

$Product = shopp_product('T-Shirt', 'name');
$Variant = shopp_product_variant(array('product'=>$Product->id, 'option'=>array('Size'=>'Large', 'Color'=>'Black')));

// Add product with variant to the cart
shopp_add_cart_product($Product->id, 2, $Variant->id);

See Also

  1. When will the API for this be updated to allow for addons to be passed? I wanted to use this in a plugin I’m working on but only being able to send along variants/options, while being unable to send addons, meant I could not use this.

    December 14th   #

You must be logged in to post a comment.

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