[ad_1]
Hi, you can modify and use the code snippet below in your theme functions.php file to add a fixed fee if the cart contains a deposit.
add_action( 'woocommerce_cart_calculate_fees', 'acowebs_add_deposit_fee', 20, 1 );
function acowebs_add_deposit_fee( $cart ) {
if ( is_admin() && ! defined( ‘DOING_AJAX’ ) ) return;
$flag = 0;
if ($cart) {
foreach ($cart->get_cart_contents() as $cart_item_key => $cart_item) {
if( isset($cart_item[‘awcdp_deposit’]) ){
$flag = 1;
}
}
}
if( $flag == 1 ) {
$total_fee = 50; // fee
$cart->add_fee( ‘Deposit Charge’, $total_fee ); // fee label
}
}
Hope you can change the additional fee and its label on your end. Please check and let us know your feedback.
Thanks pal it works as expected 🙂
