Terrance Philip
Terrance Philip

Reputation: 1

Hide shipping cost in checkout page

I i have three shipping methods in my checkout page as follows.

  1. shipping by us = table rate
  2. Shipping by customer = Free shipping
  3. Local Pickup

what is want is fi customer select freeshipping or local pickup table rate cost need to invisible. when they select table rate again it should show the cost again. I used below code

function Ws_lk_hide_shipping ( $rates, $package ) {      
// Only unset rates if free_shipping is available
if ( isset( $rates['free_shipping:12'] ) ) {
        unset( $rates['table_rate:5'] );
}     return $rates;}```


but above code hide the entire table rate line. so can not select it again.  

Upvotes: 0

Views: 64

Answers (1)

Naga Giridhar
Naga Giridhar

Reputation: 11

Instead of unsetting the $rates['table_rate:5'], try setting it to 0.00 or "Free Shipping", if it accepts string value, like below.

function Ws_lk_hide_shipping ( $rates, $package ) {      
   // Only unset rates if free_shipping is available
   if ( isset( $rates['free_shipping:12'] ) ) {
        $rates['table_rate:5'] = 0.00;
   }     
   return $rates;
}

I'm having trouble understanding the actual issue, try above method if that solves the issue.

Upvotes: 0

Related Questions