Jump to content

Problem with Cart


soir

Recommended Posts

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!

 

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...