Skip to content

Commit

Permalink
docs: update fulfillment provider module docs to reflect CalculatedSh…
Browse files Browse the repository at this point in the history
…ippingOptionPrice (medusajs#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
  • Loading branch information
ranjithkumar8352 authored and jimrarras committed Jan 28, 2025
1 parent 3daa142 commit f35a683
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
15 changes: 12 additions & 3 deletions packages/core/utils/src/fulfillment/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,22 @@ export class AbstractFulfillmentProviderService
* @returns The calculated price's details.
*
* @example
* import { CalculateShippingOptionPriceDTO } from "@medusajs/framework/types"
* 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
* // the third-party service
* 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,
* }
* }
* }
*/
Expand Down Expand Up @@ -346,7 +355,7 @@ export class AbstractFulfillmentProviderService
* `data` property, it's stored in the fulfillment's `data` property.
*
* The `data` property is useful when handling the fulfillment later,
* as you can access information useful for your integration. For example, you
* as you can access information useful for your integration. For example, you
* can store an ID for the fulfillment in the third-party service.
*
* Use this method to perform actions necessary in the third-party fulfillment service, such as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,19 @@ you can retrieve the calculated price of the shipping method.
```ts
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
// the third-party service
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
}
}
}
```
Expand Down

0 comments on commit f35a683

Please sign in to comment.