1. Home
  2. Knowledge Base
  3. WooCommerce Wholesale Prices Premium
  4. Shipping
  5. Override Wholesale Only Shipping Setting For Certain Shipping Methods

Override Wholesale Only Shipping Setting For Certain Shipping Methods

In WooCommerce 2.6.0 shipping zones were introduced which prompted us to release a new version of WooCommerce Wholesale Prices Premium with enhanced shipping mapping controls.

One of those enhancements is to do with a setting called Wholesale Only Shipping Methods which hides all mapped shipping methods from non-wholesale customers.

This is an important feature to allow admins to hide shipping methods that are exclusively for wholesale customer use. A common example of this might be Local Pickup which might only be offered to wholesale customers.

As of 1.9.5, for advanced users, we have also added a new filter which lets you selectively choose to override this setting and expose certain shipping methods to non-wholesale customers.

The idea here is that you enable the setting because that is the default behaviour, but there might be certain shipping methods that you actually do want to expose to customers.

You can use this filter to achieve that by putting the following code into your functions.php file in your theme.

To make all non-zoned shipping methods available:


// Allow all non-zoned shipping methods to be available to regular users
function allowMappedNonZonedMethodsForRegularUsers( $allow, $shipping_method ) {

if ( ! $shipping_method->supports( 'shipping-zones' ) )
$allow = true;

return $allow;

}

add_filter( 'wwpp_force_allow_mapped_shipping_method_for_non_wholesale' , 'allowMappedNonZonedMethodsForRegularUsers', 10, 2 );

Or for a specific non-zoned shipping method:


// Allow non-zoned shipping method "Advanced Free Shipping" only to be available to regular users
function allowAdvancedFreeShippingForNonWholesale( $allow, $shipping_method ) {

if ( ! $shipping_method->supports( 'shipping-zones' ) && $shipping_method->id == 'advanced_free_shipping' )
$allow = true;

return $allow;

}

add_filter( 'wwpp_force_allow_mapped_shipping_method_for_non_wholesale' , 'allowAdvancedFreeShippingForNonWholesale', 10, 2 );

Need to allow a different shipping method other than Advanced Free Shipping?

Just use the ID key of your shipping method, eg. UPS shipping method is ‘ups’, USPS is ‘usps’ and so on.

Contact your developer to find out what the ID of the shipping method is you need.

Was this article helpful?

Related Articles

Need Support?

Can't find the answer you're looking for?
Contact Support