Last active
November 5, 2016 16:54
-
-
Save MinaPansuriya/5d5c14b3eb68080f3f00d80520a625ee to your computer and use it in GitHub Desktop.
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
/** | |
* @Title: WooCommerce Charge additional amount if Cart Quantity exceed given amount | |
* @Author: Mina Pansuriya | |
* @Website: http://minapansuriya.com | |
*/ | |
add_action( 'woocommerce_cart_calculate_fees', 'pbs_woo_charge_additional_fees_for_x_no_of_products' ); | |
function pbs_woo_charge_additional_fees_for_x_no_of_products(){ | |
global $woocommerce; | |
$cart_content = $woocommerce->cart->get_cart(); | |
$qty = 0; | |
foreach($cart_content as $key => $value){ | |
$qty += $value['quantity']; | |
} | |
$extraCostQtyLimit = 10; | |
if($qty > $extraCostQtyLimit) | |
{ | |
$additionalCost = 10; | |
$woocommerce->cart->add_fee('Extra Charges (No. of Products > '.$extraCostQtyLimit.')', $additionalCost); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment