0

I am trying to figer out a logic to set the shipping cost to 0 when switching payment method in customer account under woocommerce subscription where URL contain this value

&kco-action=change-subs-payment

This code is duplicate of code founded here link to code

 add_action('woocommerce_cart_calculate_fees','custom_handling_fee',10,1);
 function custom_handling_fee($cart){
 if(!is_admin() && ! defined('DOING_AJAX') && get_query_var('cat'))
    return;
 if('cod' === WC()->session->get('chosen_payment_method')){
    $extra_cost = 0.00;
    $cart_total = $cart->cart_contents_total; 
    $fee = $cart_total * $extra_cost;
    if($fee != 0)
    $cart->add_fee('COD Charge',$fee,true);
  }
 }

As soon it detects specific var in url it set the shipping cost to 0. Right now issue i am facing is when customer switch payment method for woocommerce subscription, he gets the shipping cost to pay before successfully changing payment method.

Mr.Devops
  • 178
  • 1
  • 10

0 Answers0