feat(core-flows): calculate SO price on cart ops (#10563)

**What**
- calculate the shipping option price when creating a shipping method
- calculate the shipping option price when refreshing cart
- add testing for calculated SO flow
- fix validation on calculated SO creation
- add manual fulfillment provider for testing
- add `from_location` to calculation context

---

RESOLVES CMRC-778
RESOLVES CMRC-602
RESOLVES SUP-136
This commit is contained in:
Frane Polić
2024-12-16 22:28:30 +00:00
committed by GitHub
parent 95baacfd00
commit 0c49470066
21 changed files with 903 additions and 52 deletions
@@ -1,5 +1,6 @@
import {
CalculatedShippingOptionPrice,
CalculateShippingOptionPriceDTO,
FulfillmentOption,
IFulfillmentProvider,
} from "@medusajs/types"
@@ -219,9 +220,9 @@ export class AbstractFulfillmentProviderService
* }
*/
async calculatePrice(
optionData: Record<string, unknown>,
data: Record<string, unknown>,
context: Record<string, unknown>
optionData: CalculateShippingOptionPriceDTO["optionData"],
data: CalculateShippingOptionPriceDTO["data"],
context: CalculateShippingOptionPriceDTO["context"]
): Promise<CalculatedShippingOptionPrice> {
throw Error("calculatePrice must be overridden by the child class")
}