Need to add extra fixed amout

[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 🙂

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer