WooCommerce Checkout Upsell Checkbox

WooCommerce Checkout form showing custom checkbox which is a product upsell

Pre-Requisites

You’ll need the Product ID of the product you wish to link to and upsell.

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

Do you want to be able to upsell products on the WooCommerce checkout without any bloated, expensive plugins? This quick guide shows you how to upsell a product at the checkout stage of the buying journey by implementing a checkbox which adds a product of your choice to the order. Simple replace the product ID in the code with your product ID of choice and change the text as necessary. We recommend making the upsell product a hidden, discounted product so that the upsell offer is more appealing and true in that it is a one-time offer only.

				
					/**
 * Snippet Name:     Add custom hidden_product_upsell at WooCommerce checkout
 * Snippet Author:   ecommercehints.com
 */

add_action( 'woocommerce_review_order_before_submit', 'ecommercehints_hidden_product_upsell_checkbox' );
add_action( 'woocommerce_checkout_order_processed', 'ecommercehints_hidden_product_upsell_something', 9, 3 );

function ecommercehints_hidden_product_upsell_checkbox() {
   echo '<p class="form-row">
      <label class="woocommerce-form__label woocommerce-form__label-for-checkbox checkbox">
         <input type="checkbox" class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" name="ecommercehints_hidden_product_upsell">
         <span>Today\'s Offer - get <a href="UPSELL_PRODUCT_URL_HERE" target="_blank">the belt to match</a> for just £55!</span>
      </label>
   </p>';
}

function ecommercehints_hidden_product_upsell_something( $order_id, $posted_data, $order ) {
   if( isset( $_REQUEST['ecommercehints_hidden_product_upsell'] ) && $_REQUEST['ecommercehints_hidden_product_upsell'] == 'on' ) { 
      $product = wc_get_product( 15 ); // The product ID you would like to upsell
      $order->add_product( $product );
      $order->calculate_totals();
   }
}
				
			

Snippet Benefits

  • Increase you AOV (Average Order Value) by upselling products on the checkout page with a simple checkbox.
WooCommerce Conversion Rate Optimisation (CRO) eBook
100 WooCommerce Conversion Rate Optimisation Tips

Leave a Reply

If you are going to write code in the comments, please wrap it between code tags.

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

Other Recent Guides

Subscribe To Emails

Get exclusive WooCommerce tips that I only share with email subscribers

Join hundreds of other subscribers