Product Archive, Product Page

WooCommerce Call For A Price

WooCommerce product archive loop items and single product template showing call for a price button instead of add to cart button

Pre-Requisites

There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About This Solution

This snippet removes all instances of the Add To Cart button whatever the product type (Simple, Grouped, Variable, External) then displays a new button on both the product archive loop items and the single product template which says “Call for a price”. This button, if clicked, is hyperlinked to a custom telephone number which will be called on click. This guide is useful if you don’t want users to see prices and require them to call you instead of adding products to cart.

/**
 * Snippet Name:	WooCommerce Call For A Price
 * Snippet Author:	ecommercehints.com
 */

// First, remove all instances of the add to cart button
remove_action( 'woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30 );
remove_action( 'woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart', 30 );
remove_action( 'woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30 );
remove_action( 'woocommerce_external_add_to_cart', 'woocommerce_external_add_to_cart', 30 );
remove_action( 'woocommerce_single_variation', 'woocommerce_single_variation', 10 );
remove_action( 'woocommerce_single_variation', 'woocommerce_single_variation_add_to_cart_button', 20 );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );

// Show a new 'Call for a price' button on the product archive loop items
function ecommercehints_call_for_a_price_on_product_archive_loop() {
   echo '<a class="button" href="tel:5551234567">Call for a price</a>';	// Telephone number and button text
};
add_action ('woocommerce_after_shop_loop_item', 'ecommercehints_call_for_a_price_on_product_archive_loop', 10, 0);

// Show a new 'Call for a price' button on the single product template
function ecommercehints_call_for_a_price_on_single_product_template() {
   echo '<a class="button" href="tel:5551234567">Call for a price</a>';	// Telephone number and button text
};
add_action ('woocommerce_single_product_summary', 'ecommercehints_call_for_a_price_on_single_product_template', 25, 0);

Snippet Benefits

  • Remove all ‘Add To Cart’ buttons and replace them with a ‘Call For A Price’ button.

100 WooCommerce Conversion Rate Optimisation Tips

This field is for validation purposes and should be left unchanged.

Let’s collaborate!

Need to outsource WordPress development?

Join forces with UnlimitedWP for an outsourced white label web development service you can truly rely on.

First Timer Here?

Sign up to receive 20% off on your first month with us.

26027
WELCOME OFFER