docs: improve commerce modules [1/n] (#9498)

Improve and add docs for API Key, Auth, and Cart Modules

[1/n]
This commit is contained in:
Shahed Nasser
2024-10-11 15:19:13 +00:00
committed by GitHub
parent dd162d69be
commit 69b9e73be7
29 changed files with 1025 additions and 323 deletions
@@ -14,7 +14,7 @@ In this document, youll learn how a promotion is applied to a carts line i
An adjustment line indicates a change to an item or a shipping methods amount. Its used to apply promotions or discounts on a cart.
The `LineItemAdjustment` data model represents changes on a line item, and the `ShippingMethodAdjustment` data model represents changes on a shipping method.
The [LineItemAdjustment](/references/cart/models/LineItemAdjustment) data model represents changes on a line item, and the [ShippingMethodAdjustment](/references/cart/models/ShippingMethodAdjustment) data model represents changes on a shipping method.
![A diagram showcasing the relations between other data models and adjustment line models](https://res.cloudinary.com/dza7lstvk/image/upload/v1711534248/Medusa%20Resources/cart-adjustments_k4sttb.jpg)
@@ -24,7 +24,7 @@ The `amount` property of the adjustment line indicates the amount to be discount
## Discountable Option
The `LineItem` data model has an `is_discountable` property that indicates whether promotions can be applied to the line item. Its enabled by default.
The [LineItem](/references/cart/models/LineItem) data model has an `is_discountable` property that indicates whether promotions can be applied to the line item. Its enabled by default.
When disabled, a promotion cant be applied to a line item. In the context of the Promotion Module, the promotion isnt applied to the line item even if it matches its rules.
@@ -33,7 +33,7 @@ When disabled, a promotion cant be applied to a line item. In the context of
## Promotion Actions
When using the Cart and Promotion modules together, use the [computeActions method of the Promotion Modules main service](/references/promotion/computeActions). It retrieves the actions of line items and shipping methods.
When using the Cart and Promotion modules together, such as in the Medusa application, use the [computeActions method of the Promotion Modules main service](/references/promotion/computeActions). It retrieves the actions of line items and shipping methods.
<Note>
@@ -41,6 +41,8 @@ Learn more about actions in the [Promotion Modules documentation](../../promo
</Note>
For example:
```ts collapsibleLines="1-8" expandButtonLabel="Show Imports"
import {
ComputeActionAdjustmentLine,
@@ -101,7 +103,7 @@ The `computeActions` method accepts the existing adjustments of line items and s
Then, use the returned `addItemAdjustment` and `addShippingMethodAdjustment` actions to set the carts line item and the shipping methods adjustments.
```ts collapsibleLines="1-9" expandButtonLabel="Show Imports"
```ts collapsibleLines="1-8" expandButtonLabel="Show Imports"
import {
AddItemAdjustmentAction,
AddShippingMethodAdjustment,