Last active
June 7, 2016 12:22
-
-
Save WooForce/fcfbc8b0f80baad3ab10387134080d04 to your computer and use it in GitHub Desktop.
Price adjustment if the cart total exceed given value.
This file contains hidden or 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
add_filter( 'woocommerce_package_rates', 'wf_rate_adjustment_if_cart_total_exceed', 10, 2 ); | |
function wf_rate_adjustment_if_cart_total_exceed( $available_shipping_methods, $package ) { | |
$minimum_cart_price_to_adjust = 30; //give value here | |
$shipping_services_with_price = array( | |
'wf_shipping_ups:01' => 0, //give shipping service with adjustment price in percent. | |
'wf_shipping_ups:02' => 0 | |
); | |
$cart_total = WC()->cart->cart_contents_total; | |
if( $cart_total > $minimum_cart_price_to_adjust ){ | |
foreach ($available_shipping_methods as $key => $value) { | |
if( array_key_exists( $key, $shipping_services_with_price ) ){ | |
$available_shipping_methods[$key]->cost *= $shipping_services_with_price[$key] ; | |
} | |
} | |
} | |
return $available_shipping_methods; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment