#Overriding Price Selection strategy doesn't work?

4 messages · Page 1 of 1 (latest)

trim yew
#

Trying to override price selection strategy,
Created a file in src/strategies
and wrote code like
this.
However, calculateVariantPrice is not being called.
What to do?

halcyon spruce
#

Hey @trim yew - thank for reporting this in.

Can I get you to create an issue on GitHub? I think that would be appropriate for this type of request.

We'd love to help out!

crimson fiber
#

This doesn't work for me either as the method doesn't get called. I expect it to be called a lot. I'm on 1.14 and here's the code. I only want to override for certain cases so want to override PriceSelectionStrategy instead of AbstractPriceSelectionStrategy

import {PriceSelectionContext, PriceSelectionResult} from "@medusajs/medusa";
import PriceSelectionStrategy from "@medusajs/medusa/dist/strategies/price-selection";

export default class PriceStrategy extends PriceSelectionStrategy {

    calculateVariantPrice(data: { variantId: string; quantity?: number }[],
                          context: PriceSelectionContext): Promise<Map<string, PriceSelectionResult>> {
        console.log("does not print")
        return super.calculateVariantPrice(data, context);
    }
}