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

Fix unit decimal calculation #1314

Merged
merged 1 commit into from
Oct 24, 2023
Merged

Conversation

alecritson
Copy link
Collaborator

Currently when calculating the cart lines via the pipelines, we're getting the unit cost based on the unit quantity but then also applying the same unit quantity to the cart line, even though it's already been considered. The result is if a purchasable has a unit quantity over 1 it's being doubled e.g.

ProductVariant::create([
    // ...
    'unit_quantity' => 100,
]);

$price = Price::create([
   'price' => 5503
]);

$price->price->unitDecimal; // 0.55

// After $cart->calculate();

$cartLine->subTotal->unitDecimal; // 0.01

This PR sets the unitQuantity to 1 on the $cartLine price data types, as the unit quantity has already been factored in.

@vercel
Copy link

vercel bot commented Oct 20, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
lunar-docs ✅ Ready (Inspect) Visit Preview Oct 20, 2023 1:00pm

@glennjacobs
Copy link
Contributor

@alecritson shouldn't this target 0.6?

@alecritson alecritson merged commit c29bcaf into main Oct 24, 2023
12 checks passed
@alecritson alecritson deleted the hotfix/fix-cart-line-unit-quantity branch October 24, 2023 08:41
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

Successfully merging this pull request may close these issues.

2 participants