Redirect to cart after "add to cart" - Debut Theme

Vvs2022
New Member
3 0 2

I run a 1 product store and would love if add to cart redirects to the cart with the same click. Right now, once add-to-cart is clicked a little notification appears in the top right side of the store notifying me its in the cart and I can choose to go to the cart from there. However since I only sell 1 product this is just 1 unnecessary click and surely leads to abandoned carts.

Michal_Morek
Shopify Partner
821 73 139

Hi @Vvs2022 

Hope you're having a great day!

You should enable dynamic checkout buttons.

Your customers can use the dynamic checkout button to quickly buy the product they're viewing. They skip the cart and complete their payment with the checkout method displayed on the button. The button dynamically changes to reflect the customer's preferred accelerated checkout method.

Chopper-All-in-One-B-–-deluxyys (1).png

Useful resources:

Adding and removing dynamic checkout buttons

Founder of Shopify agency - Accomplishify.com
If you would like to hire us as Shopify experts, please reach out via:
  • Email michal.morek@accomplishify.com
  • WhatsApp +48 507 613 425
bdowling
Explorer
66 13 39

Hi, Michal offered a good solution. If you do not want to use the Buy button; however, here is a solution for your described desired outcome (how to redirect to the cart).

Step 1: Find this chunk of code in the "theme.js" file in the assets folder near line 8259:

 

 

 

 

        .then(function(json) {
          if (json.status && json.status !== 200) {
            var error = new Error(json.description);
            error.isFromServer = true;
            throw error;
          }
          self._hideErrorMessage();
          self._setupCartPopup(json);
      })

 

 

 

 

 

Step 2: Comment out "self._setupCartPopup(json);" (just comment in case you want to change it back) 

Step 3:  Directly under that line, add this line:

 

 

 

 

windowObjectReference = window.open(self.cartRoutes.cartUrl, "_self");

 

 

 

 

So the whole chunk should look like this now:

 

 

 

 

        .then(function(json) {
          if (json.status && json.status !== 200) {
            var error = new Error(json.description);
            error.isFromServer = true;
            throw error;
          }
          self._hideErrorMessage();
          //self._setupCartPopup(json);
          windowObjectReference = window.open(self.cartRoutes.cartUrl, "_self");
      })

 

 

 

 

That should do it. Good luck with whichever solution you choose.