4

Info

I'm quite new to Magento and now I've to develop an external service (C# web service), which needs to add a product to a customers cart (using the SOAPv2 call shoppingCartProductAdd). The only information I got is the encrypted customer session id and the quote id (if the customer has already a cart).

Problem

If I've the qoute id (cart id), everything works just fine. Without the qoute id the product can't be added of course.

Question(s)

Is it possible to create a cart for a session? Yes I've already seen the method shoppingCartCreate, but this will only create a cart and doesn't connect it with the customer session. Is there a method for connecting the a cart with a session?

1
  • I have created cart using "cart.create" and then assinged to customer using "cart_customer.set". but this will only create a cart on "LocalHost" and doesn't connect it with the customer session on "Live Website". Is there something that am i missing for cart sync?
    – pallavi
    Jan 19, 2016 at 16:18

1 Answer 1

1

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.

You are trying to fill a customers shopping cart with products from the SOAP API which is not a standard function.

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:

Mage::getSingleton('checkout/session')
    ->setCustomer(Mage::getSingleton('customer/session')->getCustomer());

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

Your Answer

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

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