discount

Add a discount programmatically to an Order in Woocommerce 3.2+

女生的网名这么多〃 提交于 2019-12-01 00:48:27
In woocommerce, we can add a discount to any order using Coupons feature (fixed amount, percent amount…). Is it possible to add discount amount to any order programmatically where the discount amount can be any amount? Any help will be appreciated. The only available feature to make a discount programmatically for an Order , is tricking the Fee API . For info, this trick is not recommended by woocommerce, but used by many people as there is not a discount feature in Woocommerce outside Coupons. The following function will allow you to make a fixed discount of any amount or a percentage

Add a discount programmatically to an Order in Woocommerce 3.2+

独自空忆成欢 提交于 2019-11-30 19:34:10
问题 In woocommerce, we can add a discount to any order using Coupons feature (fixed amount, percent amount…). Is it possible to add discount amount to any order programmatically where the discount amount can be any amount? Any help will be appreciated. 回答1: The only available feature to make a discount programmatically for an Order , is tricking the Fee API . For info, this trick is not recommended by woocommerce, but used by many people as there is not a discount feature in Woocommerce outside

Cart item quantity progressive percentage discount in Woocommerce 3

拟墨画扇 提交于 2019-11-29 17:36:22
I am trying to apply a TOTAL CART discount to all the items in the cart, depending on the quantity of items added. I have taken and modified the code example from answer here and got most of the logic working. I cannot however get it working for two scenarios described below. It also only applies the rule to a single item in the cart. Not the entire cart. Scenario: If no of items in the cart are between 9-12, Apply 5% Discount to all items. If no of items in the cart are between 13-16, Apply 10% Discount to all items. The discount's should not stack. e.g. when 12 items in cart, apply 5%

Cart item discount based on quantity in Woocommerce 3

谁说我不能喝 提交于 2019-11-29 16:39:07
My WP site sells customized t-shirts. The customization plugin makes each customized shirt a line item in the woocommerce cart. If there are 2 shirts ordered of one design (quantity of 2 on that line item) I want to discount. But if there is just 1 item per line I dont want to discount. I found this solution Adding a discount by cart items conditionally based on the item quantity But this seems to change the product price in the db, so after the discount kicks in for say 2 blue shirts because there were 2 ordered on 1 line, if I add a 3rd shirt on a separate line it also gets the discount,

How can get Final Price, with applied price rule in Magento

我与影子孤独终老i 提交于 2019-11-29 13:55:58
问题 For example $_producte = Mage::getModel('catalog/product')->load(2974); echo $_producte->getFinalPrice(); I can get in frontend when insert to .phtml BUT I can not get final price (with discount) in admin section or in custom product export file. 回答1: Price calculation in Magento is a hot mess. You need to load the frontend event area in order to trigger rule calculation (ref Mage_CatalogRule_Model_Observer::processFrontFinalPrice() configured in Mage_CatalogRule config.xml ). Mage::app()-

Cart discount based on cart item count and only for items that are not in sale

柔情痞子 提交于 2019-11-29 11:03:44
In WooCommerce, I would like to give a discount of 10% specifically for those products that are not on sale. If cart item count is 5 or more items and not on sale, then I give a discount of 10%. I use the following code to get a discount based on cart item count restriction here: add_action('woocommerce_cart_calculate_fees' , 'add_custom_fees'); /** * Add custom fee if more than three article * @param WC_Cart $cart */ function add_custom_fees( WC_Cart $cart ){ if( $cart->cart_contents_count < 5 ){ return; } // Calculate the amount to reduce $discount = $cart->subtotal * 0.1; $cart->add_fee(

Apply a discount on the cart content total excluding taxes in WooCommerce

一世执手 提交于 2019-11-29 08:40:46
I need to apply a discount to the cart subtotal before tax is calculated if a user is ordering for the first time. However, tax is calculated per-item in WooCommerce and added to the subtotal afterwards. So I need to apply the discount to the items in the cart before WooCommerce calculates the tax on them. This way the tax is based off of the discounted prices rather than the original prices. Here is what I have: function first_order_add_five_percent_discount($cart_object) { if ( is_user_logged_in() ) { //current user id $currentUser_id = get_current_user_id(); //amount of orders by current

Progressive discount based on cart total in WooCommerce

限于喜欢 提交于 2019-11-29 05:22:10
I'm trying to automatically apply 3 different coupon codes in WooCommerce Cart. Here's my code ! add_action( 'woocommerce_before_cart', 'apply_matched_coupons' ); function apply_matched_coupons() { global $woocommerce; $coupon_code5 = '5percent'; $coupon_code10 = '10percent'; $coupon_code55 = '15percent'; if ( $woocommerce->cart->has_discount( $coupon_code ) ) return; if ( $woocommerce->cart->cart_contents_total >= 50 && $woocommerce->cart->cart_contents_total < 100 && $woocommerce->cart->cart_contents_total != 100 ) { $woocommerce->cart->add_discount( $coupon_code5 ); } elseif ($woocommerce-

Discount for Certain Category Based on Total Number of Products

╄→尐↘猪︶ㄣ 提交于 2019-11-28 13:06:17
In WooCommerce, I have a category of products called Samples, each sample costs $2.99. But I'd like a way to automatically change the cost of the Samples from $2.99 to $1 when 5 Samples are added to cart. So if 4 samples are added to cart, the total would be $11.96… but if 5 were added the total would be $5. So for every 5 products, the product price would change from $2.99 to $1 but if 6 Samples were added to cart the total would be $7.99 and if 10 were added the total would be $10 etc... How could I achieve this? Thanks. Update — Added Woocommerce 3 compatibility. Here is something that

Conditional progressive percentage discount based on cart item count in Woocommerce

£可爱£侵袭症+ 提交于 2019-11-28 12:46:59
I would like to have a conditional progressive discount based on number of items in cart. After you added 2 products to the cart, you get a discount. More products you add and more discount you get. For example: 1 product – full price (No Discount) 2 products – full price with 5% discount of the combined price 3 products – full price with 10% discount of the combined price 4 products – full price with 15% discount of the combined price And so on … I have search over internet without any success. When searching about discounts I just fall on WooCommerce coupon feature or I get some old wrong