Skip to content

Walmart Ship with Walmart (SWW) - Early Label Purchase Flow

This feature allows purchasing shipping labels early for Walmart Marketplace orders using Ship with Walmart (SWW), sending tracking information to Walmart immediately when an order is released to the warehouse, rather than waiting for the warehouse to complete pick/pack processing.

  • Faster tracking delivery: Send tracking to Walmart as soon as the order is released, improving seller metrics
  • Meet delivery promises: Ensure tracking is registered early to avoid late shipment penalties
  • Simplified warehouse flow: Warehouse uses pre-purchased labels at ship time

When a Walmart order is imported via EDI, purchase_label_early is automatically set to true by default. This ensures all Walmart orders benefit from early tracking delivery.

Users can toggle the “Purchase shipping label early” checkbox on the shipping page to enable/disable early label purchase for individual orders.

When the order transitions to awaiting_deliveries state:

  1. System automatically purchases a shipping label via Walmart SWW API
  2. Label PDF is stored as an order attachment (category: early_ship_label)
  3. EDI ship confirmation is sent to Walmart with tracking info
  4. Metadata stored in early_label_metadata JSONB column

When the warehouse picks/packs the order:

  1. The picker screen displays an alert if an early label was purchased
  2. Shows the early-labeled shipment dimensions/weights
  3. Warns that changing packing will void the early label
  4. Staff can choose to match the early label packing or override

When the warehouse completes picking and performs ship-labeling:

  1. System checks for mismatch between early label and actual packing
  2. If packing matches: Reuses the existing label (no new API call), moves label PDF from order to shipment
  3. If packing changed: Voids early label, resets flag, purchases new labels for actual shipments
  4. Shipment(s) marked as label_complete

If order transitions OUT of awaiting_deliveries to:

  • cancelled
  • fraudulent
  • in_cr_hold

The early label is automatically voided via API. The purchase_label_early flag is preserved so it will purchase again when re-released.

When picking is completed, if the actual packing differs from the early label:

  • System compares shipment count, dimensions, and weights
  • Triggers if: different shipment count, or >20% / >2 inches / >1 lb difference
  • Early label is voided via API
  • purchase_label_early flag is reset to false
  • Flash message warns user that early label was voided
  • New labels are purchased via normal flow

If user clicks “Void Shipments” on the delivery:

  • Early label is voided (if not yet transferred to shipment)
  • purchase_label_early flag is reset to false
  • Next ship-label will go through normal flow
20260121000000_add_early_label_columns_to_orders.rb
add_column :orders, :purchase_label_early, :boolean, default: false, null: false
add_column :orders, :early_label_metadata, :jsonb, default: {}
{
"tracking_number": "1Z999AA10123456784",
"carrier": "USPS",
"sww_label_id": "abc123",
"service_type": "USPS_GROUND_ADVANTAGE",
"purchased_at": "2026-01-21T10:00:00Z",
"delivery_id": 12345,
"voided_at": null,
"void_reason": null,
"early_label_shipments_count": 1,
"early_label_shipments_data": [
{
"id": 123456,
"length": 12.0,
"width": 10.0,
"height": 8.0,
"weight": 5.0,
"container_type": "carton"
}
]
}
FilePurpose
app/models/order.rbState machine hooks, label purchase/void logic, mismatch detection
app/models/delivery.rbvoid_shipments integration
app/services/edi/walmart/shipping_label_purchaser.rbReuse early label at ship-label time
app/services/edi/walmart/confirm_message_processor.rbEDI ship confirmation with carrier info
app/services/edi/walmart/ship_code_mapper.rbMaps SWW carrier to Walmart EDI codes
app/controllers/orders_controller.rbFlash messages for UI feedback
app/controllers/deliveries_controller.rbMismatch detection at complete_picked
app/views/orders/shipping.html.erbCheckbox and status display
app/views/deliveries/picked.html.erbEarly label alert with dimensions
app/models/upload.rbearly_ship_label category
# Check if order has active early label
order.has_early_purchased_label?
# Check if eligible for SWW
order.walmart_sww_eligible?
# Check if early label shipments match current packing
# Returns { match: true/false, reason: 'description of mismatch' }
order.early_label_shipments_match?(delivery)
# Manually void early label
order.void_early_label!(reason: 'Manual void', reset_flag: true)
# Get early label upload
order.early_label_upload
# Get stored early label shipment data
order.early_label_shipments_data
order.early_label_shipments_count
StateDisplay
No early label, SWW eligibleCheckbox shown
Early label purchasedGreen success alert with tracking
Early label voidedWarning alert + checkbox shown
Labels already on shipmentsSuccess alert (labels exist)
  • Walmart allows updating tracking within 24 hours of original shipment OR before first carrier scan
  • Use processMode: PARTIAL_UPDATE to update tracking
  • Multiple confirm messages allowed for different line items
  • Early label is for 1 shipment based on existing suggested shipments
  • Must have at least one shipment created before early label purchase
  • If actual packing differs significantly, early label is voided and new labels purchased

At complete_picked time, the system detects if:

  • Number of shipments differs from early label (early = 1, actual = 2+)
  • Dimensions/weights significantly different (>20% or >2 inches / >1 lb)

When mismatch is detected:

  • Early label is voided via Walmart API
  • purchase_label_early flag is reset to false
  • Flash warning informs user of the void
  • Normal ship-labeling flow purchases new labels for actual shipments
  • EDI confirm message sent with correct carrier info
  1. Multi-shipment early labels: Currently early label supports 1 shipment; consider supporting multiple upfront
  2. Dimension estimation improvements: Use historical data to better estimate packaging

In development mode, the system uses a mock PDF (test/sww_label_mock_pdf.pdf) since the Walmart sandbox doesn’t return real label PDFs.