docs: fix pricing query params in storefront guide + modules restructure (#9021)

- Fix pricing query params previously using `customer_group_id` and `customer_id` as expected / accepted queries and update information around them
- Other: reorganize the introduction page of each module to show how to use it at the very beginning.
This commit is contained in:
Shahed Nasser
2024-09-09 06:43:43 +00:00
committed by GitHub
parent afb83b2408
commit 3eb2387746
20 changed files with 973 additions and 964 deletions
@@ -8,60 +8,6 @@ export const metadata = {
The Cart Module is the `@medusajs/cart` NPM package that provides cart-related features in your Medusa and Node.js applications.
## Features
### Cart Management
Store and manage carts, including their addresses, line items, shipping methods, and more.
```ts
const cart = await cartModuleService.createCarts({
currency_code: "usd",
shipping_address: {
address_1: "1512 Barataria Blvd",
country_code: "us",
},
items: [
{
title: "Shirt",
unit_price: 1000,
quantity: 1,
},
],
})
```
### Apply Promotions
Apply promotions or discounts to line items and shipping methods by adding adjustment lines that are factored into their subtotals.
```ts
const lineAdjustments = await cartModuleService.addLineItemAdjustments({
item_id: "cali_123",
code: "50OFF",
amount: 500,
})
const shippingAdjustments =
await cartModuleService.addShippingMethodAdjustments({
shipping_method_id: "casm_123",
code: "FREESHIPPING",
amount: 1000,
})
```
### Cart Context and Scoping
A cart is scoped to a sales channel, region, and a customer.
When used with their respective modules and other commerce modules, you benefit from features like:
- Checking product availability in a sales channel.
- Retrieving pricing per region.
- Applying promotions based on the customer's group.
---
## How to Use Cart Module's Service
You can use the Cart Module's main service by resolving from the Medusa container the resource `ModuleRegistrationName.CART` imported from `@medusajs/utils`.
@@ -126,3 +72,57 @@ const step1 = createStep("step-1", async (_, { container }) => {
</CodeTab>
</CodeTabs>
---
## Features
### Cart Management
Store and manage carts, including their addresses, line items, shipping methods, and more.
```ts
const cart = await cartModuleService.createCarts({
currency_code: "usd",
shipping_address: {
address_1: "1512 Barataria Blvd",
country_code: "us",
},
items: [
{
title: "Shirt",
unit_price: 1000,
quantity: 1,
},
],
})
```
### Apply Promotions
Apply promotions or discounts to line items and shipping methods by adding adjustment lines that are factored into their subtotals.
```ts
const lineAdjustments = await cartModuleService.addLineItemAdjustments({
item_id: "cali_123",
code: "50OFF",
amount: 500,
})
const shippingAdjustments =
await cartModuleService.addShippingMethodAdjustments({
shipping_method_id: "casm_123",
code: "FREESHIPPING",
amount: 1000,
})
```
### Cart Context and Scoping
A cart is scoped to a sales channel, region, and a customer.
When used with their respective modules and other commerce modules, you benefit from features like:
- Checking product availability in a sales channel.
- Retrieving pricing per region.
- Applying promotions based on the customer's group.