Project

General

Profile

Edit Copy Actions

Support #12223

open

Gaps in preorder flow with integration of products with variants & shipping

Added by Yalavarthi Thriveni 10 days ago. Updated 8 days ago.

Status:
In Progress
Priority:
High
Target version:
-
Start date:
11/20/2026
Due date:
11/20/2026 (8 days late)
% Done:

100%

Estimated time:
8:00 h
Spent time:

Description

Gap 1: Packaging Box Stock Skipping Without Release Trigger
Files:

packagingInventory.service.js#L158
,

packagingInventory.service.js#L253-L263
What Happens: When a pre-order is placed, the backend intentionally skips reserving physical packaging boxes to avoid locking warehouse box inventory months ahead of shipment:
javascript
// packagingInventory.service.js:158
if (!order || order.preOrder) return { skipped: true, reason: order ? "preorder" : "order_not_found", results: [] };
However, there is no scheduled cron job or release trigger when the pre-order reaches its fulfillment/delivery date to transition it to "reserved" status.
The Failure Point: When the warehouse packer opens the order on the packing screen, consumePackedBoxes finds no reservation entry for the pre-order and executes a fallback create with status: "short" and note: "Packed without a reservation":
javascript
// packagingInventory.service.js:261
status: "short", userId: by, note: "Packed without a reservation"
This bypasses planned box allocations, records the pre-order as an unexpected inventory deduction, and triggers unplanned low-stock alerts.
Recommended Fix: Add a scheduled daily job (or trigger upon moving the pre-order to processing/ready_to_pack) that executes reserveOrderBoxes({ orderId }) once the order date enters the fulfillment window.
Gap 2: Shipping Rate Card Independence & Skeleton Loading Gap
Files:

CheckoutPreorder.tsx
vs

Checkout.tsx#L2749, L2875
What Happens: In today's commit (67ab77d), standard checkout (

Checkout.tsx
) was upgraded with:
cardQuoteStatus: Record<string, 'loading' | 'failed'>
cardQuoteKeysRef
prefetchOtherMethod This allows the Standard and Express shipping cards to render skeleton loaders and fetch independently without blocking the user.
The Failure Point:

CheckoutPreorder.tsx
and

usePreorderShipping.ts
have not been synced with this change. If FedEx takes 4–5 seconds to quote Express on a split order, the pre-order checkout shipping selector remains in an indeterminate state or triggers a complete re-quote when toggled.
Recommended Fix: Port cardQuoteStatus and the independent prefetchOtherMethod logic from Checkout.tsx into usePreorderShipping.ts and PreorderShippingOptions.tsx.
Gap 3: Stripe Modal Abandonment / Stock Hold Recovery
Files:

payment.service.js:handleStripeCheckout
,

shop-controller.js
What Happens: When a customer clicks "Pay with Card" for a pre-order:
The backend soft-reserves variant stock (reserveCatalogVariant).
Creates a Stripe Checkout Session / Payment Intent.
Returns the clientSecret to render

StripeEmbeddedCheckoutModal.tsx
.
The Failure Point: If the customer closes the embedded modal, navigates away, or their session times out, Stripe sessions expire after 24 hours. Unless Stripe's checkout.session.expired webhook is received, the pre-order soft-reservation locks up catalog.products[].preorderLimit indefinitely, falsely marking items as "Sold Out" for other customers.
Recommended Fix: Add a 30-minute reservation TTL with a cleanup cron (or an explicit cancel endpoint triggered when the user closes StripeEmbeddedCheckoutModal).
Gap 4: Multi-Catalog Pre-Order Siloing / Cart Isolation
Files:

PreorderCartContext.tsx#L11
,

useStandalonePreorderCart.ts
What Happens: Pre-order carts store line items partitioned strictly by catalogId:
typescript
export const PREORDER_CATALOG_SESSION_KEY = "activePreorderCatalogId";
// localStorage key: preorder_cart_${catalogId}
The Failure Point: If a customer adds an item from "Spring Pre-Order Catalog", then visits "Fall Nursery Catalog" and adds an item, the cart context overwrites activePreorderCatalogId. The items from the Spring catalog disappear from the cart drawer without warning, reappearing only when navigating back to the Spring catalog URL.
Recommended Fix: If a user attempts to add an item from Catalog B while Catalog A has active items, display a confirmation prompt: "Your cart contains pre-orders from [Catalog A]. Would you like to clear your cart or finish checkout for [Catalog A] first?"
Gap 5: Residual Pickup Slot Time State in Mixed Fulfillment Orders
Files:

CheckoutPreorder.tsx#L3233, L3245-L3250
What Happens: Pre-orders support mixed fulfillment (pickupProducts and deliveryProducts). When pickedUpLocationPayload is constructed:
typescript
pickedUpLocation: pickedUpLocationPayload,
products: editableCart.map((item) => ({
...
fulfillmentType: resolvePreorderLineFulfillment(item),
selectedShippingMethod: resolvePreorderLineFulfillment(item) === 'delivery' ? preorderShipping.lineShippingMethod : undefined
}))
The Failure Point: If a customer initially selects Store Pickup, chooses a pickup date/time slot, and then toggles that item to Delivery, the slot time state remains attached to the item's local object. The backend delivery shipment receives residual store pickup times, which can cause downstream packing dispatch errors.
Recommended Fix: Sanitize item.pickupTime and item.pickupDate when resolvePreorderLineFulfillment(item) === 'delivery'.
Gap 6: Timezone Evaluation Discrepancy for Custom Product Windows
Files:

catlogproducts.tsx#L919-L921
,

SaleWindowTabs.tsx
What Happens: The POS Admin sets custom sale windows stored as ISO strings (YYYY-MM-DDTHH:mm:ss) representing the nursery's business timezone (e.g. Eastern Time / New York).
The Failure Point: In

catlogproducts.tsx
, certain countdown calculations compare against client-local browser time new Date(). A customer in Pacific Time (PST) can see countdown timers that are 3 hours out-of-sync with the server's Eastern Time (EST) schedule, either showing expired sales prematurely or allowing cart additions for 3 extra hours.
Recommended Fix: Always compare against the server-reported business time offset (getBusinessTimezone) rather than new Date().getTime().
Gap 7: Free-Shipping Subtotal Threshold on Mixed Fulfillment Carts
Files:

usePreorderShipping.ts#L257-L275
,

payment.service.js#L2635
What Happens: In a mixed cart containing both pickup and delivery items:
typescript
// usePreorderShipping.ts:273
const allocated = cartSubtotal > 0 ? Math.min(eligible, discount * eligible / cartSubtotal) : 0;
freeShippingEligibleSubtotal excludes freight and threshold-ineligible lines, but when a coupon discount is applied across the entire order, the free shipping subtotal allocates the coupon proportion across cartSubtotal (which includes pickup items).
The Failure Point: If a customer adds $150 of pickup items and $40 of delivery items (where the company free delivery threshold is $50), applying a $20 order-wide coupon can cause the frontend and backend threshold checks to disagree on whether the delivery items crossed the $50 threshold.
Recommended Fix: Ensure coupon discounts are apportioned strictly between delivery-eligible merchandise and pickup merchandise prior to testing freeShippingEligibleSubtotal >= minOrderSubtotal.


Add

Subtasks


Add

Related issues

Actions #1

Updated by Pavan Kumar Murala 9 days ago

  • Due date changed from 11/19/2026 to 11/20/2026
  • Status changed from New to In Progress
  • Start date changed from 11/19/2026 to 11/20/2026

Updated by Pavan Kumar Murala 9 days ago

  • % Done changed from 0 to 100
  • Estimated time set to 2:00 h

1. Gap 1 – Packaging Box Reservation: Updated packagingInventory.service.js to reserve pre-order boxes during packing confirmation, preventing unreserved packing entries and false low-stock alerts.

2. Gap 2 – Express Shipping Quote: Updated usePreorderShipping.ts and PreorderShippingOptions.tsx to display Standard shipping immediately while Express loads in the background and remains disabled until the quote arrives.

3. Gap 4 – Switching Catalogs: Added preorderCatalogGuard.ts and cart storage helpers to show a clear-or-keep confirmation when adding products from a different catalog.

4. Gap 6 – Business Timezone: Updated catlogproducts.tsx to calculate pre-order countdowns using the business timezone.

5. Gap 7 – Free Shipping Coupon Split: Updated usePreorderShipping.ts to distribute coupon discounts only across delivery lines, matching backend calculations.

6. Gap 5 – Pickup Data Safety: Updated CheckoutPreorder.tsx to remove stale pickup-related fields from delivery lines in the checkout payload.

7. Gap 3 – Stripe Modal: No changes required because stock is reserved only after successful payment completion; closing the Stripe modal does not reserve stock.

Actions #3

Updated by Pavan Kumar Murala 9 days ago

  • Status changed from In Progress to Resolved
Actions #4

Updated by Pavan Kumar Murala 9 days ago

  • Status changed from Resolved to In Progress

Updated by Pavan Kumar Murala 8 days ago

Orders and Preorders loading: Found duplicate and unnecessary requests that were slowing tab changes.
Orders tab: Made the extra 1,000-order request for card hover details run only when a card is hovered.
Shipping summary: Delayed its report request until the main order list has loaded.
Preorders tab: Made catalog setup skip analytics it doesn’t need, and delayed catalog analytics until sale-window setup completes.
Duplicate requests: Added guards to avoid sending identical requests while they’re already running.
Loading skeletons: Added skeleton rows to the Location Wise Product view and kept the order table skeleton visible while switching tabs and fetching new data.
Backend query work: Reduced repeated reads for the default order list and limited the catalog analytics query to fields it uses.

resolve the issues and view order page api's improments push notification related issues, order flow wise issue now fixed

Actions #6

Updated by Pavan Kumar Murala 8 days ago

  • Estimated time changed from 2:00 h to 8:00 h
Edit Copy Actions

Also available in: Atom PDF