[英]prestashop: How to add a product from a custom module to shopping cart
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. 任何想法都欢迎。
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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.