Jump to content

[How to?] Add to cart = go to checkout OR go to cart (1.7)


PS-WebAgentur

Recommended Posts

Hi :)

 

hope someone can help me with the problem. How I can go directly to the checkout / cart when I'm clicking on "Add to cart"-Button on the product-site. I don't want to show the modal-dialog (popup with information and the opinion to go back or to the cart). It should go faster for the customer. They just have to buy one article.

 

post-923326-0-10317500-1486900441_thumb.png

 

Hope you can help me. :) I've searched for hours ... :

 

Greetings

Philipp

  • Like 1
Link to comment
Share on other sites

Thank you for the tip. I've tried this before, but then nothing happens. The customer remains on the product page, the product lands in the shopping cart, but you have to go to the checkout manually. How I can edit the code in the product-add-to-cart.tpl, so that the customer is automatically sent to checkout? Can you help me or need you the url of the website?

 <div class="add">
          <button class="btn btn-primary add-to-cart" data-button-action="add-to-cart" type="submit" {if !$product.add_to_cart_url || $product.quantity_wanted>$product.quantity}disabled{/if}>
            <i class="material-icons shopping-cart"></i>
            {l s='Add to cart' d='Shop.Theme.Actions'}
          </button>
Edited by PS-WebAgentur (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 3 months later...

 

Thank you for the tip. I've tried this before, but then nothing happens. The customer remains on the product page, the product lands in the shopping cart, but you have to go to the checkout manually. How I can edit the code in the product-add-to-cart.tpl, so that the customer is automatically sent to checkout? Can you help me or need you the url of the website?

 <div class="add">
          <button class="btn btn-primary add-to-cart" data-button-action="add-to-cart" type="submit" {if !$product.add_to_cart_url || $product.quantity_wanted>$product.quantity}disabled{/if}>
            <i class="material-icons shopping-cart"></i>
            {l s='Add to cart' d='Shop.Theme.Actions'}
          </button>

Have you solved this? At the moment i am only thinking about solving it via a javascript onclick function, but i think this is the wrong way.

Link to comment
Share on other sites

  • 3 years later...

You can do it with the hook actionCartSave

Create a module, or upgrade an existing module, let it install this hook, then create this function in the module:

	public function hookActionCartSave($params){
		Tools::redirect('order');
	}

Now anytime you're adding, removing, or somehow updating the cart, it will redirect you to order.php

Quote

actionCartSave

After a product is added to the cart or if the cart’s content is modified

Located in: /classes/Cart.php

 
 

https://devdocs.prestashop.com/1.7/modules/concepts/hooks/list-of-hooks/

Link to comment
Share on other sites

Also, I've gone straight up into the template file checkout/cart.tpl and replaced everything in there with

{Tools::redirect('order')}

There's absolutely no point to having this "cart" page, all it does is make the customer jump through another hoop before clicking the "pay now" button, especially since checkout.tpl (which is the file you see when you go to the order contoller) - especially since this file looks almost the same as cart.tpl

🙄

 

Edit: This definitely causes glitches sometimes. 

May be better to create a cart.tpl that looks identical to checkout.tpl in case a customer ever visits /cart or for whatever other reason they might land on this page.

 

It's definitely possible to delete /cart in back office (Shop Parameters -> SEO & URLs). {$product.add_to_cart_url} will then be resolved to /index.php?controller=cart instead of /cart

Of course, this may still lead to a customer sometimes being taken to index.php?controller=cart, so the cart.tpl still needs to be optimized for checkout.

Edited by theillo (see edit history)
Link to comment
Share on other sites

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...