{
"name": "test_medusa",
"version": "0.0.1",
"description": "A starter for Medusa projects.",
"author": "Medusa (https://medusajs.com)",
"license": "MIT",
"keywords": [
"sqlite",
"postgres",
"typescript",
"ecommerce",
"headless",
"medusa"
],
"scripts": {
"build": "medusa build",
"start": "medusa start",
"dev": "medusa develop",
"migrate": "medusa db:migrate",
"lint": "eslint src --ext .ts,.tsx",
"lint:fix": "eslint src --ext .ts,.tsx --fix"
},
"dependencies": {
"@medusajs/admin-sdk": "2.11.3",
"@medusajs/cli": "2.11.3",
"@medusajs/framework": "2.11.3",
"@medusajs/medusa": "2.11.3",
"@opentelemetry/exporter-trace-otlp-http": "0.53.0",
"@types/fhir": "^0.0.41",
"axios": "^1.8.4",
"moment": "^2.30.1",
"uuid": "^11.1.0"
},
"devDependencies": {
"@eslint/js": "^9.15.0",
"@medusajs/test-utils": "2.11.3",
"@swc/core": "1.5.7",
"@swc/jest": "^0.2.36",
"@types/jest": "^29.5.13",
"@types/node": "^20.0.0",
"@types/react": "^18.3.2",
"@types/react-dom": "^18.2.25",
"eslint": "^9.15.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-only-warn": "^1.1.0",
"eslint-plugin-prettier": "^5.5.4",
"jest": "^29.7.0",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"ts-node": "^10.9.2",
"typescript": "^5.6.2",
"typescript-eslint": "^8.15.0",
"vite": "^5.2.11",
"yalc": "^1.0.0-pre.53"
},
"engines": {
"node": ">=20"
}
}
v22.15.0
PostgreSQL 14.19
MacOS Sequoia 15.7.1
Google Chrome
I encountered an issue in version v2.11.* where I can’t create a cart that automatically calculates prices based on the customer_group the customer belongs to.
For example, I create a cart by passing the customer’s email to the API:
Next.js server code:
const { cart } = await medusaSdk.store.cart.create(
{
region_id: process.env.MEDUSA_REGION_ID,
email: customerEmail,
promo_codes: discountCode ? [discountCode] : [],
items: [
{
variant_id: variant?.id || '',
quantity: 1,
},
],
},
{},
headers
);
The customer belongs to a group where the product price differs from the default, but the returned price is still the default one.
P.S. In version 2.10.3, we used a small workaround with a medusa hook:
createCartWorkflow.hooks.setPricingContext(
async ({ customerData }, { container }) => {
const query = container.resolve(ContainerRegistrationKeys.QUERY);
const {
data: [customer],
} = await query.graph({
entity: "customer",
fields: ["*", "groups.*"],
filters: {
email: customerData.email,
},
});
if (customer.groups) {
return new StepResponse({
customer: {
groups: {
id: customer.groups.map((group) => group?.id).filter((id) => id),
},
},
});
}
return new StepResponse({});
},
);
However, this no longer works because the customer field is now being overwritten in your code (line 113): https://github.com/medusajs/medusa/blob/147ce2fdc35366e591f552404ec949f6a5b92a11/packages/core/core-flows/src/cart/workflows/get-variants-and-items-with-prices.ts#L92-L132
The product prices in the cart should be calculated based on the customer group.
The product prices in the cart can't be calculated by customer group.
none