Created
August 30, 2017 06:31
-
-
Save gedex/0e444c1026604416ba8cad8ebaf4be6e to your computer and use it in GitHub Desktop.
Override rule cost for distance shipping when destination within 5miles of shop AND order total over $100
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'woocommerce_distance_rate_shipping_rule_cost_distance_shipping', function( $rule_cost, $rule, $distance, $package ) { | |
$order_total = $package['contents_cost']; | |
if ( $order_total > 100 && $distance <= 5 ) { | |
$rule_cost = 0; | |
} | |
return $rule_cost; | |
}, 10, 4 ); |
Hello. I'm interested in purchasing the WooCommerce Distance Rate Shipping plugin. I have a condition to make, would it be possible using to have this scenario: Delivery from restaurant: 1-3 miles & 20 pounds or above in basket = free delivery 1-3 miles & less than 20 pounds = 2.50 for delivery 1-3 miles & less than 12 pounds = no delivery
3.1-4.0 & 20 pounds or above in the basket = 1 pound delivery 3.1-4.0 & less than 20 pounds = 3.50 for delivery 3.1-4.0 & less than 12 pounds = no delivery
Is this doable in this plugin? If there needs to be a custom code, would you provide an example here? Thank you
Is it possible?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome! With this example, I was able to figure out distance and weight conditions using the cart contents weight variable. I needed to do multiple zones with dual rates based upon weight and this seems to work well. Oh, it seems that only one shipping zone (All Zones) is needed, even for multiple zones (custom code does the multiple zones work). I then added Distance Rate as a shipping method within it (you can limit zip codes here as well). Within the Distance Rate shipping method, I added a single distance rule with default values (I guess it just needs to be there for this custom code to work). I also added my shop address here.