Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taxjar charging shipping on 100% discount cart rule #26

Closed
treii28 opened this issue Jun 1, 2018 · 9 comments
Closed

Taxjar charging shipping on 100% discount cart rule #26

treii28 opened this issue Jun 1, 2018 · 9 comments

Comments

@treii28
Copy link

treii28 commented Jun 1, 2018

We want to extend a coupon to customers as part of a marketing promotion that gives them 100% off their cart for a single item. When the subtotal shows up in the cart, it shows $0 for all items and $0 for shipping but taxjar still seems to be charging tax on the fixed-rate cost of shipping. (the regular fixed rate would be $5, but the subtotal to the customer is $0. But the grand total is showing with the regional sales tax on the shipping cost. e.g. for Michigan it is $0.06 on the dollar so it will show $0.30 as the total in the cart)

@treii28
Copy link
Author

treii28 commented Jun 1, 2018

Hmm, when I was looking at those places in the code, I was going by the suggestions of your support that changing those lines (or more specifically, your support referred primarily to the Smartcalcs line 161 and 162) would change the result in the cart for the shipping. However, after I sent the suggestion I went about making the changes and deploying them here locally and it doesn't actually do anything to change the results in the cart. It still ends up with a total of $0.30 so I assume the original suggestion to change that line was flawed.
The fix does not appear to resolve the problem.

@treii28
Copy link
Author

treii28 commented Jun 1, 2018

As an aside, I also noticed that at that point in the code, the 'getGrandTotal' function is also returning the $5 shipping amount (without the discount applied) if the coupon code has been added to the cart. As in if I remove the coupon code, the getGrandTotal function will return Product cost + shipping cost + product tax + shipping tax. If I apply the product code, getGrandTotal only returns the shipping cost. So I also opened a ticket on the main magento thread as this struck me as odd. I might understand it returning shipping in both instances if tax wasn't applied since there is a getShippingDiscountAmount() method, but tax (including shipping tax) is applied if there's no coupon applied to the cart.
https://github.com/magento/magento2/issues/15673

@fastdivision
Copy link
Member

Hi @treii28, I tested this fix locally and added a couple specs to verify that discounts applied to shipping will be passed on to our API. After applying the code, can you try clearing your checkout session to verify the tax isn't cached on your end? If you're still encountering issues, can you share screenshots of your discount cart rule from admin so I can try to reproduce? Thank you!

@treii28
Copy link
Author

treii28 commented Jun 4, 2018

well not only am I still showing the tax on the last page, now if I go back a page, it gets stuck in a loop or something in the javascript trying to calculate the shipping and crashes the browser (chrome) tab. And if I open it in firefox, I get the shipping calculation repeating down the page over and over and over and over when it finally stops the code.
The only change on this system are the changes from that patch.

@treii28
Copy link
Author

treii28 commented Jun 4, 2018

hmmm, ok, I'll have to do more testing. I made the modifications in place and it was causing all those problems. So I pulled your separate branch to a different folder and copied the whole thing, re-ran setup:upgrade and setup:di:compile and I think it's working now.

@treii28
Copy link
Author

treii28 commented Jun 4, 2018

Hmmm, ok, it seems to work but still trying to nail down what all needs to be flushed to make it work. I had trouble getting it to go away this time also. I hope I don't have to clear every single customer cart to get it functioning properly.

@fastdivision
Copy link
Member

@treii28 Glad that it's working now! When caching API requests, we set taxjar_salestax_order in the customer's checkout session with the complete order details. After applying the fix, customers that already have the shipping discount applied should have a different shipping amount when making a request. We'll determine that the order details have changed and hopefully make a new request with the updated shipping amount.

If you notice any caching issues with incoming orders after deploying the fix, you could consider commenting out the orderChanged conditional temporarily until customer cookies expire after the fix goes live, depending on your configured cookie lifetime.

@treii28
Copy link
Author

treii28 commented Jun 13, 2018

I don't think it's going to be a huge problem as we have a limited number of coupons of this sort in circulation and currently that's the first coupon we've issued as it's a new site. But good to know for future reference. Is there any way of being notified when this is added to master? I get errors/warnings now due to the modified code base whenever running git on my own master. (the current taxjar I'm using is the branch and not master)

15:33:00.090: [vendor/taxjar-magento2-extension] git -c core.quotepath=false -c log.showSignature=false push --progress --porcelain origin refs/heads/develop:develop
remote: Permission to taxjar/taxjar-magento2-extension.git denied to treii28.
fatal: unable to access 'https://github.com/taxjar/taxjar-magento2-extension.git/': The requested URL returned error: 403

@fastdivision
Copy link
Member

@treii28 I'll try to get #27 merged and released by next week. Refactored some of the code today. I'll close out this issue once it's done. Thanks for your patience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants