New Landing How can we help? Atelier Types of Shipping

Viewing 2 posts - 1 through 2 (of 2 total)
  • Posted in: Atelier
  • #225211
    malasuer
    Member
    Post count: 15

    Hi!

    i tried to filterer the kind of shipping with this code but it´s not working. I just want to show one type of shipping when the user send his product to Ceuta,Melilla, Baleares or Canarias. It should be show “flat_rate” when the subtotal is more than 30 euros. And in the other case, should be show “local_delivery” when the subtotal is less than 30 euros. But with this code in the functions.php of my child theme, it´s not working… ¿What´s the problem? Thanks!

    add_filter( ‘woocommerce_package_rates’, ‘ocultar_otros_envios’, 10, 2 );

    // Hide other shippings
    function ocultar_otros_envios( $rates, $package ) {
    $subtotal=substr(wc_cart_totals_subtotal_html(), 0,-1);
    $sub=doubleval($subtotal);
    $free=30;

    if($subtotal < $free){
    if ( isset( $rates[‘local_delivery’] ) ){
    unset( $rates[‘flat_rate’] );
    $local_delivery = $rates[‘local_delivery’];
    $rates = array();
    $rates[‘local_delivery’] = $local_delivery;

    return $rates;
    }
    }else{
    unset( $rates[‘local_delivery’] );
    $flat_rate = $rates[‘flat_rate’];
    $rates = array();
    $rates[‘flat_rate’] = $flat_rate;

    return $rates;

    }
    return $rates;
    }

    #225309
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Hi

    This is not a theme related question so please contact woocommerce support

    – Kyle

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register