Created
June 6, 2018 04:17
-
-
Save sugi1119/348599102057578a58dcd0b6ace59954 to your computer and use it in GitHub Desktop.
WooCommerce: Add extra fee when product total exceed certain amount
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_action( 'woocommerce_cart_calculate_fees', 'loc_woo_charge_additional_fee_for_nr_of_products' ); | |
function loc_woo_charge_additional_fee_for_nr_of_products(){ | |
global $woocommerce; | |
$cart_content = $woocommerce->cart->get_cart(); | |
$qty = 0; | |
foreach($cart_content as $key => $value){ | |
$qty += $value['quantity']; | |
} | |
$extraCostQtyLimit = 500; | |
if($qty > $extraCostQtyLimit) | |
{ | |
$additionalCost = 100; | |
$woocommerce->cart->add_fee('YOUR TEXT HERE '.$extraCostQtyLimit.' YOUR TEXT HERE', $additionalCost); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment