Jump to content

martini0

Members
  • Posts

    26
  • Joined

  • Last visited

Everything posted by martini0

  1. The following code is removing 'flat_rate:13' and 'flat_rate:15' but for BOTH wholesale customers as for guests. But it should only remove for wholesale customers. Now, guests are seeing the wrong shipment costs: 'flat_rate:10' and 'flat_rate:7' What is wrong? As I am loosing my mind because so.. add_filter( 'woocommerce_package_rates', 'shipping_methods_based_on_wholesale_customer', 10, 2 ); function shipping_methods_based_on_wholesale_customer( $rates, $package ){ $is_wholesale = get_user_meta( get_current_user_id(), 'wholesale_customer', true ); // Set the shipping methods rate ids in the arrays: if( $is_wholesale ) { $shipping_rates_ids = array('flat_rate:10', 'flat_rate:7'); // To be removed for NON Wholesale users } else { $shipping_rates_ids = array('flat_rate:13', 'flat_rate:15'); // To be removed for Wholesale users } // Loop through shipping rates from the current shipping package foreach( $rates as $rate_key => $rate ) { if ( in_array( $rate_key, $shipping_rates_ids) ) { unset( $rates[$rate_key] ); } } return $rates; }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.