Skip to content

Updated Price Model TaxIncl methods & Cart Item TaxIncl properties to actually provide Tax inclusive values.#2411

Open
MacTavish-69 wants to merge 4 commits intolunarphp:1.xfrom
MacTavish-69:patch/tax-incl
Open

Updated Price Model TaxIncl methods & Cart Item TaxIncl properties to actually provide Tax inclusive values.#2411
MacTavish-69 wants to merge 4 commits intolunarphp:1.xfrom
MacTavish-69:patch/tax-incl

Conversation

@MacTavish-69
Copy link
Contributor

@MacTavish-69 MacTavish-69 commented Feb 27, 2026

Lunar Current Behavior

  1. Taxes are only accounted for when shipping address is set.

    For most stores, this is at the time of checkout. Logically, if tax is applicable on end user, the prices should be shown tax inclusive. Often, this is a legal requirement.

  2. Lunar internally relies on Default Tax Class & Default Tax Zone.

    When Lunar Internally just uses Default Tax class & Zone, this system causes incorrect behavior when you've some taxed zone and some zones which are NOT taxed. In this case, you'll set the non taxed zone as Default and the incTax methods will result in same non-taxed amount.

  3. Because of 1 & 2, the taxIncl methods often don't actually provide the intended taxIncl prices.

Fixes in PR

The PR approaches this problem at cart level and Price Model level.

Cart Level

We add TaxZone property to Cart model. The typical flow is to find the user country based on IP in middleware, determine the tax zone and set it on the cart. With this, The items added to cart, will correctly give tax incl price when taxInc methods are called.

Price Model Level

When we have Product/Purchasable instead of Cart Line (Item is added to cart), we get the price from prices relation (prices attached to purchasable) and utilize priceIncTax, comparePriceIncTax methods. An optional TaxZone parameter is added so you can get the tax inclusive price as per the zone of your choice. This is useful when you need it for one time for any reason.
Note: You can totally ignore it if you need the prices to be as per the zone set on cart, the PR will fallback to the zone set on cart.

Previous PR: #2406

The previous PR focused strictly on Product/Purchasable display prices. It introduced a taxzone parameter to specific methods, allowing developers to:

  • Identify the user's taxable region manually.
  • Pass that taxzone into price methods to display the correct tax-inclusive amounts.
  • While effective for simple product displays, it did not address the underlying Cart logic.

This PR is a superset of #2406. It retains the functionality mentioned above but expands it by adding a taxZone property directly to the Cart.

IMPORTANT:
Since this PR includes all changes from #2406, please reject/close that PR if you choose to merge this one.

taxIncl methods internally work on default tax class basis. The moment you've more than 1 tax class, it stops working.

Moreover, taxation works on cart when address is set. However, it's a standard use case to display Tax inclusive prices to user when they're from a tax eligible jurisdiction. This use case is not achievable with current way of Lunar.

Hence, we need to have tax information on the cart which can take care of it.
For one time situations where you need tax Incl price for a given zone, you can pass the zone as parameter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant