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

Execute the total model 'shipping' after 'tax_subtotal' #1104

Conversation

hannes011
Copy link

@hannes011 hannes011 commented Jul 9, 2020

This pull request solves the problem I've mentioned earlier in #80 :

Description (*)

This is a major change which is causing troubles for the calculation of shipping rate! Is "shipping" really needed as prerequisite for subtotal?
A: shipping is not included within subtotal
B: some shipping methods calculate there rate based on subtotal

This change led to strange behavior: once the totals are already calculated and stored/cached then the subtotal doesn't include tax anymore (as expected) BUT when totals will be collected first time the "shipping" total is executed before "tax_subtotal", so the subtotal still contains tax, which leads to inconsistency...

Fixed Issues (if relevant)

  1. Fixes Twice tax in Grand Total #80

Manual testing scenarios (*)

This issue applies only to external shipping modules like matrixrates from webshopapps (I haven't tested it but it might apply to tablerates from Magento core, too)

  1. configure two shipping rates for a certain threshold (e.g. rate A for subtotal < 10 EUR and rate B for subtotal > 10 EUR)
  2. add a product to cart (with tax 11 EUR, and without tax 9.24 EUR)
  3. in step "shipping method" I can choose rate A since subtotal is expected to be without tax
  4. in final step I click "place order" and get an error message "Please select a shipping method"
  5. I go back to step shipping method and now I get rate B

This different behavior depends on whether totals are already calculated and cached (then subtotal does not contain tax anymore because subtotal_tax is already collected) or not (then the total model "shipping" is executed before "subtotal_tax")!

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All automated tests passed successfully (all builds are green)

…ive sipping rate calculation the opportunity to rely on a valid subtotal
@hannes011 hannes011 changed the title Execute the total model 'shipping' after 'tax_subtotal' in order to g… Execute the total model 'shipping' after 'tax_subtotal' Jul 9, 2020
@github-actions github-actions bot added the Component: Tax Relates to Mage_Tax label Jul 24, 2020
@sreichel sreichel assigned sreichel and unassigned sreichel Jul 26, 2020
@ADDISON74
Copy link
Contributor

ADDISON74 commented Sep 8, 2021

By using any of the lines bellow in /app/code/core/Mage/Tax/etc/config.xml at line 165 solves the issue reported here #1813.

<after>freeshipping</after> => Vanilla Magento 1.9.4.5

or

<after>subtotal,nominal,freeshipping</after> => PR #1104

The variant below is now in all Magento LTS/OpenMage versions but the "Free Shipping" feature no longer works. Before merging this PR I would be interested to know what are the differences and real advantages in using the original Magento version or the proposed one.

<after>subtotal,nominal,shipping,freeshipping</after> => Magento LTS/OpenMage all versions

@fballiano
Copy link
Contributor

This is a very delicate change, it would require extensive tests that are impossible to me to conduct.

@fballiano
Copy link
Contributor

This PR doesn't have updates in 3 years, it's an extremely delicate topic, the original issue is closed as fixed... sorry but I'll close this PR too.

@ithuis
Copy link

ithuis commented Feb 2, 2024

can we reopen this ...

This PR fixes this situation for me.

When i configure a minimum cart total before "freeShipping" is available, in file
/app/code/core/Mage/Shipping/Model/Carrier/Freeshipping.php

the "$request->getBaseSubtotalInclTax()" returns 0.

after this pull request, it returns the correct cart amount.

@fballiano
Copy link
Contributor

github doesn't let me reopen it for some reason so it will have to be re-created

@ADDISON74
Copy link
Contributor

I am still using this change because of this issue #1813.

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