metatrondelivery/extensions/datetime-widget/blocks/product-availability.liquid
metatroncubeswdev a2c78d703f
Some checks failed
CI / Lint, Unit & Integration Tests (push) Has been cancelled
feat: close DS study coverage gaps (inventory exclusion, live checkout re-validation, per-day cap, payment fn, checkout ext)
Audited the implementation against DS_Delivery_Date_Time_App_Study.docx and
closed the actionable gaps (see IMPLEMENTATION_REVIEW_2026-09-04.md).

Core (code + unit tests, 156 green):
- Wire excludeLocationsWithoutStock into resolveAvailabilityRequest; widget
  now sends variantIds so inventory-based location exclusion actually runs.
- Live slot re-validation at checkout: new checkout-snapshot.server.ts writes
  a shop-metafield capacity snapshot; validation-slot's evaluateCheckout
  rejects a complete selection that has since filled / blacked out / closed /
  hit the daily cap / left the schedule. Refreshed on order webhooks and
  slot/blackout/location/enforcement edits.
- Scopable checkout enforcement: Shop.enforcementMode (all|tagged|off) +
  enforcementTag, new app.settings.tsx admin page, honoured via the snapshot.
- Per-day order cap: Location.dailyOrderCap threaded through getAvailability
  (dailyCap + consumedPerDate); admin field on the location screen.
- Product-rule slot blocking: ProductRule.blockedStartMins, unioned in
  resolveProductRuleConstraints, enforced in the engine and resolveHoldRequest;
  admin field on the product rules screen.
- Product-page placement: product-availability.liquid block + widget
  data-mode="preview" (read-only earliest-date line).
- Second locale: datetime-widget fr.json / fr.schema.json.
- Migration 20260904120000_review_gaps (apply with prisma migrate deploy).

New Functions (source + unit tests; need `shopify app deploy` to ship):
- extensions/payment-customization: cart.payment-methods.transform.run — hides
  cash-on-delivery / pay-in-store gateways on SHIPPING orders.
- extensions/checkout-datetime/src: restored from a gitignored dist-only state
  — Plus native picker + Thank you / Order status confirmation blocks, all
  calling the existing checkout.scheduling.* routes (one capacity pool).
  tsconfig ships checkJs:false pending reconciliation with live checkout types.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-04 01:31:02 -04:00

71 lines
2.6 KiB
Plaintext

{% comment %}
Product-page placement (study §3.7 "Delivery/availability information can
surface at the product level"). Renders the same widget in read-only
"preview" mode: it shows the earliest available date per method and
collects nothing — the interactive picker still lives on the cart page.
Merchants add this block to their product template from the theme editor.
{% endcomment %}
<div
class="dd-widget dd-widget--preview"
data-dd-widget
data-mode="preview"
data-heading="{{ block.settings.heading | escape }}"
data-show-shipping="{{ block.settings.show_shipping }}"
data-show-local-delivery="{{ block.settings.show_local_delivery }}"
data-show-pickup="{{ block.settings.show_pickup }}"
data-label-shipping="{{ 'widget.method_shipping' | t | escape }}"
data-label-local-delivery="{{ 'widget.method_local_delivery' | t | escape }}"
data-label-pickup="{{ 'widget.method_pickup' | t | escape }}"
data-attr-label-shipping="{{ 'widget.date_label_shipping' | t | escape }}"
data-attr-label-local-delivery="{{ 'widget.date_label_local_delivery' | t | escape }}"
data-attr-label-pickup="{{ 'widget.date_label_pickup' | t | escape }}"
data-label-no-dates="{{ 'widget.no_dates' | t | escape }}"
data-label-loading="{{ 'widget.loading' | t | escape }}"
data-label-error="{{ 'widget.error' | t | escape }}"
data-label-earliest-prefix="{{ 'widget.earliest_prefix' | t | escape }}"
data-label-delivery-at-checkout="{{ 'widget.delivery_at_checkout' | t | escape }}"
{% if block.settings.location_id != blank %}data-location-id="{{ block.settings.location_id | escape }}"{% endif %}
{{ block.shopify_attributes }}
>
<noscript>{{ 'widget.enable_js' | t | escape }}</noscript>
</div>
{% schema %}
{
"name": "t:product_availability.name",
"target": "section",
"settings": [
{
"type": "text",
"id": "heading",
"label": "t:product_availability.heading_label",
"default": "Delivery & pickup availability"
},
{
"type": "checkbox",
"id": "show_shipping",
"label": "t:datetime_picker.show_shipping_label",
"default": true
},
{
"type": "checkbox",
"id": "show_local_delivery",
"label": "t:datetime_picker.show_local_delivery_label",
"default": true
},
{
"type": "checkbox",
"id": "show_pickup",
"label": "t:datetime_picker.show_pickup_label",
"default": true
},
{
"type": "text",
"id": "location_id",
"label": "t:datetime_picker.location_id_label",
"info": "t:datetime_picker.location_id_info"
}
]
}
{% endschema %}