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.
Related
I`m a beginner in Magento 2. I did setup a shopping cart app with flat rate shipping. But now client wants to add a link in cart for buying premium membership, so that this particular users can shop without shipping charges for one year. Normal users will have to pay shipping charges as usual. Any idea on how to implement this?
You can make a Customer Group.
Stores > Other Setting and select Customer Group.
Add new customer group.
Go To Cart Rule please follow.
Marketing > Select Cart Price Rule > Add New Rule. now without using coupon and select free shipping in magento for that customer group .
Thanks
Easiest thing comes to my mind is Coupon code that he'll use everytime, with 1-year validity.
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 started on magento i use to list items including VAT as i am not VAT register. but now i have automated my price and data from a data supply company. and they send prices exclude VAT so i needed a rule to add 20% VAT on top of them.
i have created a rule as told here: http://www.magentocommerce.com/knowledge-base/entry/setting-up-value-added-tax-vat
and gave it Name "Standard VAT" but the problem is my magento is using attribute for tax "Taxable" and not using "VAT Standard"
can you tell me how to make magento use this rule by default? and show the prices include VAT on front end, every where.
there is a solution to select all the item in catalog and edit attribute and select "Standard VAT" but that is not fault proof. we edit new items every day and wont find a out which product is showing VAT and which isnt.
another thing i have done is: changed the setting in "taxable" attribute. but it is still not showing VAT on front end. i have tried to give priority to "standard VAT2 but no use.
you help will be much appreciated. please tell every thing in little details.
Once you have setup your Product Tax Rules which will have all the countries and rates you want to apply assigned to your Standard VAT Product VAT class, you will then to change each product to use this tax class. Go into the product, select prices, and change the VAT class to Standard VAT. Providing your rules are all setup correctly and you have set in the system configuration that your product prices are now setup as excluding tax, then it will automatically apply your tax rules to the products on the frontend.
I am unaware of a Default System Configuration Option for product tax_class_id. Ultimately it is simply an EAV attribute like any other custom product attribute. My deployment always defaults to the first product tax class after None when setting up a new product. What you could do is go into the database manually and set the default value of the tax_class_id attribute to be the ID of the product tax class you want to default to. Something like the following would probably do it;
UPDATE `eav_attribute` SET `default_value` = '2' WHERE `eav_attribute`.`attribute_code`='tax_class_id';
I need to add custom attributes to selected products in store. To do so I'm using Model_Price_Observer. I'm using Magento 1.7.
So far I'm able to add custom attribute but calculated price is wrong - tax is missing.
My code is (part):
$quote_item->getProduct()->setIsSuperMode(true);
$quote_item->setOriginalCustomPrice( $customprice );
$quote_item->setCustomPrice( $customprice );
$quote_item->setTaxAmount($taxAmount);
$quote_item->setBaseTaxAmount($taxAmount);
Any ideas what am I doing wrong?
Am I using right trigger?
Tax cannot be added to an item as we do not yet know the customer's location in the world, and therefore cannot reasonably calculate a tax rate. I assume Magento is not saving your new tax information because of this fact. It also seems dangerous to me to add tax manually as it is always calculated on the fly via (sometimes) complex logic.
In the cart, try getting a "quick estimate" by entering in your country and postal code and see if tax is applied to the quote, and maybe try again.
I have a free shipping price rule which is configured like this:
All customer groups
No coupon
uses per customer: 0
Conditions: Cart total >= 100, Shipping country == NL or BE or DE
Free shipment: for shipment with matching items.
When I enter a coupon with a fixed discount amount however, the free shipment disappears.
Both price rules have Stop Further Rule Processing set to NO
This behaviour of Magento is driving me insane
Apparently Magento does not care about other shopping cart price rules if there is a valid coupon code entered in the Front-end.
Fix for this issue is in the comments of the following website:
http://magentoexpert.com/issue-with-cart-price-rules-coupon-code-discard-promotion-without-coupon-code/
As suggested in one of the comments it's best that you try and convert the current rule into a "Shopping Cart Price Rule".
In a Shopping Cart Price rule you can also set conditions that depend on the subtotal of the cart, the shipping region, shipping country, ...
In the action tab you can easily Free shipping option to "For shipment with matching items"
This should solve it ;)
Go through all your other rules which might be triggered as well (make sure they have "further rule processing" on "no").
Set the priority to "1"
Try again if the rule is applied and let us know.
If we are talking for Magento CE 1.9 and above, the code is corrected as long as the database is concerned but you might encounter the same problem! If so, then there is another cause.
One also usual bug is * user not being able to update the cart quantities* or users not able to login. This has to do with formKey and the answer that was given here.
Apparently, the same solution fixes the problem of vanished shipment or payment method after applying a coupon, that we are discussing here.
Hope this helps users of newer versions...
so be it - manemoi