In Woocommerce, how do I add a "Continue" button inked to the the product page just after?
And inside the product page how to add a checkout button just under the add to cart button?
Any help is appreciated.
The following code will:
The code:
// Archives pages: Additional button linked to the product
add_action( 'woocommerce_after_shop_loop_item', 'loop_continue_button', 15 );
function loop_continue_button(){
global $product;
if( $product->is_type('simple') ){
$link = $product->get_permalink();
$text = __("Continue", "woocommerce");
echo '<a href="' . $link . '" class="button alt" style="margin-top:10px;">' . $text . '</a>';
}
}
// Single product pages: Additional button linked to checkout
add_action( 'woocommerce_single_product_summary', 'product_additional_checkout_button', 1 );
function product_additional_checkout_button() {
global $product;
// For variable product types
if( $product->is_type( 'variable' ) ) {
add_action( 'woocommerce_single_product_summary', 'custom_checkout_button', 21 );
}
// For all other product types
else {
add_action( 'woocommerce_single_product_summary', 'custom_checkout_button', 31 );
}
}
function custom_checkout_button() {
$link = wc_get_checkout_url();
$text = __("Proceed to checkout", "woocommerce");
echo '<a href="' . $link . '" class="button alt" style="margin-bottom:14px;">' . $text . '</a>';
}
Code goes in function.php file of your active child theme (or active theme). Tested and work.