I'm using PrestaShop 1.7.x and I'd like to find a way to automatically add a product to the cart and redirect to the checkout at the same time.
It works for Woocommerce (e.g. https://example.com/checkout/?add-to-cart=36) but I'd like the same on PrestaShop.
I tried to call a link like this but it does not seem to work: http://localhost/s/en/women/2-9-brown-bear-printed-sweater.html#/1-size-s/cart?action=add-to-cart
Hi @Ashish Sharawat and Welcome to SO!
This is not the default behavior in PrestaShop 1.7.x, however you can do the following:
autoAddToCart()
method inside$this->context->cart->updateQty($quantity, $id_product, $id_product_attribute)
and thenTools::redirect('index.php?controller=order&step=2');
https://<shop_domain>/en/module/mymodule/autoaddtocart?quantity=1&id_product=1&id_product_attribute=1
Alternately, if you use PrestaShop 1.6.x, you can turn on an option to automatically redirect a customer to the checkout after adding a product to the cart:
I hope this helps!