Skip to content

Instantly share code, notes, and snippets.

@BFTrick
Last active October 29, 2019 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save BFTrick/88189f4fc5924ed5f4f074ea8b193482 to your computer and use it in GitHub Desktop.
Save BFTrick/88189f4fc5924ed5f4f074ea8b193482 to your computer and use it in GitHub Desktop.
Add a Call to order button on the product archive page(s) (Shop page)
<?php
function patricks_woocommerce_call_to_order_button(){
global $product; //get the product object
if ( $product ) { // if there's a product proceed
$url = esc_url( $product->get_permalink() ); //get the permalink to the product
echo '<a rel="nofollow" href="' . $url . '" class="button add_to_cart_button ">Call to order!</a>'; //display a button that goes to the product page
}
}
add_action('woocommerce_after_shop_loop_item','patricks_woocommerce_call_to_order_button', 10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment