Question

Is there any public function to add a product in to the shopping cart from a custom module? Or do I need to do some hard coding to achieve that? All the product info comes from a query, however im not able to figure out how to add it to the shopping cart.

Any ideas are welcome.

Était-ce utile?

La solution

Okay I figured it out.

Here is the code for future generations who are going to need similar help.

    $Cart = $this->context->cart; // can be achieved through cookies aswell, a matter of opinion
    $Cart->updateQty($quantity, $id_product, $id_product_attribute = null, $id_customization = false, $operator = 'up', $id_address_delivery = 0, $shop = null, $auto_add_cart_rule = true);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top