471

How to Redirect Add to Cart to Checkout Page in WooCommerce

Powered by WPCodeBox

After adding a product to the cart, automatically redirect customers to the checkout page in WooCommerce. This snippet is useful for stores selling a single product or streamlining the purchase process.


<?php

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

Other Snippets

WPCodeBox is a WordPress Code Snippets Manager that allows you to share your WordPress Code Snippets across your sites.