1

I have been trying to work out the correct way to add a configurable product to the cart via a custom end point.

$cart->addProduct($product, $params);

I want to know if it is okay for $product to be a simple product, or whether it is more correct for it to be the configurable product with the correct configurable attributes. Is there any difference, or advantage to either approach? Is it wrong to add a simple product to the cart like this, when it actually has a configurable product parent?

0

You can use either type, see Adding a product to the cart via querystring

To add a simple product with custom options simply add options[id]=[value] to the end. The basic structure is:

/path/to/magento/checkout/cart/add?product=$id&qty=$qty&options[$id]=$value

For adding a Configurable Product to the Cart via Querystring you need a url format like following

/checkout/cart/add?product=68&qty=1&super_attribute[528]=55&super_attribute[525]=56

|improve this answer|||||
0

I believe it is better to add the simple product for the inventory, the picture in the cart in case of color declinaisons... By the way, I never tried to add the configurable with options. So I do not know what is the best or even if it is possible and I cannot try at the moment.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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