@shopbite-de/storefront 2.5.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CLAUDE.md CHANGED
@@ -92,7 +92,8 @@ Custom ShopBite plugin endpoints are prefixed `shopbite.*` in the operations typ
92
92
  Key custom composables:
93
93
 
94
94
  - **`useBusinessHours`** – opening hours with multi-interval support; Sunday is day 7 (not 0)
95
- - **`useDeliveryTime`** – validates slots in 5-minute increments, accounts for `deliveryMinutes` (default 30), handles holidays
95
+ - **`useDeliveryTime`** – validates slots in 5-minute increments, accounts for the lead time of the selected shipping method (`useShippingLeadTime`; 30 minutes until the config is loaded), handles holidays
96
+ - **Lead time per shipping method** (shopbite#6) – `/store-api/shopbite/config` returns `shippingMethods: [{ id, fulfillment: "delivery" | "pickup", leadTimeMinutes }]` (active methods of the sales channel); there is no global `deliveryTime` any more and no guessing from method names. `app/utils/leadTime.ts` (also used by llms.txt): `shippingLeadTime()` for a method (unlisted = delivery without lead time), `fulfillmentLeadTime()` = first method of a fulfillment (`null` without one; home hero/facts and llms.txt then leave the time out), `FULFILLMENT_WORDING` (Wunschlieferzeit/Wunschabholzeit, Liefer-/Abholzeiten), `wishedTimeComment()`/`parseWishedTime()`. `useShippingLeadTime()` follows the checkout's selected shipping method (time field, hint, empty states, comment prefix). The order's `customerComment` is `Wunschlieferzeit: HH:MM` or `Wunschabholzeit: HH:MM`; readers accept both (older orders always say Wunschlieferzeit). `useShopBiteConfig()` exposes `deliveryTime`/`pickupTime` (lead time of the first delivery/pickup method or `null`) and `leadTimeFor(method)`; the home facts have `kind: delivery` and `kind: pickup`
96
97
  - **`useAddToCart`** – products with extras/toppings use UUID v5 (product ID + sorted extras) as container item reference; simple products bypass the container
97
98
  - **`useAddressAutocomplete`** – proxies Geoapify through `/api/address/autocomplete` to avoid exposing the API key client-side
98
99
  - **`useShopBiteConfig`** – fetches delivery config and checkout state from the custom Shopware plugin; the server renders from the cached `/api/shopbite/config` (60 s), the browser loads it from Shopware after hydration (`useLiveShopData`) and the checkout every 10 s (`Checkout/Summary.vue`). The plugin does not enforce the checkout switch, so the browser's value is the gate and must come from Shopware
@@ -10683,18 +10683,74 @@
10683
10683
  "type": "boolean",
10684
10684
  "description": "Whether checkout is enabled for ShopBite"
10685
10685
  },
10686
- "deliveryTime": {
10687
- "type": "integer",
10688
- "minimum": 1,
10689
- "description": "Default delivery time in minutes"
10686
+ "addressStreet": {
10687
+ "type": "string",
10688
+ "nullable": true,
10689
+ "description": "Street and number of the shop, null if not configured"
10690
+ },
10691
+ "addressPostalCode": {
10692
+ "type": "string",
10693
+ "nullable": true,
10694
+ "description": "Postal code of the shop, null if not configured"
10695
+ },
10696
+ "addressCity": {
10697
+ "type": "string",
10698
+ "nullable": true,
10699
+ "description": "City of the shop, null if not configured"
10700
+ },
10701
+ "telephone": {
10702
+ "type": "string",
10703
+ "nullable": true,
10704
+ "description": "Telephone number in display format (e.g. +49 123 456789), null if not configured"
10705
+ },
10706
+ "googleBusinessProfileUrl": {
10707
+ "type": "string",
10708
+ "format": "uri",
10709
+ "nullable": true,
10710
+ "description": "Link to the shop's Google Business Profile, null if not configured"
10690
10711
  },
10691
10712
  "menuCategoryId": {
10692
10713
  "type": "string",
10693
10714
  "pattern": "^[0-9a-f]{32}$",
10694
10715
  "description": "Root category of the menu: the configured menu category, else the navigation category of the sales channel"
10716
+ },
10717
+ "shippingMethods": {
10718
+ "type": "array",
10719
+ "description": "The active shipping methods of the sales channel with fulfillment and lead time (shipping method custom fields shopbite_fulfillment and shopbite_lead_time_minutes; without a value: delivery and 30 minutes)",
10720
+ "items": {
10721
+ "type": "object",
10722
+ "properties": {
10723
+ "id": {
10724
+ "type": "string",
10725
+ "pattern": "^[0-9a-f]{32}$"
10726
+ },
10727
+ "fulfillment": {
10728
+ "type": "string",
10729
+ "enum": [
10730
+ "delivery",
10731
+ "pickup"
10732
+ ]
10733
+ },
10734
+ "leadTimeMinutes": {
10735
+ "type": "integer",
10736
+ "minimum": 1,
10737
+ "maximum": 1440,
10738
+ "description": "Minutes until the order is delivered or ready for pickup"
10739
+ }
10740
+ },
10741
+ "required": [
10742
+ "id",
10743
+ "fulfillment",
10744
+ "leadTimeMinutes"
10745
+ ]
10746
+ }
10695
10747
  }
10696
10748
  },
10697
- "required": ["isCheckoutEnabled", "deliveryTime"]
10749
+ "required": [
10750
+ "isCheckoutEnabled",
10751
+ "menuCategoryId",
10752
+ "shippingMethods"
10753
+ ]
10698
10754
  },
10699
10755
  "BusinessHour": {
10700
10756
  "type": "object",
@@ -16899,7 +16955,7 @@
16899
16955
  "get": {
16900
16956
  "tags": ["ShopBite"],
16901
16957
  "summary": "Get ShopBite configuration",
16902
- "description": "Retrieves ShopBite configuration including checkout status and delivery time",
16958
+ "description": "Retrieves ShopBite configuration including checkout status and the fulfillment and lead time of each shipping method",
16903
16959
  "operationId": "shopbite.config.get",
16904
16960
  "parameters": [],
16905
16961
  "responses": {
@@ -5358,12 +5358,31 @@ export type Schemas = {
5358
5358
  readonly updatedAt?: string;
5359
5359
  };
5360
5360
  ShopBiteConfig: {
5361
- /** Default delivery time in minutes */
5362
- deliveryTime: number;
5361
+ /** City of the shop, null if not configured */
5362
+ addressCity?: string | null;
5363
+ /** Postal code of the shop, null if not configured */
5364
+ addressPostalCode?: string | null;
5365
+ /** Street and number of the shop, null if not configured */
5366
+ addressStreet?: string | null;
5367
+ /**
5368
+ * Format: uri
5369
+ * Link to the shop's Google Business Profile, null if not configured
5370
+ */
5371
+ googleBusinessProfileUrl?: string | null;
5363
5372
  /** Whether checkout is enabled for ShopBite */
5364
5373
  isCheckoutEnabled: boolean;
5365
- /** Root category of the menu: the configured menu category, else the navigation category of the sales channel (plugin 2026-10, missing in older plugins) */
5366
- menuCategoryId?: string;
5374
+ /** Root category of the menu: the configured menu category, else the navigation category of the sales channel */
5375
+ menuCategoryId: string;
5376
+ /** The active shipping methods of the sales channel with fulfillment and lead time (shipping method custom fields shopbite_fulfillment and shopbite_lead_time_minutes; without a value: delivery and 30 minutes) */
5377
+ shippingMethods: {
5378
+ /** @enum {string} */
5379
+ fulfillment: "delivery" | "pickup";
5380
+ id: string;
5381
+ /** Minutes until the order is delivered or ready for pickup */
5382
+ leadTimeMinutes: number;
5383
+ }[];
5384
+ /** Telephone number in display format (e.g. +49 123 456789), null if not configured */
5385
+ telephone?: string | null;
5367
5386
  };
5368
5387
  ShopBiteWishlistItem: {
5369
5388
  /** Format: date-time */
@@ -13,7 +13,9 @@ const emit = defineEmits<{
13
13
  (e: "update:valid", value: boolean): void;
14
14
  }>();
15
15
 
16
- const { deliveryTime } = useShopBiteConfig();
16
+ // Lead time and wording follow the selected shipping method (shopbite#6).
17
+ const { fulfillment, leadTime } = useShippingLeadTime();
18
+ const wording = computed(() => FULFILLMENT_WORDING[fulfillment.value]);
17
19
 
18
20
  const selected = ref<string>(props.modelValue ?? "");
19
21
  const now = ref<Date>(new Date());
@@ -90,7 +92,32 @@ function roundToNext5MinInterval(timeString: string | null): string {
90
92
  return `${newHours.toString().padStart(2, "0")}:${newMinutes.toString().padStart(2, "0")}`;
91
93
  }
92
94
 
93
- // Move initialization to a proper place
95
+ /**
96
+ * A 5-minute slot within min and max: rounded up, else the last slot before
97
+ * max. A clamped raw minimum such as 16:43 failed the 5-minute check.
98
+ */
99
+ function slotWithin(time: string, min: string, max: string): string {
100
+ const rounded = roundToNext5MinInterval(time);
101
+ if (rounded <= max) return rounded;
102
+ const parts = max.split(":").map(Number);
103
+ const total = Math.floor(((parts[0] ?? 0) * 60 + (parts[1] ?? 0)) / 5) * 5;
104
+ const last = `${Math.floor(total / 60)
105
+ .toString()
106
+ .padStart(2, "0")}:${(total % 60).toString().padStart(2, "0")}`;
107
+ return last >= min ? last : rounded;
108
+ }
109
+
110
+ // Whether the time is the one filled in here (earliest slot), not one the
111
+ // guest chose: it follows the earliest slot, e.g. to an earlier one after a
112
+ // switch from delivery to pickup (shopbite#6).
113
+ const isPrefilled = ref(false);
114
+
115
+ function setSelected(time: string): void {
116
+ if (time === selected.value) return;
117
+ selected.value = time;
118
+ emit("update:modelValue", time);
119
+ }
120
+
94
121
  watch(
95
122
  [minTime, maxTime],
96
123
  () => {
@@ -102,26 +129,20 @@ watch(
102
129
  return;
103
130
  }
104
131
 
105
- if (!selected.value) {
106
- selected.value = roundToNext5MinInterval(minTime.value);
107
- emit("update:modelValue", selected.value);
132
+ if (!selected.value || isPrefilled.value) {
133
+ setSelected(slotWithin(minTime.value, minTime.value, maxTime.value));
134
+ isPrefilled.value = true;
108
135
  return;
109
136
  }
110
137
 
111
- if (
112
- selected.value &&
113
- !isTimeWithinBounds(selected.value, minTime.value, maxTime.value)
114
- ) {
138
+ if (!isTimeWithinBounds(selected.value, minTime.value, maxTime.value)) {
115
139
  const clampedTime = clampTimeToInterval(
116
140
  selected.value,
117
141
  minTime.value,
118
142
  maxTime.value,
119
143
  now.value,
120
144
  );
121
- if (clampedTime !== selected.value) {
122
- selected.value = clampedTime;
123
- emit("update:modelValue", clampedTime);
124
- }
145
+ setSelected(slotWithin(clampedTime, minTime.value, maxTime.value));
125
146
  }
126
147
  },
127
148
  { immediate: true },
@@ -129,6 +150,7 @@ watch(
129
150
 
130
151
  function handleTimeInput(event: Event): void {
131
152
  const value = (event.target as HTMLInputElement).value;
153
+ isPrefilled.value = false;
132
154
  selected.value = value;
133
155
  emit("update:modelValue", value || null);
134
156
  }
@@ -147,7 +169,7 @@ function handleTimeInput(event: Event): void {
147
169
  <strong class="block"
148
170
  >Öffnungszeiten konnten nicht geladen werden</strong
149
171
  >
150
- Ohne Öffnungszeiten können wir keine Lieferzeit anbieten.
172
+ Ohne Öffnungszeiten können wir keine {{ wording.time }} anbieten.
151
173
  </span>
152
174
  <SbButton variant="secondary" @click="retryOpeningHours"
153
175
  >Erneut versuchen</SbButton
@@ -164,7 +186,7 @@ function handleTimeInput(event: Event): void {
164
186
  <SbField
165
187
  id="delivery-time"
166
188
  v-slot="{ id, describedBy, invalid }"
167
- label="Wunschzeit für Lieferung oder Abholung, frühestens"
189
+ :label="wording.wishedTime"
168
190
  :hint="validationError ? undefined : helperText"
169
191
  :error="validationError ?? undefined"
170
192
  >
@@ -184,9 +206,8 @@ function handleTimeInput(event: Event): void {
184
206
  />
185
207
  </ClientOnly>
186
208
  </SbField>
187
- <p class="text-sm text-sb-ink-muted">
188
- Lieferzeit ca. {{ deliveryTime }} Minuten, zu Stoßzeiten kann es etwas
189
- länger dauern.
209
+ <p v-if="leadTime !== null" class="text-sm text-sb-ink-muted">
210
+ {{ wording.leadTimeHint(leadTime) }}
190
211
  </p>
191
212
  </template>
192
213
  <p v-else class="text-sm text-sb-ink-muted" aria-busy="true">
@@ -9,6 +9,7 @@ const { refreshCart } = useCart();
9
9
  const { isLoggedIn, isGuestSession, refreshUser } = useUser();
10
10
  const { isCheckoutEnabled, refresh, checkCheckoutEnabled } =
11
11
  useShopBiteConfig();
12
+ const { fulfillment } = useShippingLeadTime();
12
13
  const { trackOrder } = useTrackEvent();
13
14
  const { isLoading: isLoadingOpeningHours, hasFailed: hasOpeningHoursFailed } =
14
15
  useOpeningHoursData();
@@ -121,7 +122,10 @@ async function handleCreateOrder() {
121
122
  if (!(await hasAvailableCheckoutMethods())) return;
122
123
 
123
124
  const order = await createOrder({
124
- customerComment: "Wunschlieferzeit: " + selectedDeliveryTime.value,
125
+ customerComment: wishedTimeComment(
126
+ fulfillment.value,
127
+ selectedDeliveryTime.value,
128
+ ),
125
129
  });
126
130
 
127
131
  trackOrder(order);
@@ -4,7 +4,7 @@ export type FeatureCardProps = {
4
4
  title: string;
5
5
  description: string;
6
6
  icon?: string;
7
- kind?: "hours" | "delivery" | "reservation";
7
+ kind?: "hours" | "delivery" | "pickup" | "reservation";
8
8
  lead?: string;
9
9
  link?: { label: string; to: string };
10
10
  };
@@ -12,12 +12,13 @@ export type FeatureCardProps = {
12
12
  /**
13
13
  * Facts row under the hero of the presets (#444): the `features` of
14
14
  * content/index.yml as four columns with a strong top rule. Today's hours
15
- * and the delivery time are live, like on the feature cards (#332).
15
+ * and the delivery and pickup times are live, like on the feature cards
16
+ * (#332, shopbite#6).
16
17
  */
17
18
  const props = defineProps<{ features: FeatureCardProps[] }>();
18
19
 
19
20
  const { businessHours } = useBusinessHours();
20
- const { deliveryTime } = useShopBiteConfig();
21
+ const { deliveryTime, pickupTime } = useShopBiteConfig();
21
22
 
22
23
  const items = computed(() =>
23
24
  props.features.map((feature) => {
@@ -25,9 +26,13 @@ const items = computed(() =>
25
26
  if (feature.kind === "hours" && businessHours.value) {
26
27
  lead = formatTodayHours(businessHours.value, new Date());
27
28
  }
28
- if (feature.kind === "delivery") {
29
+ // lead times of the delivery and pickup methods (shopbite#6)
30
+ if (feature.kind === "delivery" && deliveryTime.value !== null) {
29
31
  lead = `In ca. ${deliveryTime.value} Minuten bei Ihnen`;
30
32
  }
33
+ if (feature.kind === "pickup" && pickupTime.value !== null) {
34
+ lead = `Abholbereit in ca. ${pickupTime.value} Minuten`;
35
+ }
31
36
  return { ...feature, lead };
32
37
  }),
33
38
  );
@@ -42,7 +42,8 @@ const rating = computed(() => {
42
42
  });
43
43
 
44
44
  const { status } = useStoreStatus();
45
- const { deliveryTime } = useShopBiteConfig();
45
+ // lead times of the delivery and pickup methods (shopbite#6)
46
+ const { deliveryTime, pickupTime } = useShopBiteConfig();
46
47
 
47
48
  const statusLabel = computed(() => {
48
49
  if (!status.value) return "";
@@ -120,7 +121,12 @@ const BLANK =
120
121
  />
121
122
  {{ statusLabel }}
122
123
  </span>
123
- <span>Lieferung ca. {{ deliveryTime }} Min</span>
124
+ <span v-if="deliveryTime !== null"
125
+ >Lieferung ca. {{ deliveryTime }} Min</span
126
+ >
127
+ <span v-if="pickupTime !== null"
128
+ >Abholung ca. {{ pickupTime }} Min</span
129
+ >
124
130
  </p>
125
131
  <template #fallback>
126
132
  <span class="h-6" aria-hidden="true" />
@@ -33,10 +33,9 @@ const shippingMethod = computed(() => {
33
33
  const method = props.order.deliveries?.[0]?.shippingMethod;
34
34
  return method?.translated?.name ?? method?.name;
35
35
  });
36
- // The checkout stores the chosen time as "Wunschlieferzeit: …" (Summary.vue).
37
- const wishedTime = computed(() =>
38
- props.order.customerComment?.replace(/^Wunschlieferzeit:\s*/, "").trim(),
39
- );
36
+ // The checkout stores the chosen time as "Wunschlieferzeit: …" or
37
+ // "Wunschabholzeit: …" (Summary.vue, wishedTimeComment).
38
+ const wishedTime = computed(() => parseWishedTime(props.order.customerComment));
40
39
 
41
40
  // Restaurants sell gross prices; net orders (B2B) list the tax on top.
42
41
  const taxLabel = computed(() =>
@@ -10,7 +10,8 @@ function isTimeWithinBounds(
10
10
  }
11
11
 
12
12
  export function useDeliveryTime(now: Ref<Date>) {
13
- const { deliveryTime } = useShopBiteConfig();
13
+ // lead time of the selected shipping method (shopbite#6)
14
+ const { leadTime, fulfillment } = useShippingLeadTime();
14
15
  const {
15
16
  getServiceIntervals,
16
17
  getEarliestSelectableTime,
@@ -19,12 +20,14 @@ export function useDeliveryTime(now: Ref<Date>) {
19
20
  } = useBusinessHours();
20
21
  const { isClosedHoliday } = useHolidays();
21
22
 
23
+ const wording = computed(() => FULFILLMENT_WORDING[fulfillment.value]);
24
+
22
25
  const earliest = computed<Date>(() =>
23
- getEarliestSelectableTime(now.value, deliveryTime.value),
26
+ getEarliestSelectableTime(now.value, leadTime.value),
24
27
  );
25
28
 
26
29
  const activeInterval = computed<ServiceInterval | null>(() =>
27
- findActiveInterval(now.value, deliveryTime.value),
30
+ findActiveInterval(now.value, leadTime.value),
28
31
  );
29
32
 
30
33
  const minTime = computed<string | null>(() => {
@@ -76,9 +79,9 @@ export function useDeliveryTime(now: Ref<Date>) {
76
79
  const intervals = getServiceIntervals(now.value);
77
80
  const lastInterval = intervals.at(-1);
78
81
  if (lastInterval && earliest.value > lastInterval.end) {
79
- return "Heute sind keine Lieferzeiten mehr verfügbar.";
82
+ return `Heute sind keine ${wording.value.times} mehr verfügbar.`;
80
83
  }
81
- return "Aktuell keine Lieferzeit verfügbar. Bitte später erneut versuchen.";
84
+ return `Aktuell keine ${wording.value.time} verfügbar. Bitte später erneut versuchen.`;
82
85
  }
83
86
 
84
87
  const startStr = toTimeString(interval.start);
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Fulfillment (delivery or pickup) and lead time of the shipping method
3
+ * selected in the checkout (shopbite#6), from `shippingMethods` of the
4
+ * plugin configuration. Switching the method updates both. Before the
5
+ * configuration is loaded it is a delivery without a lead time.
6
+ */
7
+ export function useShippingLeadTime() {
8
+ const { selectedShippingMethod } = useCheckout();
9
+ const { leadTimeFor } = useShopBiteConfig();
10
+
11
+ const current = computed(() => leadTimeFor(selectedShippingMethod.value));
12
+
13
+ return {
14
+ fulfillment: computed(() => current.value.fulfillment),
15
+ leadTime: computed(() => current.value.minutes),
16
+ };
17
+ }
@@ -51,9 +51,18 @@ export function useShopBiteConfig() {
51
51
  return data.value?.isCheckoutEnabled ?? false;
52
52
  }
53
53
 
54
+ /** Fulfillment and lead time of a shipping method (shopbite#6). */
55
+ function leadTimeFor(method: { id?: string } | null | undefined): LeadTime {
56
+ return shippingLeadTime(data.value, method);
57
+ }
58
+
54
59
  return {
55
60
  checkCheckoutEnabled,
56
- deliveryTime: computed(() => data.value?.deliveryTime ?? 30),
61
+ leadTimeFor,
62
+ /** Lead time of the delivery method, `null` without one. */
63
+ deliveryTime: computed(() => fulfillmentLeadTime(data.value, "delivery")),
64
+ /** Lead time of the pickup method, `null` without one. */
65
+ pickupTime: computed(() => fulfillmentLeadTime(data.value, "pickup")),
57
66
  isCheckoutEnabled: computed(() => data.value?.isCheckoutEnabled ?? false),
58
67
  refresh,
59
68
  };
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Lead times per shipping method (shopbite#6): the ShopBite plugin reports
3
+ * for every active shipping method of the sales channel whether it is a
4
+ * delivery or a pickup and how many minutes the kitchen needs
5
+ * (`shippingMethods` of `/store-api/shopbite/config`). Also imported by the
6
+ * server (llms.txt), so it stays free of Nuxt imports.
7
+ */
8
+ export type Fulfillment = "delivery" | "pickup";
9
+
10
+ export type ShippingMethodLeadTime = {
11
+ id: string;
12
+ fulfillment: Fulfillment;
13
+ leadTimeMinutes: number;
14
+ };
15
+
16
+ export type LeadTimeConfig =
17
+ | { shippingMethods?: readonly ShippingMethodLeadTime[] | null }
18
+ | null
19
+ | undefined;
20
+
21
+ export type LeadTime = { fulfillment: Fulfillment; minutes: number | null };
22
+
23
+ /**
24
+ * Fulfillment and lead time of a shipping method. A method the plugin does
25
+ * not list (or none, or no configuration yet) counts as delivery without a
26
+ * lead time.
27
+ */
28
+ export function shippingLeadTime(
29
+ config: LeadTimeConfig,
30
+ method: { id?: string } | null | undefined,
31
+ ): LeadTime {
32
+ const entry = method?.id
33
+ ? config?.shippingMethods?.find((item) => item.id === method.id)
34
+ : undefined;
35
+ return entry
36
+ ? { fulfillment: entry.fulfillment, minutes: entry.leadTimeMinutes }
37
+ : { fulfillment: "delivery", minutes: null };
38
+ }
39
+
40
+ /**
41
+ * Lead time of the first shipping method of a fulfillment, for texts that
42
+ * are not about a selected method (home page, llms.txt); `null` when the
43
+ * sales channel has no such method.
44
+ */
45
+ export function fulfillmentLeadTime(
46
+ config: LeadTimeConfig,
47
+ fulfillment: Fulfillment,
48
+ ): number | null {
49
+ return (
50
+ config?.shippingMethods?.find((item) => item.fulfillment === fulfillment)
51
+ ?.leadTimeMinutes ?? null
52
+ );
53
+ }
54
+
55
+ /** German wording of the time choice per fulfillment. */
56
+ export const FULFILLMENT_WORDING = {
57
+ delivery: {
58
+ wishedTime: "Wunschlieferzeit",
59
+ time: "Lieferzeit",
60
+ times: "Lieferzeiten",
61
+ leadTimeHint: (minutes: number) =>
62
+ `Lieferzeit ca. ${minutes} Minuten, zu Stoßzeiten kann es etwas länger dauern.`,
63
+ },
64
+ pickup: {
65
+ wishedTime: "Wunschabholzeit",
66
+ time: "Abholzeit",
67
+ times: "Abholzeiten",
68
+ leadTimeHint: (minutes: number) =>
69
+ `Abholbereit in ca. ${minutes} Minuten, zu Stoßzeiten kann es etwas länger dauern.`,
70
+ },
71
+ } as const satisfies Record<Fulfillment, unknown>;
72
+
73
+ /**
74
+ * The order's customer comment carries the wished time, e.g.
75
+ * "Wunschabholzeit: 18:40" (read by the receipt printer and the backoffice).
76
+ */
77
+ export function wishedTimeComment(
78
+ fulfillment: Fulfillment,
79
+ time: string,
80
+ ): string {
81
+ return `${FULFILLMENT_WORDING[fulfillment].wishedTime}: ${time}`;
82
+ }
83
+
84
+ /**
85
+ * The wished time of a customer comment; both prefixes are accepted (orders
86
+ * before shopbite#6 always say "Wunschlieferzeit"). Other comments are
87
+ * returned as they are.
88
+ */
89
+ export function parseWishedTime(
90
+ comment: string | null | undefined,
91
+ ): string | undefined {
92
+ if (!comment) return undefined;
93
+ return comment
94
+ .trim()
95
+ .replace(/^Wunsch(?:liefer|abhol)zeit:\s*/, "")
96
+ .trim();
97
+ }
package/content.config.ts CHANGED
@@ -42,9 +42,9 @@ const createFeatureSchema = () =>
42
42
  createBaseSchema().extend({
43
43
  icon: z.string().editor({ input: "icon" }),
44
44
  // Information cards on the home page (#332): `kind` fills the lead line
45
- // with live data (today's hours, delivery time), `lead` is the static
45
+ // with live data (today's hours, delivery or pickup time), `lead` is the static
46
46
  // alternative, `link` the card's action (a `tel:` target is a button).
47
- kind: createEnum(["hours", "delivery", "reservation"]).optional(),
47
+ kind: createEnum(["hours", "delivery", "pickup", "reservation"]).optional(),
48
48
  lead: z.string().optional(),
49
49
  link: z
50
50
  .object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopbite-de/storefront",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "main": "nuxt.config.ts",
5
5
  "description": "Shopware storefront for food delivery shops",
6
6
  "keywords": [
@@ -53,7 +53,7 @@
53
53
  "@typescript-eslint/eslint-plugin": "^8.73.0",
54
54
  "@typescript-eslint/parser": "^8.73.0",
55
55
  "@vitejs/plugin-vue": "^6.0.11",
56
- "@vitest/ui": "5.1.0",
56
+ "@vitest/ui": "5.1.1",
57
57
  "@vue/compiler-dom": "^3.5.45",
58
58
  "@vue/server-renderer": "^3.5.45",
59
59
  "@vue/test-utils": "^2.6.0",
@@ -1,5 +1,5 @@
1
1
  /**
2
- * ShopBite plugin configuration (delivery time, checkout switch, menu root)
2
+ * ShopBite plugin configuration (lead times, checkout switch, menu root)
3
3
  * for server-side rendering, cached `cacheTtl.config` (shopBiteConfig). The
4
4
  * browser loads it from Shopware again after hydration (useLiveShopData).
5
5
  */
@@ -2,6 +2,7 @@ import { queryCollection } from "@nuxt/content/server";
2
2
  import { defineEventHandler } from "nuxt/server";
3
3
  import type { components } from "~~/api-types/storeApiTypes";
4
4
  import { getDiets, getMainIngredients } from "../../app/utils/product";
5
+ import { fulfillmentLeadTime } from "../../app/utils/leadTime";
5
6
  import { productDeepLink } from "../../app/utils/productUrl";
6
7
  import { splitList, toAbsoluteUrl } from "../../app/utils/seo";
7
8
  import { buildLlmsTxt, type LlmsMenuSection } from "../utils/llmsTxt";
@@ -87,9 +88,7 @@ export default defineEventHandler(async (event) => {
87
88
  storeApi<{ holidays?: { start?: string; end?: string }[] }>(
88
89
  "/shopbite/holiday",
89
90
  ),
90
- storeApi<{ isCheckoutEnabled?: boolean; deliveryTime?: number }>(
91
- "/shopbite/config",
92
- ),
91
+ storeApi<Schemas["ShopBiteConfig"]>("/shopbite/config"),
93
92
  storeApi<Schemas["SalesChannelContext"]>("/context"),
94
93
  queryCollection(event, "landingpages")
95
94
  .select("path", "title", "description")
@@ -135,7 +134,9 @@ export default defineEventHandler(async (event) => {
135
134
  businessHours: value(hours)?.businessHours,
136
135
  holidays: value(holidays)?.holidays,
137
136
  isCheckoutEnabled: value(config)?.isCheckoutEnabled,
138
- deliveryTime: value(config)?.deliveryTime,
137
+ // lead times of the delivery and pickup methods (shopbite#6)
138
+ deliveryTime: fulfillmentLeadTime(value(config), "delivery"),
139
+ pickupTime: fulfillmentLeadTime(value(config), "pickup"),
139
140
  menuUrl: toAbsoluteUrl(siteUrl, "/speisekarte"),
140
141
  menu: (value(navigation) ?? [])
141
142
  .filter((category) => category.type === "page")
@@ -40,8 +40,10 @@ export type LlmsTxtInput = {
40
40
  }[];
41
41
  holidays?: { start?: string; end?: string }[];
42
42
  isCheckoutEnabled?: boolean;
43
- /** Minutes until delivery. */
44
- deliveryTime?: number;
43
+ /** Minutes until delivery (lead time of the delivery method). */
44
+ deliveryTime?: number | null;
45
+ /** Minutes until an order is ready for pickup (pickup method). */
46
+ pickupTime?: number | null;
45
47
  menuUrl?: string;
46
48
  menu?: LlmsMenuSection[];
47
49
  pages?: { title: string; url: string; description?: string }[];
@@ -169,7 +171,9 @@ export function buildLlmsTxt(input: LlmsTxtInput): string {
169
171
  input.deliveryTime
170
172
  ? `- Lieferzeit: ca. ${input.deliveryTime} Minuten`
171
173
  : undefined,
172
- input.address?.street ? "- Abholung im Restaurant möglich" : undefined,
174
+ input.address?.street
175
+ ? `- Abholung im Restaurant möglich${input.pickupTime ? `, abholbereit in ca. ${input.pickupTime} Minuten` : ""}`
176
+ : undefined,
173
177
  ].filter((line): line is string => Boolean(line))
174
178
  : [];
175
179
 
@@ -19,7 +19,7 @@ const cachedConfig = defineCachedFunction(
19
19
  const load = createResilientLoader<ShopBiteConfig>();
20
20
 
21
21
  /**
22
- * The ShopBite plugin configuration (delivery time, checkout switch, menu
22
+ * The ShopBite plugin configuration (lead times, checkout switch, menu
23
23
  * root) for server-side rendering, `/api/shopbite/config` and the menu root.
24
24
  * When Shopware fails, the last good configuration is kept (the menu stays
25
25
  * on its root) and Shopware is asked again only after a pause, so an outage
@@ -36,10 +36,13 @@ mockNuxtImport("useUser", () => () => ({
36
36
  }));
37
37
  mockNuxtImport("useShopBiteConfig", () => () => ({
38
38
  isCheckoutEnabled: ref(true),
39
- deliveryTime: ref(30),
40
39
  refresh: vi.fn(),
41
40
  checkCheckoutEnabled: vi.fn().mockResolvedValue(true),
42
41
  }));
42
+ mockNuxtImport("useShippingLeadTime", () => () => ({
43
+ fulfillment: ref("delivery"),
44
+ leadTime: ref(30),
45
+ }));
43
46
  mockNuxtImport("useTrackEvent", () => () => ({ trackOrder: vi.fn() }));
44
47
  mockNuxtImport("useCheckoutMethodGuard", () => () => ({
45
48
  isShippingMethodBlocked: ref(false),