docs: update fulfillment provider module docs to reflect CalculatedShippingOptionPrice (#10778)
The return value below the example for the `calculatePrice` method is shown correctly as `CalculatedShippingOptionPrice` but the example is not updated in the guide "How to Create a Fulfillment Provider Module" This PR updates the example in the guide and the TS doc
This commit is contained in:
1 parent
6780ea9f13
commit
1ef3e4b8de
2 files changed
+21
-4
No files matched your search
@@ -229,13 +229,22 @@ export class AbstractFulfillmentProviderService
|
|||||||
* @returns The calculated price's details.
|
* @returns The calculated price's details.
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
|
* import { CalculateShippingOptionPriceDTO } from "@medusajs/framework/types"
|
||||||
* class MyFulfillmentProviderService extends AbstractFulfillmentProviderService {
|
* class MyFulfillmentProviderService extends AbstractFulfillmentProviderService {
|
||||||
* // ...
|
* // ...
|
||||||
* async calculatePrice(optionData: any, data: any, context: any): Promise<number> {
|
* async calculatePrice(
|
||||||
|
* optionData: CalculateShippingOptionPriceDTO["optionData"],
|
||||||
|
* data: CalculateShippingOptionPriceDTO["data"],
|
||||||
|
* context: CalculateShippingOptionPriceDTO["context"]
|
||||||
|
* ): Promise<CalculatedShippingOptionPrice> {
|
||||||
* // assuming the client can calculate the price using
|
* // assuming the client can calculate the price using
|
||||||
* // the third-party service
|
* // the third-party service
|
||||||
* const price = await this.client.calculate(data)
|
* const price = await this.client.calculate(data)
|
||||||
* return price
|
* return {
|
||||||
|
* calculated_amount: price,
|
||||||
|
* // Update this boolean value based on your logic
|
||||||
|
* is_calculated_price_tax_inclusive: true,
|
||||||
|
* }
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
|
|||||||
+10
-2
@@ -241,11 +241,19 @@ you can retrieve the calculated price of the shipping method.
|
|||||||
```ts
|
```ts
|
||||||
class MyFulfillmentProviderService extends AbstractFulfillmentProviderService {
|
class MyFulfillmentProviderService extends AbstractFulfillmentProviderService {
|
||||||
// ...
|
// ...
|
||||||
async calculatePrice(optionData: any, data: any, context: any): Promise<number> {
|
async calculatePrice(
|
||||||
|
optionData: CalculateShippingOptionPriceDTO["optionData"],
|
||||||
|
data: CalculateShippingOptionPriceDTO["data"],
|
||||||
|
context: CalculateShippingOptionPriceDTO["context"]
|
||||||
|
): Promise<CalculatedShippingOptionPrice> {
|
||||||
// assuming the client can calculate the price using
|
// assuming the client can calculate the price using
|
||||||
// the third-party service
|
// the third-party service
|
||||||
const price = await this.client.calculate(data)
|
const price = await this.client.calculate(data)
|
||||||
return price
|
return {
|
||||||
|
calculated_amount: price,
|
||||||
|
// update this boolean value based on your logic
|
||||||
|
is_calculated_price_tax_inclusive: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in new issue
Block a user