When we sell tickets with WooCommerce, we've added a handling fee per ticket. The fee part is working fine, using the
WC()->cart->add_fee().
However, if we apply a coupon, the amount it substracts does not take into account the fees.
So, the customer would still need to pay the fee. We'd like for the coupon to also apply for the fees.
Not knowing php that well, I have tried finding the function for coupons and the cart, interpreting them, but unfortunately it didn't help me much in understanding what I could change to make coupons apply to the cart total amount.
Related
We run a webshop and orders over $35,- get free shipping. Working as it should.
We also have 20% discount coupons. Also working as it should.
Now a client emailed us with the following:
She has for $40,- of items in her shopping bag and also a 20% discount code.
Before she applied the discount code free shipping is active. But after adding the discount code the total order value is les then $35,- (it is $32,-) and the Free Shipping is gone and she has to pay the Shipping costs.
Totaly makes sense but is there a way to avoid this? So the discount is not part when calculating the total cart value so she still has Free Shipping?
I have a little problem. A client of ours setup a WooCommerce shop himself and forgot to add taxes. Since he was in over his head he decided to get help setting it all up.
Now unfortunately this shop is already live and has about 50 completed orders in it. I setup the taxes etc. correctly for him but this will work only for new orders, not the old ones.
Does anybody know a simple way of adding the taxes to the old orders (all prices are including tax), maybe a loop or something I can run over the orders to get the taxes calculated?
I tried something really simple, just constructing the order and calling calculate_taxes() but this will only add a tax of 0,00€ to the order, so I guess I'm missing something important here:
$order = new WC_Order(1234);
$order->calculate_taxes();
Thank you for your help
What I did was:
1. update the product to pending payment.
2. recalculate the tax, change status to complete again, and set order action to send invoice to customer
that's it.
Alright, I dove really deep into the the mechanics behind this, so I think I can answer this myself, but be warned, it's more complicated then it seems.
There are some important things about how WooCommerce handles orders before though:
Shipping costs have to entered without taxes
Prices are stored without taxes in an order, even when you added them including taxes to the product
So when you add taxes after there are completed orders, that leaves you with the following problems:
The prices need to be changed in the old orders
The shippings costs need to be chached in the old orders
In more technical words, you would have to loop through all orders, loop through the items in the order, update prices, add the tax, update the shipping costs and only then can you run "calculate_taxes()" as I did in my really simple example.
I can't provide you with a finished function that does all this (yet) since I first have to clarify if the client is willing to pay for this. I'll add the function if he does. If anybody stumbles upon this and writes this function fell free to post is as an answer, I'll accept it as correct.
When I apply a coupon at cart having a recurring product, it applies the Coupon but calculates wrong and displays wrong amount.
But it is working fine with normal products(other than recurring Products).
Can anyone ever worked with Coupons and Recurring Products?
A project I’m working on allows customers to buy products that have the ability to be VAT exempt (through disability/chronic sickness). I have added an additional step to the checkout process so the customer can easily fill in the VAT exempt form. Once that form has been filled in I need to remove tax from their quote/order.
I have done a fair bit of digging into how I could potentially do this. Below is the code I got so far, however it works but the moment I go through to our payment provider the tax has been reset. Even when I use Check / Money Order payment option.
file: app/code/local/Vat/Exempt/controllers/OnepageController.php (method: saveExemptAction())
$quote = $this->getOnepage()->getQuote();
$quote->setCustomerTaxClassId(6); // Tried forcing a custom tax class id
$quote->setCustomerGroupId(4); //also tried forcing a different customer group...
foreach($quote->getAllItems() as $item){
// Attempt to zero the tax on each item
$item->setTaxAmount(0);
$item->setBaseTaxAmount(0);
//re-calculate & save each item.
$item->calcTaxAmount();
$item->save();
}
$quote->collectTotals()->save();
Any advice would be much appreciated!
The easiest way would be to change the customer's group to a group that doesn't pay VAT (you can define that in Sales > Tax > Manage Tax Rules).
After they fill up the form you change their group ($customer->setGroup(self::GROUP_EXEMPT_VAT)->save();) and from this moment they won't pay tax.
Let me know if that would work for your issue and if you need more help.
I have a Magento shop and we use Barclaycard ePDQ as our payment method. I recently created a new cart rule that gives you 10% off discount when using a coupon code. Everything goes well with Magento - the coupon applies - but after I press Checkout and it takes me to the Barclaycard ePDQ page, I notice that the total amount to pay is actually the regular price + the discount amount, which is really weird because when I look at my order reports it seems that the grand total is with the discount.
I saw this problem in an earlier version of Magento with regards to Paypal. The issue was that the processor was expecting a negative value (-5.00) and Magento was passing a positive one (5.00) or vice versa. I'd check the redirect page from Magento and see if the discount is applied with the opposite sign.