Skip to content

Conversation

@digistaal
Copy link

@digistaal digistaal commented Jan 10, 2026

Summary

What

Add missing fields to productVariantsFields in packages/core/core-flows/src/order/utils/fields.ts to match the cart version.

Why

Fixes #14304
The order version of productVariantsFields was missing several fields compared to the cart version at packages/core/core-flows/src/cart/utils/fields.ts. Most critically, product.shipping_profile.id was missing.
This causes orders created via the admin panel (draft orders) to have requires_shipping=false on their line items and fulfillments, which prevents the "Mark as shipped" button from appearing in the admin dashboard.

Root Cause

When creating draft orders in the admin:

  1. createOrdersStep calls validateVariantPrices() which fetches variants using productVariantsFields
  2. The order version was missing product.shipping_profile.id
  3. prepareLineItemData() evaluates hasShippingProfile as false because the field is never fetched
  4. requires_shipping is set to false on line items
  5. Fulfillments inherit this incorrect value
  6. The "Mark as shipped" button never appears (it requires fulfillment.requires_shipping === true)

Changes

Added fields to order/utils/fields.ts

  • requires_shipping
  • variant_option_values
  • thumbnail
  • product.is_giftcard
  • product.shipping_profile.id (critical fix)
    Added integration test
    Added a test to integration-tests/modules/__tests__/order/draft-order.spec.ts that:
  • Creates a product with a shipping profile linked
  • Uses an inventory item with requires_shipping=false to isolate the shipping profile logic
  • Validates that requires_shipping=true on the order item due to the shipping profile
    This ensures the fix is properly covered and prevents regression.

Testing

After applying this fix, draft orders created in the admin panel will correctly have requires_shipping=true on their fulfillments, and the "Mark as shipped" button will appear as expected.

Checklist

Please ensure the following before requesting a review:

  • I have added a changeset for this PR
    • Every non-breaking change should be marked as a patch
    • To add a changeset, run yarn changeset and follow the prompts
  • The changes are covered by relevant tests
  • I have verified the code works as intended locally
  • I have linked the related issue(s) if applicable

Additional Context

This issue only occurs for variants that do not have inventory management enabled, which is why it wasn't caught by other unit/integration tests. Normally it would fall back to one of the inventory to require shipping (which is true by default), but if inventory management is disabled, this is not applicable.


Note

Ensures requires_shipping is derived correctly for draft orders by aligning order variant fields with the cart.

  • Extends order/utils/fields.ts productVariantsFields with requires_shipping, variant_option_values, thumbnail, product.is_giftcard, and product.shipping_profile.id (critical for shipping determination)
  • Adds an integration test in integration-tests/.../draft-order.spec.ts that links a product to a shipping profile and validates requires_shipping=true even when the inventory item has requires_shipping=false; resolves FULFILLMENT module in tests
  • Adds a patch changeset for @medusajs/core-flows

Written by Cursor Bugbot for commit e841b3d. This will update automatically on new commits. Configure here.

Add missing fields to productVariantsFields in order/utils/fields.ts to match
the cart version. This fixes medusajs#14304 where orders created via admin panel have
incorrect requires_shipping=false on fulfillments.

Added fields:
- requires_shipping
- variant_option_values
- thumbnail
- product.is_giftcard
- product.shipping_profile.id (critical fix)

The missing product.shipping_profile.id field caused prepareLineItemData() to
always evaluate hasShippingProfile as false, resulting in requires_shipping=false
on line items and fulfillments for draft orders.
Add integration test that validates requires_shipping is correctly set to true
when a product has a shipping profile linked, even when the inventory item has
requires_shipping=false.

This test ensures the fix for medusajs#14304 is properly covered and prevents regression.
The test specifically validates that the product.shipping_profile.id field is
being fetched and used in the requires_shipping calculation.
@digistaal digistaal requested a review from a team as a code owner January 10, 2026 11:01
@changeset-bot
Copy link

changeset-bot bot commented Jan 10, 2026

🦋 Changeset detected

Latest commit: e841b3d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 76 packages
Name Type
@medusajs/core-flows Patch
@medusajs/medusa Patch
@medusajs/test-utils Patch
integration-tests-http Patch
@medusajs/medusa-oas-cli Patch
@medusajs/analytics Patch
@medusajs/api-key Patch
@medusajs/auth Patch
@medusajs/caching Patch
@medusajs/cart Patch
@medusajs/currency Patch
@medusajs/customer Patch
@medusajs/file Patch
@medusajs/fulfillment Patch
@medusajs/index Patch
@medusajs/inventory Patch
@medusajs/link-modules Patch
@medusajs/locking Patch
@medusajs/notification Patch
@medusajs/order Patch
@medusajs/payment Patch
@medusajs/pricing Patch
@medusajs/product Patch
@medusajs/promotion Patch
@medusajs/rbac Patch
@medusajs/region Patch
@medusajs/sales-channel Patch
@medusajs/settings Patch
@medusajs/stock-location Patch
@medusajs/store Patch
@medusajs/tax Patch
@medusajs/translation Patch
@medusajs/user Patch
@medusajs/workflow-engine-inmemory Patch
@medusajs/workflow-engine-redis Patch
@medusajs/draft-order Patch
@medusajs/oas-github-ci Patch
@medusajs/cache-inmemory Patch
@medusajs/cache-redis Patch
@medusajs/event-bus-local Patch
@medusajs/event-bus-redis Patch
@medusajs/analytics-local Patch
@medusajs/analytics-posthog Patch
@medusajs/auth-emailpass Patch
@medusajs/auth-github Patch
@medusajs/auth-google Patch
@medusajs/caching-redis Patch
@medusajs/file-local Patch
@medusajs/file-s3 Patch
@medusajs/fulfillment-manual Patch
@medusajs/locking-postgres Patch
@medusajs/locking-redis Patch
@medusajs/notification-local Patch
@medusajs/notification-sendgrid Patch
@medusajs/payment-stripe Patch
@medusajs/framework Patch
@medusajs/js-sdk Patch
@medusajs/modules-sdk Patch
@medusajs/orchestration Patch
@medusajs/types Patch
@medusajs/utils Patch
@medusajs/workflows-sdk Patch
@medusajs/cli Patch
@medusajs/deps Patch
@medusajs/telemetry Patch
@medusajs/admin-bundler Patch
@medusajs/admin-sdk Patch
@medusajs/admin-shared Patch
@medusajs/admin-vite-plugin Patch
@medusajs/dashboard Patch
@medusajs/icons Patch
@medusajs/toolbox Patch
@medusajs/ui-preset Patch
create-medusa-app Patch
medusa-dev-cli Patch
@medusajs/ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Jan 10, 2026

@digistaal is attempting to deploy a commit to the medusajs Team on Vercel.

A member of the Team first needs to authorize it.

@digistaal digistaal changed the title Fix/draft order variants requires_shipping field fix(core): draft order variants requires_shipping field Jan 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Orders created in admin panel have incorrect requires_shipping when fulfillment is created

2 participants