Force local pickup
-
I’m creating an online shop for a friend of mine with the woocommerce-plugin. I would like to offer two different shipping methods to the customers. One the one hand a weight based shipping-option (I was able to do that with a plugin) and on the other hand the option to pick up products. But the pickup-option should only be available if there’s a product in the cart that has the “pickup-only” shipping-class.
Do you know how I could do that?
I’ve found the following code on github:
function hideShippingWhenPickupRequired($rates, $package) { foreach ($package['contents'] as $item) { $product = $item['data']; $shippingClass = $product->get_shipping_class(); if ('pickup-only' === $shippingClass) { // The cart requires pickup return array( 'local_pickup' => $rates['local_pickup'], ); } } return $rates; } add_filter('woocommerce_package_rates', 'hideShippingWhenPickupRequired', 10, 2);But it’s not working and even if it would, the pickup-option would still be available if there’s no product in the cart with the pickup-only-class.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Force local pickup’ is closed to new replies.