Add Quick Checkout Button Product Page WooCommerce – Redirect to Checkout Without Plugin

Adding Quick Checkout function to your WordPress shopping website on product page it will redirect customer directly to payment checkout page without using any plugin.

Here we share a simple code that can help to fast your checkout process most of out theme already have this feature included you can enable or disable from settings.

Add Quick Checkout Button Product Page WooCommerce  - Redirect to Checkout Without Plugin

Before we start suggest you to take backup of theme in any situation you can restore is to default.

Add Quick Checkout button to Product page

First you need to open function.php file from Dashboard > Appearance > Theme Editor now choose file from right side of list.

You can also access file from FTP client then go to WordPress install directory > wp-content > YOUR_THEME > function.php

Now paste below code into theme file.

function insertcart_addtocart_button_func() {
// echo content.
global $product;
$pid = $product->get_id();
$quicklink = WC()->cart->get_checkout_url();
echo '<div class="button quickcheckout"><a href="'.$quicklink.'?add-to-cart='.$pid.'">'.esc_attr('Quick Checkout').'</a></div>';
}
add_action( 'woocommerce_after_add_to_cart_button', 'insertcart_addtocart_button_func' );

Above code will show Quick checkout button just after Add to cart button.

Additionally you can add css to button as well.


.button.quickcheckout {
    border-radius: 5px;
    clear: both;
    margin-top: 10px;
    padding: 8px;
    background: #339ad5;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Name *
Email *