WooCommerce: Replace “Add To Cart” with “Ask” Form for Custom Products

When you Google the phrase “replace Add to Cart WooCommerce” (or any variants thereof), there are a lot of SERP’s suggesting the same way of hiding/not displaying the Add To Cart button. The idea is to remove the “woocommerce_template_single_add_to_cart” action.

Replace “Add to Cart” for Custom Products

However, in my case, I wanted to do this for only certain specific products. I have products that are marked as “Custom”, i.e. not stocked products. These are products that can be customized as per the customer/client. They usually take 6-8 weeks from order to delivery. The idea for the landing pages for these “Custom” products is not for them to make the purchase outright, but get them to contact the store owner. This way, the process of designing the custom product can be taken offline.

How to Designate a Product as “Custom”

The first step is to identify the products as “Custom” in WooCommerce. Following this guide by Remy Corson, I added a Checkbox under the General tab in the Product Edit Screen. When this Checkbox is checked, it means that the Product is “Custom”.

"Custom" product
“Custom” product

As you can see in the image above, this product is defined as “Custom”.

Next up, we have to hook into the correct action for marking all “Custom” products as not being allowed for Purchase. We will use the is_purchaseable() hook for that purpose.

Alternative CTA for “Custom” Products

I wanted a form to take the place of the “Add To Cart” button. In my case, I use Contact Form 7 for my forms. I just added a small form specifically for the purpose of this CTA. The visitors will see this form in place of the Add to Cart button. The store owner receives an email containing the lead.

We are simply checking if the Product is “Custom”. If it is “Custom”, we will set it as being non-purchaseable. This will hide the “Add To Cart” button for such “Custom” products.

Full Code Listing

Here is the full code. Notice that 2 other custom fields were added. You do not need those, so you can easily delete the relevant lines of code.

add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' );
function woo_add_custom_general_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
'id' => '_no_free_shipping_checkbox',
'wrapper_class' => '',
'label' => __('Exclude From Free Shipping', 'woocommerce' ),
'description' => __( 'Dis-allow Free Shipping', 'woocommerce' )
'id' => '_discontinued_product_checkbox',
'wrapper_class' => '',
'label' => __('Discontinued Product', 'woocommerce' ),
'description' => __( 'No longer in Production', 'woocommerce' )
'id' => '_custom_product',
'wrapper_class' => '',
'label' => __('Custom Order Product', 'woocommerce' ),
'description' => __( 'Product can be customized', 'woocommerce' )
echo '</div>';
// Save Fields
add_action( 'woocommerce_process_product_meta', 'woo_add_custom_general_fields_save' );
function woo_add_custom_general_fields_save( $post_id ){
// Checkbox
$woocommerce_checkbox = isset( $_POST['_no_free_shipping_checkbox'] ) ? 'yes' : 'no';
update_post_meta( $post_id, '_no_free_shipping_checkbox', $woocommerce_checkbox );
$woocommerce_product_checkbox = isset( $_POST['_discontinued_product_checkbox'] ) ? 'yes' : 'no';
update_post_meta( $post_id, '_discontinued_product_checkbox', $woocommerce_product_checkbox );
$woocommerce_custom_product_checkbox = isset( $_POST['_custom_product'] ) ? 'yes' : 'no';
update_post_meta( $post_id, '_custom_product', $woocommerce_custom_product_checkbox );
add_filter('woocommerce_is_purchasable', 'ar_custom_is_purchasable', 10, 2);
function ar_custom_is_purchasable( $is_purchasable, $object ) {
// get the product id first
$product_id = $object->get_id();
// get the product meta data
$is_custom = get_post_meta($product_id, '_custom_product', true);
if ($is_custom == "yes"){
return false;
else {
return true;
add_action( 'woocommerce_single_product_summary', 'ar_custom_product_cta', 60);
function ar_custom_product_cta()
global $product;
// get the product id first
$product_id = $product->get_id();
// get the product meta data
$is_custom = get_post_meta($product_id, '_custom_product', true);
// Show the Form if product is Custom
if ($is_custom == "yes"){
echo '<h5> Questions? We respond in minutes! </h5>';
echo do_shortcode( '[contact-form-7 404 "Not Found"]' );

view raw
hosted with ❤ by GitHub

Questions/Comments? Type away in the comments below.

code ecommerce WooCommerce Wordpress

[WooCommerce] Checkout Progress Bar

As you read articles/posts on ecommerce optimization, specifically checkout optimization, a popular theme emerges: The Checkout Progress Bar. The idea is to provide your visitors some kind of visual feedback that they are making progress. It tells them how far along they are before the purchase is complete. Conversely, it tells them how much longer before they can own the product/service they are vying for.

With this in mind, I googled for a free plugin that would accomplish just that. My search ended fruitless (almost). I did hit this gem of a plugin called Progress Bar. This is a simple plugin that can be used anywhere on a WordPress site.


In this article, my aim is to create your own customized checkout progress bar without the use of any paid plugins. You will need

  • Download the Progress Bar plugin from the WordPress plugin repository
  • Make some code changes (PHP and JS included). Download from github.

The code changes are shown below. The first change is in your theme/child theme’s functions.php file. Two things are happening here:

  1. Hooking into the “woocommerce_checkout_before_customer_details” action hook to display the Progress Bar. We use the shortcode for the Progress Bar because it allows to send in parameters for styling and appearance.
  2. Loading the JavaScript file that will manipulate the Progress Bar based on how much of the Checkout Form has been validated.

The second file is the JS script that checks in real-time which mandatory fields have been validated. Then it calculates the progress (in pixels) by simply dividing the “number of fields validated” by the “number of fields that require validation”. It also accounts for the “Shipping Address Same as Billing Address” checkbox.

The end result is you get a progress bar for your WooCommerce Checkout Page.

WooCommerce Checkout  Progress Bar in Action
WooCommerce Checkout Progress Bar in Action

Notes on Customization

The CSS for the progress bar can be easily customized. Follow the instructions on this link. Also, note that the plugin has quite a few options that can be used for customizing the look and feel of the Progress Bar.

ecommerce Wordpress

Evaluation of JigoShop as WordPress e-Commerce platform

So far, I have had some time to look at JigoShop for evaluation as an ecommerce plugin for WordPress. Coming from a setup where we use dedicated CMS’s for e-commerce, the idea of a plugin seems a little too thin, relatively speaking. i.e. maybe the plugin does not have all the features that a full scaled CMS that is geared towards ecommerce use.

I have found that last part to be mostly untrue, since JigoShop supports a lot of features, right out of the box. It also has a variety of secondary plug-ins for SEO, email etc that make it powerful.

Looking closer at the JigoShop code, I realize that internally it does not use separate tables dedicated to the ecommerce functionality. Instead, it embeds and extends the core WordPress database tables for tailoring it to WordPress. At this point, I am not sure what are the advantages and disadvantages of this structure.

I will continue writing about whatever I discover about the different eCommerce plugins like WordPress.

If you have any feedback, feel free to comment below.