To add product to shopping cart from a module controller you can use the function bellow.


public function addToCart(){

$context=Context::getContext();
$message='';
$id_cart=(int)$context->cookie->id_cart;
if(Tools::isSubmit('submitAddProduct')){

$cart=new Cart($id_cart);
$id_product=(int)Tools::getValue('id_product');
$quantity=(int)Tools::getValue('ordered_qty');

$cart->updateQty($quantity, $id_product, null, false);
$message='Product Added Successfully';
}

return $message;

}
Facebook Comments Box
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments