Shopping Cart API
This is an old revision of the document!
Allows to create/modify shopping cart and create an order after complete filling shopping cart. Consists of two main parts: Shopping Cart and Checkout processes.
Module: Mage_Checkout
Resource: cart
Methods |
cart.create |
Create a blank shopping cart
Return: int - Shopping Card Id (Quote Id)
Arguments:
- mixed (int | string) storeView - Store view Id or code (optional)
cart.order |
Create an order from shopping cart
Return: boolean
Arguments:
- int quoteId - Shopping Cart Id (Quote Id)
- mixed (int | string) storeView - Store view Id or code (optional)
- array (String) agreements - Website’s license identifiers (optional)
cart.info |
Get full information about current shopping cart
Return: array (ShoppingCartEntity) - return an associate array contained information about Shopping Cart (quote)
Arguments:
- int quoteId - Shopping Cart Id (Quote Id)
- mixed (int | string) storeView - Store view Id or code (optional)
cart.totals |
Get all available prices based on additional parameters set
Return: array (ShoppingCartPriceEntity) - return an associate array contained information about all prices in Shopping Cart (quote)
Arguments:
- int quoteId - Shopping Cart Id (Quote Id)
- mixed (int | string) storeView - Store view Id or code (optional)
cart.licenseAgreement |
Get website license agreement
Return: array of shoppingCartLicenseEntity - list with website license
Arguments:
- int quoteId - Shopping Cart Id (Quote Id)
- mixed (int | string) storeView - Store view Id or code (optional)
Faults |
| Fault Code | Fault Message |
|---|---|
| 1001 | Can not make operation because store is not exists |
| 1002 | Can not make operation because quote is not exists |
| 1003 | Can not create a quote. |
| 1004 | Can not create a quote because quote with such identifier is already exists |
| 1005 | You did not set all required agreements |
| 1006 | The checkout type is not valid. Select single checkout type. |
| 1007 | Checkout is not available for guest |
| 1008 | Can not create an order. |
Resource: cart_product
Methods |
cart_product.add |
Add product or several products into shopping cart
Return: boolean
Arguments:
- int quoteId - Shopping Cart Id (Quote Id)
- array of CartProductEntity - an array with list of CartProductEntity
- mixed (int | string) storeView - Store view Id or code (optional)
cart_product.update |
Update product or several products into shopping cart
Return: boolean
Arguments:
- int quoteId - Shopping Cart Id (Quote Id)
- array of CartProductEntity - an array with list of CartProductEntity
- mixed (int | string) storeView - Store view Id or code (optional)
cart_product.remove |
Remove product or several products from shopping cart
Return: boolean
Arguments:
- int quoteId - Shopping Cart Id (Quote Id)
- array of CartProductEntity - an array with list of CartProductEntity
- mixed (int | string) storeView - Store view Id or code (optional)
cart_product.list |
Get list of products in shopping cart
Return: array of catalogProductEntity - an array contained list of products
Arguments:
- int quoteId - Shopping Cart Id (Quote Id)
- mixed (int | string) storeView - Store view Id or code (optional)
cart_product.moveToCustomerQuote |
Move product(s) from Quote To Customer Shopping cart
Return: boolean
Arguments:
- int quoteId - Shopping Cart Id (Quote Id)
- array of CartProductEntity - an array with list of CartProductEntity
- mixed (int | string) storeView - Store view Id or code (optional)
Faults |
| Fault Code | Fault Message |
|---|---|
| 1001 | Can not make operation because store is not exists |
| 1002 | Can not make operation because quote is not exists |
| 1021 | Product’s data is not valid. |
| 1022 | Product(s) could not be added. |
| 1023 | Quote could not be saved during adding product(s) operation. |
| 1024 | Product(s) could not be updated. |
| 1025 | Quote could not be saved during updating product(s) operation. |
| 1026 | Product(s) could not be removed. |
| 1027 | Quote could not be saved during removing product(s) operation. |
| 1028 | Customer is not set for quote. |
| 1029 | Customer’s quote is not existed. |
| 1030 | Quotes are identical. |
| 1031 | Product(s) could not be moved. |
| 1032 | One of quote could not be saved during moving product(s) operation. |
Resource: cart_customer
Methods |
cart_customer.set |
Add Customer Information into shopping cart
Return: boolean
Arguments:
- int quoteId - Shopping Cart Id (Quote Id)
- CartCustomerEntity customerData - an associative array with customer information
- mixed (int | string) storeView - Store view Id or code (optional)
cart_customer.addresses |
Set customer’s addresses (shipping, billing) in shopping cart
Return: boolean
Arguments:
- int quoteId - Shopping Cart Id (Quote Id)
- array of CartCustomerAddressEntity customerAddressData - an array with list of CartCustomerAddressEntity
- mixed (int | string) storeView - Store view Id or code (optional)
Faults |
| Fault Code | Fault Message |
|---|---|
| 1001 | Can not make operation because store is not exists |
| 1002 | Can not make operation because quote is not exists |
| 1041 | Customer is not set. |
| 1042 | The customer’s identifier is not valid or customer is not existed |
| 1043 | Customer could not be created. |
| 1044 | Customer data is not valid. |
| 1045 | Customer’s mode is unknown |
| 1051 | Customer address data is empty. |
| 1052 | Customer’s address data is not valid. |
| 1053 | The customer’s address identifier is not valid |
| 1054 | Customer address is not set. |
| 1055 | Customer address identifier do not belong customer, which set in quote |
Resource: cart_shipping
Methods |
cart_shipping.method |
Set a shipping method for shopping cart
Return: boolean
Arguments:
- int quoteId - Shopping Cart Id (Quote Id)
- string shippingMethod - shipping method code
- mixed (int | string) storeView - Store view Id or code (optional)
cart_shipping.list |
Get list of available shipping methods for shopping cart
Return: array of CartShippingMethodEntity - an array with list of available shipping methods
Arguments:
- int quoteId - Shopping Cart Id (Quote Id)
- mixed (int | string) storeView - Store view Id or code (optional)
Faults |
| Fault Code | Fault Message |
|---|---|
| 1001 | Can not make operation because store is not exists |
| 1002 | Can not make operation because quote is not exists |
| 1061 | Can not make operation because of customer shipping address is not set |
| 1062 | Shipping method is not available |
| 1063 | Can not set shipping method. |
| 1064 | Can not receive list of shipping methods. |
Resource: cart_payment
Methods |
cart_payment.method |
Set a payment method for shopping cart
Return: boolean
Arguments:
- int quoteId - Shopping Cart Id (Quote Id)
- CartPaymentMethodEntity paymentData - an associative array with payment method information
- mixed (int | string) storeView - Store view Id or code (optional)
cart_payment.list |
Get list of available payment methods for shopping cart
Return: array of CartPaymentMethodEntity - an array with list of available payment methods
Arguments:
- int quoteId - Shopping Cart Id (Quote Id)
- mixed (int | string) storeView - Store view Id or code (optional)
Faults |
| Fault Code | Fault Message |
|---|---|
| 1001 | Can not make operation because store is not exists |
| 1002 | Can not make operation because quote is not exists |
| 1071 | Payment method data is empty. |
| 1072 | Customer’s billing address is not set. Required for payment method data. |
| 1073 | Customer’s shipping address is not set. Required for payment method data. |
| 1074 | Payment method is not allowed |
| 1075 | Payment method is not set. |
Resource: cart_coupon
Methods |
cart_coupon.add |
Add coupon (code) to Quote
Return: boolean
Arguments:
- int quoteId - Shopping Cart Id (Quote Id)
- string couponCode - coupon code
- mixed (int | string) storeView - Store view Id or code (optional)
cart_coupon.remove |
Remove coupon (code) from Quote
Return: boolean
Arguments:
- int quoteId - Shopping Cart Id (Quote Id)
- mixed (int | string) storeView - Store view Id or code (optional)
Faults |
| Fault Code | Fault Message |
|---|---|
| 1001 | Can not make operation because store is not exists |
| 1002 | Can not make operation because quote is not exists |
| 1081 | Coupon could not be applied because quote is empty. |
| 1082 | Coupon could not be applied. |
| 1083 | Coupon is not valid. |
Example |
- $proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
- $sessionId = $proxy->login('apiUser', 'apiKey');
- // Create a quote, get quote identifier
- $shoppingCartId = $proxy->call( $sessionId, 'cart.create', array( 'magento_store' ) );
- // Set customer, for example guest
- $customerAsGuest = array(
- "firstname" => "testFirstname",
- "lastname" => "testLastName",
- "email" => "testEmail",
- "website_id" => "0",
- "store_id" => "0",
- "mode" => "guest"
- );
- $resultCustomerSet = $proxy->call($sessionId, 'cart_customer.set', array( $shoppingCartId, $customerAsGuest) );
- // Set customer addresses, for example guest's addresses
- $arrAddresses = array(
- array(
- "mode" => "shipping",
- "firstname" => "testFirstname",
- "lastname" => "testLastname",
- "company" => "testCompany",
- "street" => "testStreet",
- "city" => "testCity",
- "region" => "testRegion",
- "postcode" => "testPostcode",
- "country_id" => "id",
- "telephone" => "0123456789",
- "fax" => "0123456789",
- "is_default_shipping" => 0,
- "is_default_billing" => 0
- ),
- array(
- "mode" => "billing",
- "firstname" => "testFirstname",
- "lastname" => "testLastname",
- "company" => "testCompany",
- "street" => "testStreet",
- "city" => "testCity",
- "region" => "testRegion",
- "postcode" => "testPostcode",
- "country_id" => "id",
- "telephone" => "0123456789",
- "fax" => "0123456789",
- "is_default_shipping" => 0,
- "is_default_billing" => 0
- )
- );
- $resultCustomerAddresses = $proxy->call($sessionId, "cart_customer.addresses", array($shoppingCartId, $arrAddresses));
- // add products into shopping cart
- $arrProducts = array(
- array(
- "product_id" => "1",
- "qty" => 2
- ),
- array(
- "sku" => "testSKU",
- "quantity" => 4
- )
- );
- $resultCartProductAdd = $proxy->call($sessionId, "cart_product.add", array($shoppingCartId, $arrProducts));
- // update product in shopping cart
- $arrProducts = array(
- array(
- "product_id" => "1",
- "qty" => 5
- ),
- );
- $resultCartProductUpdate = $proxy->call($sessionId, "cart_product.update", array($shoppingCartId, $arrProducts));
- // remove products from shopping cart, for example by SKU
- $arrProducts = array(
- array(
- "sku" => "testSKU"
- ),
- );
- $resultCartProductRemove = $proxy->call($sessionId, "cart_product.remove", array($shoppingCartId, $arrProducts));
- // get list of products
- $shoppingCartProducts = $proxy->call($sessionId, "cart_product.list", array($shoppingCartId));
- print_r( $shoppingCartProducts );
- // get list of shipping methods
- $resultShippingMethods = $proxy->call($sessionId, "cart_shipping.list", array($shoppingCartId));
- print_r( $resultShippingMethods );
- // set shipping method
- $randShippingMethodIndex = rand(1, count($resultShippingMethods) );
- $shippingMethod = $resultShippingMethods[$randShippingMethodIndex]["code"];
- $resultShippingMethod = $proxy->call($sessionId, "cart_shipping.method", array($shoppingCartId, $shippingMethod));
- // get list of payment methods
- $resultPaymentMethods = $proxy->call($sessionId, "cart_payment.list", array($shoppingCartId));
- print_r($resultPaymentMethods);
- // set payment method
- $paymentMethod = array(
- "method" => "checkmo"
- );
- $resultPaymentMethod = $proxy->call($sessionId, "cart_payment.method", array($shoppingCartId, $paymentMethod));
- // add coupon
- $couponCode = "aCouponCode";
- $resultCartCouponRemove = $proxy->call($sessionId, "cart_coupon.add", array($shoppingCartId, $couponCode));
- // remove coupon
- $resultCartCouponRemove = $proxy->call($sessionId, "cart_coupon.remove", array($shoppingCartId));
- // get total prices
- $shoppingCartTotals = $proxy->call($sessionId, "cart.totals", array($shoppingCartId));
- print_r( $shoppingCartTotals );
- // get full information about shopping cart
- $shoppingCartInfo = $proxy->call($sessionId, "cart.info", array($shoppingCartId));
- print_r( $shoppingCartInfo );
- // get list of licenses
- $shoppingCartLicenses = $proxy->call($sessionId, "cart.licenseAgreement", array($shoppingCartId));
- print_r( $shoppingCartLicences );
- // check if license is existed
- $licenseForOrderCreation = null;
- if (count($shoppingCartLicenses)) {
- $licenseForOrderCreation = array();
- foreach ($shoppingCartLicenses as $license) {
- $licenseForOrderCreation[] = $license['agreement_id'];
- }
- }
- // create order
- $resultOrderCreation = $proxy->call($sessionId,"cart.order",array($shoppingCartId, null, $licenseForOrderCreation));


