If the client wants to Changing Cart Page Prices price based on a number of quantity added to cart for specific products, then as a developer we must ignore the use of the plugin. We must do necessary changes as per hooks and filters of the WooCommerce.
Rather than using a plugin, try to use the code snippet which will help in site speed and code security.
To apply such logic in WooCommerce is possible using hooks and the hook related to this snippet is “woocommerce_before_calculate_totals“
Let’s take an example:
The default price of the product is 50 USD
The client want vary the price of the product if there are 50 quantity for the same product. i.e client wants to add a discount for the product if the quantity is 50.
add_action( 'woocommerce_before_calculate_totals', 'geeker_quantity_based_product_price_callback', 9999 );
function geeker_quantity_based_product_price_callback( $cart ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return;
if ( did_action( 'woocommerce_before_calculate_totals' ) >= 2 ) return;
// Define discount rules and thresholds
$quantiyincart1 = 101; // Change price if items > 100
$discount1 = 50; // Reduce unit price by 50%
$quantiyincart2 = 1001; // Change price if items > 1000
$discount2 = 0.1; // Reduce unit price by 10%
foreach ( $cart->get_cart() as $cart_item_key => $cart_item ) {
$product_id = $cart_item['product_id'];
if ( $cart_item['quantity'] >= $quantiyincart1 && $cart_item['quantity'] < $quantiyincart2 ) {
$price = round( $cart_item['data']->get_price() * ( 1 - $discount1 ), 2 );
$cart_item['data']->set_price( $price );
} elseif ( $cart_item['quantity'] >= $quantiyincart2 ) {
$price = round( $cart_item['data']->get_price() * ( 1 - $discount2 ), 2 );
$cart_item['data']->set_price( $price );
}
}
}
order generic lipitor atorvastatin 20mg drug order atorvastatin 80mg online cheap
buy generic ciprofloxacin 1000mg – buy septra sale augmentin 1000mg usa
buy cipro pills – order myambutol 600mg pills buy clavulanate pills
metronidazole 200mg pills – terramycin 250 mg usa purchase azithromycin pills
order ciplox 500 mg without prescription – chloromycetin for sale online erythromycin 250mg without prescription
ivermectin 6 mg stromectol – buy generic ciplox cost tetracycline 250mg
buy generic valtrex for sale – buy generic acyclovir 400mg zovirax 800mg over the counter
buy flagyl online – cheap zithromax 250mg zithromax 250mg for sale
buy acillin without prescription order monodox online cheap cheap amoxicillin generic
order furosemide 40mg online – buy generic candesartan 8mg capoten 25 mg price
order metformin 1000mg generic – buy duricef 250mg pill buy generic lincocin
how to get cheap retrovir without a prescription – buy glucophage without a prescription buy zyloprim 300mg pill
MyCellSpy is a powerful app for remote real – Time monitoring of Android phones.
purchase clozapine without prescription – purchase frumil buy pepcid online
Mobile Phone Monitoring App – hidden tracking app that secretly records location, SMS, call audio, WhatsApp, Facebook, Viber, camera, internet activity. Monitor everything that happens in mobile phone, and track phone anytime, anywhere.
seroquel brand – buy generic eskalith over the counter order eskalith online cheap
This can be annoying when your relationships are disrupted and her phone cannot be tracked. Now you can easily perform this activity with the help of a spy app. These monitoring applications are very effective and reliable and can determine whether your wife is cheating you.
order clomipramine 25mg sale – buy paroxetine 20mg generic buy generic doxepin 25mg
order hydroxyzine generic – buspirone over the counter endep 10mg over the counter
How to track the location of the other person’s phone without their knowledge? You will be able to track and monitor text messages, phone calls, location history and much more. Free Remote Tracking and Recording of Husband’s Phone Cell Phone Spy. Best Apps to Download for Free to Spy on Another Phone.
amoxiclav sale – order baycip generic cipro canada
amoxil pills – buy erythromycin cheap order cipro 1000mg without prescription
azithromycin sale – tindamax ca buy ciplox 500mg
order cleocin for sale – where to buy cleocin without a prescription order chloramphenicol pill
ivermectin 6mg pills for humans – order cefaclor online buy cefaclor 250mg capsules
purchase ventolin inhalator – buy theophylline 400mg order theo-24 Cr online
order depo-medrol pill – buy azelastine sprayer purchase astelin online
buy clarinex 5mg online cheap – beclamethasone buy online ventolin 4mg uk
buy glyburide generic – buy glipizide paypal order dapagliflozin generic
[url=https://drugstorepp.online/]buying from canadian pharmacies[/url]
brand glycomet – generic losartan 25mg buy precose 25mg pills
pill repaglinide – how to buy empagliflozin jardiance for sale
[url=http://lisinoprilos.online/]zestril 40 mg tablet[/url]
famciclovir 250mg price – zovirax 800mg pill buy cheap generic valaciclovir
cost digoxin 250mg – verapamil 240mg over the counter generic furosemide 100mg
Do you have a spam issue on this blog; I also am a blogger, and I was wondering your situation; many of us have created some nice procedures and we are looking to trade techniques with others, be sure to shoot me an e-mail if interested.