Hey!
I am new to PrestaShop, I have developed a custom module and I have a problem.
When choosing a product to add to cart is added only if logged on, I think it's a problem with the cookie.
My code to add a producto to cart:
$context=Context::getContext(); //new Cart();
$id_cart=$context->cookie->__get('id_cart');
if (count($_POST["service"])>0){
$cart=new Cart($id_cart);
$cart->id_currency=2;
$cart->id_lang=1;
foreach($_POST["service"] as $variable_get_services) {
$site_get_services = $variable_get_services;
$site_get_services = str_replace("service-", "", $site_get_services);
if (($site_get_services == "0") || ($site_get_services == "")) {} else {
$cart->updateQty(1, $site_get_services);
}
}
}
Thnx!