@atomic-solutions/woocommerce-react 0.6.1 → 0.7.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.
@@ -1,8 +1,8 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import { UseQueryOptions, UseInfiniteQueryOptions, InfiniteData, UseMutationOptions } from '@tanstack/react-query';
3
3
  import * as _atomic_solutions_woocommerce_api_client from '@atomic-solutions/woocommerce-api-client';
4
- import { WooCommerceClient, ProductCategory, ProductParams, PaginatedResponse, Product, Cart, Checkout, GetOrderInput, StoreApiOrder, ProductImage, CartItemImage, CartItem } from '@atomic-solutions/woocommerce-api-client';
5
- import { Q as QueryKeys, k as StoreContextValue, l as StoreFeatures, S as StoreLocale, n as StoreTheme } from './types-Dnq60zh-.js';
4
+ import { WooCommerceClient, ProductCategory, ProductParams, PaginatedResponse, Product, ProductTagsParams, ProductTag, Cart, Checkout, GetOrderInput, StoreApiOrder, ProductImage, CartItemImage, CartItem } from '@atomic-solutions/woocommerce-api-client';
5
+ import { Q as QueryKeys, k as StoreContextValue, l as StoreFeatures, S as StoreLocale, n as StoreTheme } from './types-4MW3Y__g.js';
6
6
 
7
7
  type QueryOptions<TData, TError = Error> = Omit<UseQueryOptions<TData, TError>, 'queryKey' | 'queryFn'>;
8
8
  type MutationOptions<TData, TError = Error, TVariables = unknown> = Omit<UseMutationOptions<TData, TError, TVariables>, 'mutationFn'>;
@@ -2933,6 +2933,11 @@ declare const useProductCategories: (options?: QueryOptions<ProductCategory[]>)
2933
2933
  count: number;
2934
2934
  menu_order?: number | undefined;
2935
2935
  }[], Error>;
2936
+ declare const useProductTags: (params?: ProductTagsParams, options?: QueryOptions<ProductTag[]>) => _tanstack_react_query.UseQueryResult<{
2937
+ id: number;
2938
+ name: string;
2939
+ slug: string;
2940
+ }[], Error>;
2936
2941
  declare const useProductCategoryTree: () => {
2937
2942
  data: {
2938
2943
  id: number;
@@ -8333,7 +8338,7 @@ declare const useCheckout: (options?: QueryOptions<Checkout>) => _tanstack_react
8333
8338
  payment_status: string;
8334
8339
  payment_details: unknown[];
8335
8340
  redirect_url: string;
8336
- };
8341
+ } | null;
8337
8342
  }, Error>;
8338
8343
  declare const useProcessCheckout: () => _tanstack_react_query.UseMutationResult<{
8339
8344
  status: string;
@@ -8371,7 +8376,7 @@ declare const useProcessCheckout: () => _tanstack_react_query.UseMutationResult<
8371
8376
  payment_status: string;
8372
8377
  payment_details: unknown[];
8373
8378
  redirect_url: string;
8374
- };
8379
+ } | null;
8375
8380
  }, Error, {
8376
8381
  payment_method: string;
8377
8382
  extensions?: Record<string, unknown> | undefined;
@@ -8807,6 +8812,8 @@ interface ProcessedOrderDetails {
8807
8812
  }
8808
8813
  interface UseOrderViewOptions {
8809
8814
  localeTag?: string;
8815
+ fallbackImageUrl?: string;
8816
+ imageSize?: ImageSize;
8810
8817
  }
8811
8818
  interface UseOrderViewReturn {
8812
8819
  order: ProcessedOrderDetails | undefined;
@@ -8815,4 +8822,4 @@ interface UseOrderViewReturn {
8815
8822
  }
8816
8823
  declare function useOrderView(input: GetOrderInput, options?: UseOrderViewOptions): UseOrderViewReturn;
8817
8824
 
8818
- export { useOrderView as $, type AppliedCoupon as A, getImageUrlOrPlaceholder as B, type CartTotals as C, getMaxAddToCartQuantity as D, getOrderStatusLabel as E, getPrimaryImage as F, getSizedImageUrl as G, getStockSeverity as H, type ImageSize as I, getStockStatusText as J, isLowStock as K, isPurchasable as L, preloadImage as M, preloadImages as N, unavailableReason as O, PLACEHOLDER_IMAGE_URL as P, useAddManyToCart as Q, type ReorderInputItem as R, type ShippingRate as S, useAddToCart as T, type UnavailableReason as U, useApplyCoupon as V, useCart as W, useCartView as X, useCheckout as Y, useInfiniteProducts as Z, useOrder as _, type PaymentMethod as a, useProcessCheckout as a0, useProduct as a1, useProductCategories as a2, useProductCategoryTree as a3, useProductView as a4, useProducts as a5, useProductsFeed as a6, useRemoveCoupon as a7, useRemoveFromCart as a8, useReorderView as a9, useSelectShippingRate as aa, useStore as ab, useStoreFeatures as ac, useStoreLocale as ad, useStoreTheme as ae, useUpdateCartItem as af, useUpdateCustomer as ag, useWooCommerceClient as ah, useWooCommerceQueryKeys as ai, type InfiniteQueryOptions as aj, type MutationOptions as ak, type QueryOptions as al, type ProcessedCartItem as b, type ProcessedCategory as c, type ProcessedOrderDetails as d, type ProcessedOrderLineItem as e, type ProcessedProduct as f, type ProcessedProductDetails as g, type ProductCartState as h, type ProductCategoryTreeNode as i, type ReorderItemView as j, type ReorderUnavailableReason as k, type StockDisplayConfig as l, type StockStatus as m, type UseCartViewOptions as n, type UseCartViewReturn as o, type UseOrderViewOptions as p, type UseOrderViewReturn as q, type UseProductViewOptions as r, type UseProductViewReturn as s, type UseProductsFeedOptions as t, type UseProductsFeedReturn as u, type UseReorderViewOptions as v, type UseReorderViewReturn as w, canAddToCart as x, getAllImageUrls as y, getImageUrl as z };
8825
+ export { useOrderView as $, type AppliedCoupon as A, getImageUrlOrPlaceholder as B, type CartTotals as C, getMaxAddToCartQuantity as D, getOrderStatusLabel as E, getPrimaryImage as F, getSizedImageUrl as G, getStockSeverity as H, type ImageSize as I, getStockStatusText as J, isLowStock as K, isPurchasable as L, preloadImage as M, preloadImages as N, unavailableReason as O, PLACEHOLDER_IMAGE_URL as P, useAddManyToCart as Q, type ReorderInputItem as R, type ShippingRate as S, useAddToCart as T, type UnavailableReason as U, useApplyCoupon as V, useCart as W, useCartView as X, useCheckout as Y, useInfiniteProducts as Z, useOrder as _, type PaymentMethod as a, useProcessCheckout as a0, useProduct as a1, useProductCategories as a2, useProductCategoryTree as a3, useProductTags as a4, useProductView as a5, useProducts as a6, useProductsFeed as a7, useRemoveCoupon as a8, useRemoveFromCart as a9, useReorderView as aa, useSelectShippingRate as ab, useStore as ac, useStoreFeatures as ad, useStoreLocale as ae, useStoreTheme as af, useUpdateCartItem as ag, useUpdateCustomer as ah, useWooCommerceClient as ai, useWooCommerceQueryKeys as aj, type InfiniteQueryOptions as ak, type MutationOptions as al, type QueryOptions as am, type ProcessedCartItem as b, type ProcessedCategory as c, type ProcessedOrderDetails as d, type ProcessedOrderLineItem as e, type ProcessedProduct as f, type ProcessedProductDetails as g, type ProductCartState as h, type ProductCategoryTreeNode as i, type ReorderItemView as j, type ReorderUnavailableReason as k, type StockDisplayConfig as l, type StockStatus as m, type UseCartViewOptions as n, type UseCartViewReturn as o, type UseOrderViewOptions as p, type UseOrderViewReturn as q, type UseProductViewOptions as r, type UseProductViewReturn as s, type UseProductsFeedOptions as t, type UseProductsFeedReturn as u, type UseReorderViewOptions as v, type UseReorderViewReturn as w, canAddToCart as x, getAllImageUrls as y, getImageUrl as z };
@@ -1,8 +1,8 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import { UseQueryOptions, UseInfiniteQueryOptions, InfiniteData, UseMutationOptions } from '@tanstack/react-query';
3
3
  import * as _atomic_solutions_woocommerce_api_client from '@atomic-solutions/woocommerce-api-client';
4
- import { WooCommerceClient, ProductCategory, ProductParams, PaginatedResponse, Product, Cart, Checkout, GetOrderInput, StoreApiOrder, ProductImage, CartItemImage, CartItem } from '@atomic-solutions/woocommerce-api-client';
5
- import { Q as QueryKeys, k as StoreContextValue, l as StoreFeatures, S as StoreLocale, n as StoreTheme } from './types-Dnq60zh-.cjs';
4
+ import { WooCommerceClient, ProductCategory, ProductParams, PaginatedResponse, Product, ProductTagsParams, ProductTag, Cart, Checkout, GetOrderInput, StoreApiOrder, ProductImage, CartItemImage, CartItem } from '@atomic-solutions/woocommerce-api-client';
5
+ import { Q as QueryKeys, k as StoreContextValue, l as StoreFeatures, S as StoreLocale, n as StoreTheme } from './types-4MW3Y__g.cjs';
6
6
 
7
7
  type QueryOptions<TData, TError = Error> = Omit<UseQueryOptions<TData, TError>, 'queryKey' | 'queryFn'>;
8
8
  type MutationOptions<TData, TError = Error, TVariables = unknown> = Omit<UseMutationOptions<TData, TError, TVariables>, 'mutationFn'>;
@@ -2933,6 +2933,11 @@ declare const useProductCategories: (options?: QueryOptions<ProductCategory[]>)
2933
2933
  count: number;
2934
2934
  menu_order?: number | undefined;
2935
2935
  }[], Error>;
2936
+ declare const useProductTags: (params?: ProductTagsParams, options?: QueryOptions<ProductTag[]>) => _tanstack_react_query.UseQueryResult<{
2937
+ id: number;
2938
+ name: string;
2939
+ slug: string;
2940
+ }[], Error>;
2936
2941
  declare const useProductCategoryTree: () => {
2937
2942
  data: {
2938
2943
  id: number;
@@ -8333,7 +8338,7 @@ declare const useCheckout: (options?: QueryOptions<Checkout>) => _tanstack_react
8333
8338
  payment_status: string;
8334
8339
  payment_details: unknown[];
8335
8340
  redirect_url: string;
8336
- };
8341
+ } | null;
8337
8342
  }, Error>;
8338
8343
  declare const useProcessCheckout: () => _tanstack_react_query.UseMutationResult<{
8339
8344
  status: string;
@@ -8371,7 +8376,7 @@ declare const useProcessCheckout: () => _tanstack_react_query.UseMutationResult<
8371
8376
  payment_status: string;
8372
8377
  payment_details: unknown[];
8373
8378
  redirect_url: string;
8374
- };
8379
+ } | null;
8375
8380
  }, Error, {
8376
8381
  payment_method: string;
8377
8382
  extensions?: Record<string, unknown> | undefined;
@@ -8807,6 +8812,8 @@ interface ProcessedOrderDetails {
8807
8812
  }
8808
8813
  interface UseOrderViewOptions {
8809
8814
  localeTag?: string;
8815
+ fallbackImageUrl?: string;
8816
+ imageSize?: ImageSize;
8810
8817
  }
8811
8818
  interface UseOrderViewReturn {
8812
8819
  order: ProcessedOrderDetails | undefined;
@@ -8815,4 +8822,4 @@ interface UseOrderViewReturn {
8815
8822
  }
8816
8823
  declare function useOrderView(input: GetOrderInput, options?: UseOrderViewOptions): UseOrderViewReturn;
8817
8824
 
8818
- export { useOrderView as $, type AppliedCoupon as A, getImageUrlOrPlaceholder as B, type CartTotals as C, getMaxAddToCartQuantity as D, getOrderStatusLabel as E, getPrimaryImage as F, getSizedImageUrl as G, getStockSeverity as H, type ImageSize as I, getStockStatusText as J, isLowStock as K, isPurchasable as L, preloadImage as M, preloadImages as N, unavailableReason as O, PLACEHOLDER_IMAGE_URL as P, useAddManyToCart as Q, type ReorderInputItem as R, type ShippingRate as S, useAddToCart as T, type UnavailableReason as U, useApplyCoupon as V, useCart as W, useCartView as X, useCheckout as Y, useInfiniteProducts as Z, useOrder as _, type PaymentMethod as a, useProcessCheckout as a0, useProduct as a1, useProductCategories as a2, useProductCategoryTree as a3, useProductView as a4, useProducts as a5, useProductsFeed as a6, useRemoveCoupon as a7, useRemoveFromCart as a8, useReorderView as a9, useSelectShippingRate as aa, useStore as ab, useStoreFeatures as ac, useStoreLocale as ad, useStoreTheme as ae, useUpdateCartItem as af, useUpdateCustomer as ag, useWooCommerceClient as ah, useWooCommerceQueryKeys as ai, type InfiniteQueryOptions as aj, type MutationOptions as ak, type QueryOptions as al, type ProcessedCartItem as b, type ProcessedCategory as c, type ProcessedOrderDetails as d, type ProcessedOrderLineItem as e, type ProcessedProduct as f, type ProcessedProductDetails as g, type ProductCartState as h, type ProductCategoryTreeNode as i, type ReorderItemView as j, type ReorderUnavailableReason as k, type StockDisplayConfig as l, type StockStatus as m, type UseCartViewOptions as n, type UseCartViewReturn as o, type UseOrderViewOptions as p, type UseOrderViewReturn as q, type UseProductViewOptions as r, type UseProductViewReturn as s, type UseProductsFeedOptions as t, type UseProductsFeedReturn as u, type UseReorderViewOptions as v, type UseReorderViewReturn as w, canAddToCart as x, getAllImageUrls as y, getImageUrl as z };
8825
+ export { useOrderView as $, type AppliedCoupon as A, getImageUrlOrPlaceholder as B, type CartTotals as C, getMaxAddToCartQuantity as D, getOrderStatusLabel as E, getPrimaryImage as F, getSizedImageUrl as G, getStockSeverity as H, type ImageSize as I, getStockStatusText as J, isLowStock as K, isPurchasable as L, preloadImage as M, preloadImages as N, unavailableReason as O, PLACEHOLDER_IMAGE_URL as P, useAddManyToCart as Q, type ReorderInputItem as R, type ShippingRate as S, useAddToCart as T, type UnavailableReason as U, useApplyCoupon as V, useCart as W, useCartView as X, useCheckout as Y, useInfiniteProducts as Z, useOrder as _, type PaymentMethod as a, useProcessCheckout as a0, useProduct as a1, useProductCategories as a2, useProductCategoryTree as a3, useProductTags as a4, useProductView as a5, useProducts as a6, useProductsFeed as a7, useRemoveCoupon as a8, useRemoveFromCart as a9, useReorderView as aa, useSelectShippingRate as ab, useStore as ac, useStoreFeatures as ad, useStoreLocale as ae, useStoreTheme as af, useUpdateCartItem as ag, useUpdateCustomer as ah, useWooCommerceClient as ai, useWooCommerceQueryKeys as aj, type InfiniteQueryOptions as ak, type MutationOptions as al, type QueryOptions as am, type ProcessedCartItem as b, type ProcessedCategory as c, type ProcessedOrderDetails as d, type ProcessedOrderLineItem as e, type ProcessedProduct as f, type ProcessedProductDetails as g, type ProductCartState as h, type ProductCategoryTreeNode as i, type ReorderItemView as j, type ReorderUnavailableReason as k, type StockDisplayConfig as l, type StockStatus as m, type UseCartViewOptions as n, type UseCartViewReturn as o, type UseOrderViewOptions as p, type UseOrderViewReturn as q, type UseProductViewOptions as r, type UseProductViewReturn as s, type UseProductsFeedOptions as t, type UseProductsFeedReturn as u, type UseReorderViewOptions as v, type UseReorderViewReturn as w, canAddToCart as x, getAllImageUrls as y, getImageUrl as z };
package/dist/index.cjs CHANGED
@@ -478,6 +478,8 @@ var StaleTimes = {
478
478
  product: STALE_TIME_SHORT,
479
479
  /** Product categories - always fresh */
480
480
  categories: STALE_TIME_NONE,
481
+ /** Product tags - names rarely change, 1 hour */
482
+ tags: STALE_TIME_LONG,
481
483
  /** Orders - always fresh */
482
484
  orders: STALE_TIME_NONE,
483
485
  /** Default for infinite queries - 1 hour */
@@ -575,6 +577,16 @@ var processCategoriesToTree = (data) => {
575
577
  });
576
578
  return rootCategories?.map(processCategory) ?? [];
577
579
  };
580
+ var useProductTags = (params, options) => {
581
+ const client = useWooCommerceClient();
582
+ const queryKeys = useWooCommerceQueryKeys();
583
+ return reactQuery.useQuery({
584
+ queryKey: queryKeys.products.tags(params),
585
+ queryFn: () => client.products.tags(params),
586
+ staleTime: StaleTimes.tags,
587
+ ...options
588
+ });
589
+ };
578
590
  var useProductCategoryTree = () => {
579
591
  const query = useProductCategories();
580
592
  const flatData = query.data ?? [];
@@ -895,7 +907,9 @@ var createQueryKeys = (prefix = ["woocommerce"]) => ({
895
907
  list: (params) => [...prefix, "products", "list", params],
896
908
  details: () => [...prefix, "products", "detail"],
897
909
  detail: (id) => [...prefix, "products", "detail", id],
898
- categories: () => [...prefix, "products", "categories"]
910
+ categories: () => [...prefix, "products", "categories"],
911
+ // Params are in the key, so each set of tag ids is cached apart.
912
+ tags: (params) => [...prefix, "products", "tags", params]
899
913
  },
900
914
  // Cart
901
915
  cart: {
@@ -979,64 +993,6 @@ function useStoreTheme(options = {}) {
979
993
  };
980
994
  }
981
995
 
982
- // src/utils/image.ts
983
- var SIZE_SUFFIXES = {
984
- thumbnail: "-150x150",
985
- medium: "-300x300",
986
- large: "-1024x1024",
987
- full: ""
988
- };
989
- function getPrimaryImage(images) {
990
- if (!images || images.length === 0) {
991
- return void 0;
992
- }
993
- return images[0];
994
- }
995
- function getImageUrl(images, size = "full", fallback) {
996
- const primary = getPrimaryImage(images);
997
- if (!primary) {
998
- return fallback;
999
- }
1000
- return getSizedImageUrl(primary.src, size);
1001
- }
1002
- function getSizedImageUrl(url, size = "full") {
1003
- if (!url || size === "full") {
1004
- return url;
1005
- }
1006
- const hasSize = Object.values(SIZE_SUFFIXES).some((suffix2) => suffix2 && url.includes(suffix2));
1007
- if (hasSize) {
1008
- let result = url;
1009
- Object.values(SIZE_SUFFIXES).forEach((suffix2) => {
1010
- if (suffix2) {
1011
- result = result.replace(suffix2, SIZE_SUFFIXES[size]);
1012
- }
1013
- });
1014
- return result;
1015
- }
1016
- const suffix = SIZE_SUFFIXES[size];
1017
- const lastDot = url.lastIndexOf(".");
1018
- if (lastDot === -1) {
1019
- return url;
1020
- }
1021
- return `${url.slice(0, lastDot)}${suffix}${url.slice(lastDot)}`;
1022
- }
1023
- function getAllImageUrls(images, size = "full") {
1024
- if (!images || images.length === 0) {
1025
- return [];
1026
- }
1027
- return images.map((img) => getSizedImageUrl(img.src, size));
1028
- }
1029
- var PLACEHOLDER_IMAGE_URL = "https://via.placeholder.com/300x300.png?text=No+Image";
1030
- function getImageUrlOrPlaceholder(images, size = "medium") {
1031
- return getImageUrl(images, size, PLACEHOLDER_IMAGE_URL) ?? PLACEHOLDER_IMAGE_URL;
1032
- }
1033
- async function preloadImage(_url) {
1034
- return Promise.resolve();
1035
- }
1036
- async function preloadImages(urls) {
1037
- await Promise.all(urls.map(preloadImage));
1038
- }
1039
-
1040
996
  // src/utils/price.ts
1041
997
  var DEFAULT_LOCALE = {
1042
998
  localeTag: "en-US",
@@ -1182,14 +1138,84 @@ function parseWooCommercePrice(priceString) {
1182
1138
  return parseFloat(cleaned.replace(/,/g, ""));
1183
1139
  }
1184
1140
 
1141
+ // src/utils/image.ts
1142
+ var SIZE_SUFFIXES = {
1143
+ thumbnail: "-150x150",
1144
+ medium: "-300x300",
1145
+ large: "-1024x1024",
1146
+ full: ""
1147
+ };
1148
+ function getPrimaryImage(images) {
1149
+ if (!images || images.length === 0) {
1150
+ return void 0;
1151
+ }
1152
+ return images[0];
1153
+ }
1154
+ function getImageUrl(images, size = "full", fallback) {
1155
+ const primary = getPrimaryImage(images);
1156
+ if (!primary) {
1157
+ return fallback;
1158
+ }
1159
+ return getSizedImageUrl(primary.src, size);
1160
+ }
1161
+ function getSizedImageUrl(url, size = "full") {
1162
+ if (!url || size === "full") {
1163
+ return url;
1164
+ }
1165
+ const hasSize = Object.values(SIZE_SUFFIXES).some((suffix2) => suffix2 && url.includes(suffix2));
1166
+ if (hasSize) {
1167
+ let result = url;
1168
+ Object.values(SIZE_SUFFIXES).forEach((suffix2) => {
1169
+ if (suffix2) {
1170
+ result = result.replace(suffix2, SIZE_SUFFIXES[size]);
1171
+ }
1172
+ });
1173
+ return result;
1174
+ }
1175
+ const suffix = SIZE_SUFFIXES[size];
1176
+ const lastDot = url.lastIndexOf(".");
1177
+ if (lastDot === -1) {
1178
+ return url;
1179
+ }
1180
+ return `${url.slice(0, lastDot)}${suffix}${url.slice(lastDot)}`;
1181
+ }
1182
+ function getAllImageUrls(images, size = "full") {
1183
+ if (!images || images.length === 0) {
1184
+ return [];
1185
+ }
1186
+ return images.map((img) => getSizedImageUrl(img.src, size));
1187
+ }
1188
+ var PLACEHOLDER_IMAGE_URL = "https://via.placeholder.com/300x300.png?text=No+Image";
1189
+ function getImageUrlOrPlaceholder(images, size = "medium") {
1190
+ return getImageUrl(images, size, PLACEHOLDER_IMAGE_URL) ?? PLACEHOLDER_IMAGE_URL;
1191
+ }
1192
+ async function preloadImage(_url) {
1193
+ return Promise.resolve();
1194
+ }
1195
+ async function preloadImages(urls) {
1196
+ await Promise.all(urls.map(preloadImage));
1197
+ }
1198
+
1199
+ // src/hooks/useProcessedImageUrl.ts
1200
+ var useProcessedImageUrl = (imageSize, fallbackOverride) => {
1201
+ const config = react.useContext(WooCommerceStoreContext)?.config;
1202
+ const transformer = config?.imageUrlTransformer;
1203
+ const fallbackImageUrl = fallbackOverride ?? config?.fallbackImageUrl;
1204
+ return react.useCallback(
1205
+ (images) => {
1206
+ const baseUrl = getImageUrl(images, imageSize, fallbackImageUrl);
1207
+ return baseUrl && transformer ? transformer(baseUrl, imageSize) : baseUrl;
1208
+ },
1209
+ [imageSize, fallbackImageUrl, transformer]
1210
+ );
1211
+ };
1212
+
1185
1213
  // src/hooks/useProductsFeed.ts
1186
1214
  function useProductsFeed(options = {}) {
1187
1215
  const { params, imageSize = "medium" } = options;
1188
1216
  const storeContext = react.useContext(WooCommerceStoreContext);
1189
1217
  const storeConfig = storeContext?.config;
1190
1218
  const localeTag = options.localeTag ?? storeConfig?.locale?.localeTag ?? DEFAULT_STORE_CONFIG.locale.localeTag;
1191
- const fallbackImageUrl = options.fallbackImageUrl ?? storeConfig?.fallbackImageUrl;
1192
- const imageUrlTransformer = storeConfig?.imageUrlTransformer;
1193
1219
  const {
1194
1220
  data: productsData,
1195
1221
  isLoading,
@@ -1201,16 +1227,7 @@ function useProductsFeed(options = {}) {
1201
1227
  isRefetching
1202
1228
  } = useInfiniteProducts(params);
1203
1229
  const { treeData: categoryTree = [], findById } = useProductCategoryTree();
1204
- const getProcessedImageUrl = react.useCallback(
1205
- (images) => {
1206
- const baseUrl = getImageUrl(images, imageSize, fallbackImageUrl);
1207
- if (baseUrl && imageUrlTransformer) {
1208
- return imageUrlTransformer(baseUrl, imageSize);
1209
- }
1210
- return baseUrl;
1211
- },
1212
- [imageSize, fallbackImageUrl, imageUrlTransformer]
1213
- );
1230
+ const getProcessedImageUrl = useProcessedImageUrl(imageSize, options.fallbackImageUrl);
1214
1231
  const products = react.useMemo(() => {
1215
1232
  if (!productsData) return [];
1216
1233
  const productList = Array.isArray(productsData) ? productsData : [];
@@ -1348,7 +1365,6 @@ function useProductView(options) {
1348
1365
  const storeContext = react.useContext(WooCommerceStoreContext);
1349
1366
  const storeConfig = storeContext?.config;
1350
1367
  const localeTag = options.localeTag ?? storeConfig?.locale?.localeTag ?? DEFAULT_STORE_CONFIG.locale.localeTag;
1351
- const fallbackImageUrl = options.fallbackImageUrl ?? storeConfig?.fallbackImageUrl;
1352
1368
  const imageUrlTransformer = storeConfig?.imageUrlTransformer;
1353
1369
  const [draftQuantity, setDraftQuantity] = react.useState(1);
1354
1370
  const { data: productData, isLoading, error, refetch } = useProduct(productId);
@@ -1356,6 +1372,7 @@ function useProductView(options) {
1356
1372
  const addToCartMutation = useAddToCart();
1357
1373
  const removeFromCartMutation = useRemoveFromCart();
1358
1374
  const updateCartMutation = useUpdateCartItem();
1375
+ const getProcessedImageUrl = useProcessedImageUrl(imageSize, options.fallbackImageUrl);
1359
1376
  const processImageUrl = react.useCallback(
1360
1377
  (url) => {
1361
1378
  if (!url) return url;
@@ -1371,7 +1388,6 @@ function useProductView(options) {
1371
1388
  const currencyCode = productData.prices?.currency_code;
1372
1389
  const stockStatus = productData.is_on_backorder ? "onbackorder" : productData.is_in_stock ? "instock" : "outofstock";
1373
1390
  const lowStockRemaining = productData.low_stock_remaining;
1374
- const baseImageUrl = getImageUrl(productData.images, imageSize, fallbackImageUrl);
1375
1391
  const baseImageUrls = getAllImageUrls(productData.images, imageSize);
1376
1392
  return {
1377
1393
  id: productData.id,
@@ -1381,7 +1397,7 @@ function useProductView(options) {
1381
1397
  description: productData.description,
1382
1398
  shortDescription: productData.short_description,
1383
1399
  sku: productData.sku,
1384
- imageUrl: processImageUrl(baseImageUrl),
1400
+ imageUrl: getProcessedImageUrl(productData.images),
1385
1401
  imageUrls: baseImageUrls.map((url) => processImageUrl(url) ?? url),
1386
1402
  price: formatStoreApiPriceIntl(productData.prices?.price, currencyCode, localeTag),
1387
1403
  regularPrice: formatStoreApiPriceIntl(
@@ -1411,7 +1427,7 @@ function useProductView(options) {
1411
1427
  minQuantity: productData.add_to_cart?.minimum ?? 1,
1412
1428
  raw: productData
1413
1429
  };
1414
- }, [productData, localeTag, fallbackImageUrl, imageSize, lowStockThreshold, processImageUrl]);
1430
+ }, [productData, localeTag, imageSize, lowStockThreshold, getProcessedImageUrl, processImageUrl]);
1415
1431
  const cartItem = react.useMemo(() => {
1416
1432
  return cartData?.items.find((item) => item.id === productId);
1417
1433
  }, [cartData?.items, productId]);
@@ -1494,24 +1510,13 @@ function useCartView(options = {}) {
1494
1510
  const storeContext = react.useContext(WooCommerceStoreContext);
1495
1511
  const storeConfig = storeContext?.config;
1496
1512
  const localeTag = options.localeTag ?? storeConfig?.locale?.localeTag ?? DEFAULT_STORE_CONFIG.locale.localeTag;
1497
- const fallbackImageUrl = options.fallbackImageUrl ?? storeConfig?.fallbackImageUrl;
1498
- const imageUrlTransformer = storeConfig?.imageUrlTransformer;
1499
1513
  const { data: cartData, isLoading, error, refetch } = useCart();
1500
1514
  const updateItemMutation = useUpdateCartItem();
1501
1515
  const removeItemMutation = useRemoveFromCart();
1502
1516
  const applyCouponMutation = useApplyCoupon();
1503
1517
  const removeCouponMutation = useRemoveCoupon();
1504
1518
  const selectShippingMutation = useSelectShippingRate();
1505
- const getProcessedImageUrl = react.useCallback(
1506
- (images) => {
1507
- const baseUrl = getImageUrl(images, imageSize, fallbackImageUrl);
1508
- if (baseUrl && imageUrlTransformer) {
1509
- return imageUrlTransformer(baseUrl, imageSize);
1510
- }
1511
- return baseUrl;
1512
- },
1513
- [imageSize, fallbackImageUrl, imageUrlTransformer]
1514
- );
1519
+ const getProcessedImageUrl = useProcessedImageUrl(imageSize, options.fallbackImageUrl);
1515
1520
  const items = react.useMemo(() => {
1516
1521
  if (!cartData?.items) return [];
1517
1522
  const currencyCode = cartData.totals.currency_code;
@@ -1657,8 +1662,6 @@ function useReorderView(items, options = {}) {
1657
1662
  const storeContext = react.useContext(WooCommerceStoreContext);
1658
1663
  const storeConfig = storeContext?.config;
1659
1664
  const localeTag = options.localeTag ?? storeConfig?.locale?.localeTag ?? DEFAULT_STORE_CONFIG.locale.localeTag;
1660
- const fallbackImageUrl = options.fallbackImageUrl ?? storeConfig?.fallbackImageUrl;
1661
- const imageUrlTransformer = storeConfig?.imageUrlTransformer;
1662
1665
  const productIds = react.useMemo(() => [...new Set(items.map((item) => item.productId))], [items]);
1663
1666
  const {
1664
1667
  data: productsPage,
@@ -1669,16 +1672,7 @@ function useReorderView(items, options = {}) {
1669
1672
  { enabled: productIds.length > 0 }
1670
1673
  );
1671
1674
  const { data: cart } = useCart();
1672
- const getProcessedImageUrl = react.useCallback(
1673
- (images) => {
1674
- const baseUrl = getImageUrl(images, imageSize, fallbackImageUrl);
1675
- if (baseUrl && imageUrlTransformer) {
1676
- return imageUrlTransformer(baseUrl, imageSize);
1677
- }
1678
- return baseUrl;
1679
- },
1680
- [imageSize, fallbackImageUrl, imageUrlTransformer]
1681
- );
1675
+ const getProcessedImageUrl = useProcessedImageUrl(imageSize, options.fallbackImageUrl);
1682
1676
  const views = react.useMemo(() => {
1683
1677
  const products = new Map((productsPage?.data ?? []).map((product) => [product.id, product]));
1684
1678
  return items.map((item) => {
@@ -1760,6 +1754,8 @@ function useOrderView(input, options = {}) {
1760
1754
  const storeContext = react.useContext(WooCommerceStoreContext);
1761
1755
  const storeConfig = storeContext?.config;
1762
1756
  const localeTag = options.localeTag ?? storeConfig?.locale?.localeTag ?? DEFAULT_STORE_CONFIG.locale.localeTag;
1757
+ const { imageSize = "thumbnail" } = options;
1758
+ const getProcessedImageUrl = useProcessedImageUrl(imageSize, options.fallbackImageUrl);
1763
1759
  const { data: rawOrder, isLoading, error } = useOrder(input);
1764
1760
  const order = react.useMemo(() => {
1765
1761
  if (!rawOrder) return void 0;
@@ -1770,7 +1766,7 @@ function useOrderView(input, options = {}) {
1770
1766
  quantity: item.quantity,
1771
1767
  price: formatStoreApiPriceIntl(item.prices.price, currencyCode, localeTag),
1772
1768
  total: formatStoreApiPriceIntl(item.totals.line_total, currencyCode, localeTag),
1773
- imageUrl: item.images?.[0]?.src
1769
+ imageUrl: getProcessedImageUrl(item.images)
1774
1770
  }));
1775
1771
  const status = rawOrder.status;
1776
1772
  return {
@@ -1785,7 +1781,7 @@ function useOrderView(input, options = {}) {
1785
1781
  paymentMethod: rawOrder.payment_method ?? "",
1786
1782
  raw: rawOrder
1787
1783
  };
1788
- }, [rawOrder, localeTag]);
1784
+ }, [rawOrder, localeTag, getProcessedImageUrl]);
1789
1785
  return {
1790
1786
  order,
1791
1787
  isLoading,
@@ -1928,6 +1924,7 @@ exports.useProcessCheckout = useProcessCheckout;
1928
1924
  exports.useProduct = useProduct;
1929
1925
  exports.useProductCategories = useProductCategories;
1930
1926
  exports.useProductCategoryTree = useProductCategoryTree;
1927
+ exports.useProductTags = useProductTags;
1931
1928
  exports.useProductView = useProductView;
1932
1929
  exports.useProducts = useProducts;
1933
1930
  exports.useProductsFeed = useProductsFeed;