• Resolved wowsathish

    (@wowsathish)


    Need to add extra fixed amout when customer selects to pay partial amount, as for COD our delivery partner charges extra amount, is this doable? Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Sanesh Acowebs

    (@saneshacodez)

    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.

    Thread Starter wowsathish

    (@wowsathish)

    Thanks pal it works as expected ??

    Thread Starter wowsathish

    (@wowsathish)

    Issue solved

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Need to add extra fixed amout’ is closed to new replies.