Woocommerce add to cart button redirect to checkout

前端 未结 8 1965
时光取名叫无心
时光取名叫无心 2020-12-05 23:49

I created an ecommerce using the plugin woocommerce. I am selling only a subscription so the \"/cart/\" page is useless. I\'m trying to get rid of it so that when my custome

相关标签:
8条回答
  • 2020-12-06 00:30

    None of the solutions actually worked out for me, the filter add_to_cart_redirect was triggering on every page,not only on the cart.I did some modification on the suggested answer.

    add_filter ('add_to_cart_redirect', 'redirect_to_checkout');
      function redirect_to_checkout() {
      if(is_cart()){
        $checkout_url = WC()->cart->get_checkout_url();
      ?>
      <script>
      location = '<?=$checkout_url?>';
      </script>
      <?php 
      }
    }
    
    0 讨论(0)
  • 2020-12-06 00:33

    I've found a simple solution that work like magic.

    1. As mentioned by @Ewout, check the box that says "Redirecto to cart page after succesful addtion".
    2. Woocommerce > Settings > Checkout (Tab) - where you should select pages for cart and checkout, select the checkout page as the cart page (image attached).

    That's it. works for me. enter image description here

    0 讨论(0)
提交回复
热议问题