Woocommerce add to cart button redirect to checkout

前端 未结 8 1963
时光取名叫无心
时光取名叫无心 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-06 00:26

    @RemiCorson posted this brief but beneficial tutorial:

    http://www.remicorson.com/woocommerce-skip-product-cart-pages/

    He mentions the same filter as @Ewout above,

    add_filter ('add_to_cart_redirect', 'redirect_to_checkout');
    
    function redirect_to_checkout() {
        global $woocommerce;
        $checkout_url = $woocommerce->cart->get_checkout_url();
        return $checkout_url;
    

    }

    but one line of code stands out and is of super value for me for my current woocommerce project:

    There is a direct link that a user can use to automatically bypass the product page. http://your-site.com/?add-to-cart=37

    '37' will be replaced by your product ID.

    This was useful for me to eliminate unnecessary steps and take users directly to checkout from the home page and other non-woocommerce pages/posts.

提交回复
热议问题