fix(medusa): calculate sales channel availability correctly for variants (#10448)

* fix: calculate inventory quantities based on sales channel and locations

* Update packages/medusa/src/api/utils/middlewares/products/variant-inventory-quantity.ts

Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>

* Update packages/medusa/src/api/utils/middlewares/products/variant-inventory-quantity.ts

Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>

* Update packages/core/core-flows/src/product/steps/get-variant-availability.ts

Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>

* fix: crk

---------

Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
This commit is contained in:
Sebastian Rindom
2024-12-05 19:29:47 +01:00
committed by GitHub
co-authored by Carlos R. L. Rodrigues
parent b160fd3cbf
commit 7ff3f15d6d
11 changed files with 418 additions and 121 deletions
@@ -4,7 +4,7 @@ import {
refetchEntities,
} from "@medusajs/framework/http"
import { HttpTypes } from "@medusajs/framework/types"
import { wrapVariantsWithInventoryQuantity } from "../../utils/middlewares"
import { wrapVariantsWithTotalInventoryQuantity } from "../../utils/middlewares"
import { remapKeysForVariant, remapVariantResponse } from "../products/helpers"
export const GET = async (
@@ -30,7 +30,7 @@ export const GET = async (
)
if (withInventoryQuantity) {
await wrapVariantsWithInventoryQuantity(req, variants || [])
await wrapVariantsWithTotalInventoryQuantity(req, variants || [])
}
res.json({
@@ -4,7 +4,7 @@ import {
AuthenticatedMedusaRequest,
MedusaResponse,
} from "@medusajs/framework/http"
import { wrapVariantsWithInventoryQuantity } from "../../../../utils/middlewares"
import { wrapVariantsWithTotalInventoryQuantity } from "../../../../utils/middlewares"
import { refetchEntities, refetchEntity } from "@medusajs/framework/http"
import {
remapKeysForProduct,
@@ -38,7 +38,7 @@ export const GET = async (
)
if (withInventoryQuantity) {
await wrapVariantsWithInventoryQuantity(req, variants || [])
await wrapVariantsWithTotalInventoryQuantity(req, variants || [])
}
res.json({