If you want to increase your AOV (Average Order Value), you can definitely start from the WooCommerce Checkout page.
A client asked me to place a “Donation Area” close to the “Place Order” button (so at the bottom of the page, once customers are ready to pay) to drive more awareness around this add-on. All I had to do was creating hidden products with a donation value, use my own “Custom Add to Cart URL” guide to create add to cart links and print an HTML box right above the checkout button by using my WooCommerce Visual Hook Guide for the Checkout Page. Enjoy!
PHP Snippet: Show Add-Ons Area @ WooCommerce Checkout Page
Requirements:
- Product IDs you want to add to Cart (14877, 14879, 15493 in my example)
- No “redirect to Cart after add to cart” option checked in WooCommerce settings
/**
* @snippet Upsell Area - WooCommerce Checkout
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 3.6.1
* @community https://businessbloomer.com/club/
*/
add_action( 'woocommerce_review_order_before_submit', 'bbloomer_checkout_add_on', 9999 );
function bbloomer_checkout_add_on() {
$product_ids = array( 14877, 14879, 15493 );
$in_cart = false;
foreach( WC()->cart->get_cart() as $cart_item ) {
$product_in_cart = $cart_item['product_id'];
if ( in_array( $product_in_cart, $product_ids ) ) {
$in_cart = true;
break;
}
}
if ( ! $in_cart ) {
echo '<h4>Make a Donation?</h4>';
echo '<p><a class="button" style="margin-right: 1em; width: auto" href="?add-to-cart=14877"> €5 </a><a class="button" style="margin-right: 1em; width: auto" href="?add-to-cart=14879"> €20 </a><a class="button" style="width: auto" href="?add-to-cart=15493"> €50 </a></p>';
}
}
Is there a good way to make a small table for ‘related’ and ‘upsell’ items that have already been selected in the store, and match the cart items – just as the shopping cart is already capable of doing?
I have small section on my Check Out page that I’d love to display 1-3 ‘related’ products’ on.
I love your site and appreciate all of your hard work!
Hello Sam, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
is it possible that it doesn’t work with the latest WooCommerce edition?
WooCommerce 8.6.0 version
Do you use the Checkout Block or the standard checkout shortcode?
How can I follow with a redirect to /checkout/. When on the ‘?add-to-cart=14877’ URL, then it cannot be removed from the cart (I have cart on checkout page) as it simply reloads the same URL and re adds the item. Clearing the query string allows the cart to be edited, however is not a user friendly approach
Never mind, I figured it out. I set the original URL to ‘/cart/?add-to-cart=5489’ then add the following snippet
Cool
Hi,
When you click on one of the buttons you reload the checkout page and some of the fields are not kept such as order remarks.
Sam
Good point Sam, but that’s not because of my snippet. Even if you move to another URL and then go back to the checkout you will lose them. There is a way to “remember” them but this is off topic
Thanks for this, but how can I add it to the cart page instead of the checkout page? I’m trying to use it as upsell with one unique product for all the products in my store. Thank you
Hi Cristopher, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Thank you for the code! I have a question, how can I modify the code so that it only breaks (disappears) when all the products in the array ( $product_ids = array( 14877, 14879, 15493 ) ) are in the cart? As right now it breaks when any item is added to cart from the array. Thank you in advance, have a wonderful day!
Hey Loa, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Suppose I add a jQuery datepicker field here ( at “woocommerce_review_order_before_submit” hook ), it automatically reloads and jQuery datepicker stops working. Look as normal textbox field. Can you help me on this. This works on other hook position available at checkout page.
Hey Sanesh, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Neat tip Rodolfo 🙂
Just want to add for variable products, you must add the variation’s ID or the user will get error notifications. Thankfully, you already told us how to do that in you article about custom add to cart URLs: https://businessbloomer.com/woocommerce-custom-add-cart-urls-ultimate-guide/
Great, thanks Lionel!