I am adding a product to cart via SOAP V2 API:

$client = new SoapClient('http://mywebsite.com/api/v2_soap/?wsdl');
$session = $client->login('username', 'password');

$quoteId = $client->shoppingCartCreate($session);

$customerData = array(
    "firstname" => "Klevis",
    "lastname" => "Miho",
    "email" => "[email protected]",
    "customer_id" => 2522,
    "mode" => "customer",
    "website_id" => "1"

$resultCustomerSet = $client->shoppingCartCustomerSet($session, $quoteId, $customerData);

$result = $client->shoppingCartProductAdd($session, $quoteId, array(array(
    'product_id' => '336',
    'sku' => '110757',
    'qty' => '1',
    'options' => null,
    'bundle_option' => null,
    'bundle_option_qty' => null,
    'links' => null

$result1 = $client->shoppingCartInfo($session, $quoteId); 

var_dump($result); //returns true

In the end it returns true. But when I login on the frontend there are no products in my shopping cart.

Am I missing something here?

2 Answers 2


The Magento SOAP API is a web-Service and is meant for data exchange with external systems such as ERP, accounting, etc. You can create orders via SOAP-API in your shop which you will see afterwards in the customers account as well as in the shop admin-interface.

The use-case you are trying to create is, to fill a customers shopping cart with products. So, basically, what you're doing is right, it's just not the way the intended usage of the web-service.

I've never set it up like this, but what you need to do to achieve your goal is, to create a connection between your visitors/customers session in the browser and the shopping cart.

Depending on your intended usage you'll need to access the visitors', customers' and checkout session:

Get the visitor session:

$session = Mage::getSingleton('core/session');

Get the customer session:

$session = Mage::getSingleton('customer/session');

Get the checkout session:

$session = Mage::getSingleton('checkout/session');

Set customers session to checkout session:


Whatever you do: Be careful with setting, storing,... the session-id via URL and cookies. This can be a potentical security issue.

  • Someone is building a android app which just adds products on the cart, then the user can checkout from a desktop. I am testing the SOAP API for that. Makes sense? What do I need to add to make code to make it work? Commented Sep 17, 2014 at 11:06
  • I see. Persistant Shopping might also be a solution for you then?! magentocommerce.com/knowledge-base/entry/… Commented Sep 17, 2014 at 11:14
  • I have enabled Persistent Shopping cart, but doesn't solve the problem. Thanks Anna for trying to help me. Commented Sep 17, 2014 at 11:20

I think you have to set quote(shopping cart) active by custom code:

$quoteData = Mage::getModel('sales/quote')->load($quoteId);
if($quoteData->getIsActive()==0) {

because by default quote is not activated when its created.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.