Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Shopping Cart API

Allows you to create/modify shopping cart and create an order after complete filling the shopping cart. Consists of two main parts: Shopping Cart and Checkout processes.

Module: Mage_Checkout

Resource: cart_product

Method:

  • cart_product.add (SOAP V1)
  • shoppingCartProductAdd (SOAP V2)

Allows you to add one or more products to the shopping cart (quote).

Arguments:

TypeNameDescription
stringsessionIdSession ID
intquoteIdShopping cart ID (quote ID)
arrayproducts\productsDataAn array with the list of shoppingCartProductEntity
stringstoreIdStore view ID or code (optional)

Returns:

TypeDescription
booleanTrue on success (if the product is added to the shopping cart)

The shoppingCartProductEntity array attributes are as follows:

TypeNameDescription
stringproduct_idID of the product to be added to the shopping cart (quote) (optional)
stringskuSKU of the product to be added to the shopping cart (quote) (optional)
doubleqtyNumber of products to be added to the shopping cart (quote) (optional)
associativeArrayoptionsAn array in the form of option_id => content (optional)
associativeArraybundle_optionAn array of bundle item options (optional)
associativeArraybundle_option_qtyAn array of bundle items quantity (optional)
ArrayOfStringlinksAn array of links (optional)

Faults:
No Faults.

Examples

Request Example SOAP V1
$proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
$sessionId = $proxy->login('apiUser', 'apiKey');

$quoteId = $proxy->call( $sessionId, 'cart.create', array( 'magento_store' ) );
$arrProducts = array(
	array(
		"product_id" => "1",
		"qty" => 2
                "options" => array(         
                    optionId_1 => optionValue_1,
                    ...,
                    optionId_n => optionValue_n
                 )
	),
	array(
		"sku" => "testSKU",
		"quantity" => 4
	)
);
$resultCartProductAdd = $proxy->call(
	$sessionId,
	"cart_product.add",
	array(
		$quoteId,
		$arrProducts
	)
);
Request Example SOAP V2
$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl'); 
 
$sessionId = $proxy->login('apiUser', 'apiKey'); 
  
$result = $proxy->shoppingCartProductAdd($sessionId, 10, array(array(
'product_id' => '4',
'sku' => 'simple_product',
'qty' => '5',
'options' => null,
'bundle_option' => null,
'bundle_option_qty' => null,
'links' => null
)));   
 
 
var_dump($result);
Request Example SOAP V2 (WS-I Compliance Mode)
$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl');

$sessionId = $proxy->login((object)array('username' => 'apiUser', 'apiKey' => 'apiKey'));

$result = $proxy->shoppingCartProductAdd((object)array('sessionId' => $sessionId->result, 'quoteId' => 10, 'productsData' => array(array(
'product_id' => '4',
'sku' => 'simple_product',
'qty' => '1',
'options' => null,
'bundle_option' => null,
'bundle_option_qty' => null,
'links' => null
))));


var_dump($result->result);