shopp_add_order()

create an order from the cart and associate with a customer

shopp_add_order ( $customer )

@param int $customer the customer that the order will be created for
@return bool|Purchase false on failure, Purchase object of recently created order on success

Description

create an order from the cart and associate with a customer

Example

// empty the cart
shopp_empty_cart();

// get customer id associated with WordPress user JohnDoe
$cid = shopp_customer('JohnDoe', 'wpuser')->id;

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

// get product named 'My Download Product'
$MyDLProduct = shopp_product( 'My Download Product', 'name');

// add products to the cart
shopp_add_cart_product( $MyProduct,  2 );
shopp_add_cart_product( $MyDLProduct,  1 );

// create the order from the current cart
$Purchase = shopp_add_order( $cid );

See Also

  1. Avatar of Douglas Wilson

    This code didn’t work for me, after some tweaking I got it going, I believe it should be:

    // add products to the cart
    shopp_add_cart_product( $MyProduct->id,  2 );
    

    Note the addition of ID

    October 30th   #

You must be logged in to post a comment.

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

Skip to toolbar