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

OrderItemPriceCalculationStrategy is not used on order modification #2870

Closed
kyunal opened this issue May 28, 2024 · 0 comments
Closed

OrderItemPriceCalculationStrategy is not used on order modification #2870

kyunal opened this issue May 28, 2024 · 0 comments
Assignees
Labels
type: bug 🐛 Something isn't working

Comments

@kyunal
Copy link
Contributor

kyunal commented May 28, 2024

Describe the bug
The OrderItemPriceCalculationStrategy used to adjust price calculation when items are being added or adjusted is not invoked on order modifications, specifically when a new item is added to the order during a modification.

To Reproduce
Steps to reproduce the behavior:

  1. Use this tiny example strategy
import {
    Order,
    OrderItemPriceCalculationStrategy,
    PriceCalculationResult,
    ProductVariant,
    RequestContext
} from "@vendure/core";

export class TestOrderItemPriceCalculationStrategy implements OrderItemPriceCalculationStrategy {
    calculateUnitPrice(
        ctx: RequestContext,
        productVariant: ProductVariant,
        orderLineCustomFields: { [key: string]: any },
        order: Order,
    ): PriceCalculationResult | Promise<PriceCalculationResult> {
        return {
            price: 1337,
            priceIncludesTax: true,
        }
    }
}
  1. Create a new order (draft or real) and add any item, it will have the price 13.37
  2. Finalize the order, then modify by adding another (different) item
  3. See error (the new item's original price is used)

Expected behavior
I would expect the OrderItemPriceCalculationStrategy to be used here as well.

Environment (please complete the following information):
Fresh installation with the @vendure/create tool

  • @vendure/core version: 2.2.4
  • Nodejs version: 20.12.2
  • Database (mysql/postgres etc): SQLite

Additional context
This is potentially a breaking change as price calculation is handled differently.

@kyunal kyunal added the type: bug 🐛 Something isn't working label May 28, 2024
@michaelbromley michaelbromley moved this to 🏗 In progress in Vendure OS Roadmap May 31, 2024
@michaelbromley michaelbromley moved this from 🏗 In progress to 🔖 Ready in Vendure OS Roadmap Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working
Projects
Status: 🚀 Shipped
Development

No branches or pull requests

2 participants