Knowledge Base

Hi, How can we help?

Show woocommerce deposits option based on cart amount

This document explains how you can show deposits based on the cart amount at the checkout page. For example, if you want to show the woocommerce deposits only if your cart amount is reached a certain amount, then you can use a code to perform the same. For this, first, you need to enable deposit on the checkout page.
Go to Dashboard-> Deposits-> General Settings.

Then add the following code to your theme/child-theme functions.php file.

function example_callback() {
   $cart_total = WC()->cart->total; // cart total
   $cart_subtotal = WC()->cart->subtotal; // cart subtotal

   if( $cart_subtotal > 1000 ) {
      return true;
   }
   
   return false;
}

add_filter( 'awcd_disable_deposit_custom_rule', 'example_callback' );
add_filter( 'awcd_disable_deposit_review_order_after_order_total', 'example_callback' );
add_filter( 'awcd_disable_deposit_checkout_update_order_meta', 'example_callback' );

This sample code will display deposit selection only if the cart subtotal is greater than 1000. For this, we have taken the cart subtotal value and checked the condition. This will show/hide the deposit option at the checkout page based on the cart value. You can use or modify the above code snippet with other cart parameters also.

Below is an example of the execution of the above code. First, add products to the cart with a total amount greater than 1000. Then you can see deposit selection on the checkout page as below.

If your cart amount is less than 1000 then the deposit selection area will disappear.

Customer Support

If you have questions about our plugin(s), are experiencing issues with any of our plugin