WooCommerce Fixed Coupon Price - php

I am using WooCommerce, and how create two fixed price for one product ?
standard price product
coupon using fixed price
If user enter coupon code, will show coupon fixed price, else standard price.

When you use coupons in woocommerce you can set if you want to deduct a percentual or a fixed amount. You can also limit to certain products only.
So you could basically assign a coupon to the one product with a fixed discount value.

i've found this plugin while browsing around.. maybe it could help to get the job done
(I'm not affiliated to that company/developer)
http://sarkware.com/woocommerce-change-product-price-dynamically-while-adding-to-cart-without-using-plugins/#override-price-wc-fields-factory

Related

WooCommerce coupons - how to apply percentage coupon THEN store credit

Currently, using the WooCommerce Smart Coupons plugin, when combining two different coupons, a store credit is used first and then a percentage is used on the total after the first coupon is used.
This is illogical when you give someone store credit and they want to take that amount off of the cart total AFTER using the full % off. I'd like for this to work the opposite - use the percentage off coupon, then the store credit.
To be clear: The way it works now is...
Cart subtotal = $100
$10 Store credit coupon = -$10
10% off coupon = -$9
Cart total = $81
The way it SHOULD work is...
Cart subtotal = $100
$10 Store credit coupon = -$10
10% off coupon = -$10
Cart total = $80
Does anyone else have this issue? If so, how can it be fixed? Thanks!
EDIT 1: I've narrowed down this issue to being with the Smart Coupons plugin after disabling it and the calculations working as they should once disabled.
The solution for me was to UNCHECK a line item in the Woocommerce settings under the "General" tab and "Enable Coupons" section that says "Calculate coupon discounts sequentially"

WooCommerce change tax per product programmatically

The problem is: If we sell a ticket to our customer, we pay the tax not where the customer lives and not where the company of the shop is located. We pay the tax, where the event is held.
We can use a workaround where we can define a tax class for each country, with the rate. But this is very ugly.
I would like to develope something where I can set the country for the events and WooCommerce will use this country as a tax base, just for this product.
My problem is, that I don't know which filter I should apply. I found some, but the filter don't give the product object or the product id as parameter.
For example: https://docs.woocommerce.com/wc-apidocs/source-class-WC_Checkout.html#468
Does someone have an idea?
thanks for getting back to me. That's the "hack" I implemented but it solved for me
I used the filter woocommerce_price_ex_tax_amount (there is also, woocommerce_price_inc_tax_amount) for inclusive tax calculation.
It receives $tax_amount (already calculated), $key, $rate, $price.
You can setup a fictitious tax rate for every ticket and modify it programatically. As you'll receive the price as well, you can recalculate the rate base on it and return it.
Hope it helps,

How to set custom price for a product in Magento for only the first of that product added to the cart?

I trying to allow users to get the first product sample they add to their cart for free, but any samples they add after (including the one they already added) should be normal price. Right now I using setOriginalCustomPrice in a module, but the customer can change the quantity, and the price stays at zero instead of going up. Anyone know how to go about this?
You can achieve this by a simple calculation where you are using setOriginalCustomPrice.Currently I think you are setting price 0.Instead of doing this,use following logic to set custom price.
$customPrice=$qtyincart*$productPrice-$productPrice.
So if user add 1 qty then $customPrice will be 0 else will equal to sum of qty-1.
I hope this solve your purpose.

magento customize quote collectTotals to show the updated totals

hey i'm implementing a custom discount system since magento discount system does not feet my requirements so i'm trying to apply a discount on an Mage_Sales_Model_Quote_Item I've read some and I've found the following function setOriginalCustomPrice the thing is that it applies on the item, and if the user changes the quantity he will get the discount on the item with the new quantity, so i'm trying to use a different method addOption on the item and only on the cart page show the calculations based on the quantity in the option value
$item->addOption(array('code'=>'promo','value' => serialize(['amount'=>10,'qty'=>1])));
and in the cart page
$promo = $item->getOptionByCode('promo');
echo '<div class="orig-price">'.$item->getOriginalPrice().'</div>';
echo '<div class="new-price">'.$item->getOriginalPrice() - ($promo['amount'] * $promo['qty']).'</div>';
the problem is that it does'nt actually apply the new price on the product,
so i want to customize Mage_Sales_Model_Quote->collectTotals() to show my discounts
and send it to the admin back-end when order is completed
how can i achieve that?
thanks in advance
I think there is a fundamental flaw in your approach. I'm not sure what you don't like in standard discounts, and what you can't achieve with catalog or shopping cart rules, but what you're trying to do definitely breaks these features (along with my heart).
However, if you're sure about what you're trying to do, then don't customize Mage_Sales_Model_Quote->collectTotals().
This function just... well, it collects all totals: subtotal, shipping, discount, etc. And it looks like you're changing only price output, but Magento itself doesn't know anything about it.
So if you want to let Magento know that you're changing the item price, you have to either add your own total, or change one of the existing totals. After that Magento will do everything else. Since after your changes Magento outputs already calculated price instead of original one, it may be strange for customer to see the original price in the cart and the additional discount total. So it looks like you will have to change subtotal total.
To do that you have to rewrite Mage_Sales_Model_Quote_Address_Total_Subtotal class in your extension and insert your calculation in _initItem() method. Around line 111 in the original file you will see the code:
$item->setPrice($finalPrice)
->setBaseOriginalPrice($finalPrice);
And this is where Magento sets price for the item, so you can insert your calculations and change $finalPrice before that. If you have virtual products, you will have to change collect() method too.

Programmatically add product to Virtuemart?

For a customer I am building a Virtuemart 2.0.26d website.
Because of a local law, for each unit of a product that is ordered a fee must be added.
So, when ordering 4 products, the fee must be charged 4 times. By law it is required that the total sum of this fee is visible on the invoice/order confirmation.
I looked at the price rules in Virtuemart, but they don't seem to have an option for this. There is a price modifier after tax, but then the fee is visibile as an negative discount. Something I don't want.
The only solution I came up with is to make a new product for the fee and programmatically add this product for each unit. Can this be done by making a Virtuemart Plugin, or must I change the core for this?
Or are there better solutions for this problem?
You can add extra charge by Taxes & Calculation Rules.
create new rules and select tax per product for Type of Arithmetic Operation and select Math Operation + Or +% as per you want to add extra fee per product.
You could add a custom field to each product with the fee amount and alter the code of the payment plugin to add this fee to your order.

Categories