@atomic-solutions/woocommerce-react 0.2.5 → 0.2.6

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,7 +1,7 @@
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 { WooCommerceClient, ProductCategory, ProductParams, PaginatedResponse, Product, Cart, Checkout, GetOrderInput, StoreApiOrder, ProductImage, CartItemImage, CartItem } from '@atomic-solutions/woocommerce-api-client';
4
- import { Q as QueryKeys, k as StoreContextValue, l as StoreFeatures, S as StoreLocale, n as StoreTheme } from './types-D7dDI9Lr.js';
4
+ import { Q as QueryKeys, k as StoreContextValue, l as StoreFeatures, S as StoreLocale, n as StoreTheme } from './types-_8YqnkO-.js';
5
5
 
6
6
  type QueryOptions<TData, TError = Error> = Omit<UseQueryOptions<TData, TError>, 'queryKey' | 'queryFn'>;
7
7
  type MutationOptions<TData, TError = Error, TVariables = unknown> = Omit<UseMutationOptions<TData, TError, TVariables>, 'mutationFn'>;
@@ -1,7 +1,7 @@
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 { WooCommerceClient, ProductCategory, ProductParams, PaginatedResponse, Product, Cart, Checkout, GetOrderInput, StoreApiOrder, ProductImage, CartItemImage, CartItem } from '@atomic-solutions/woocommerce-api-client';
4
- import { Q as QueryKeys, k as StoreContextValue, l as StoreFeatures, S as StoreLocale, n as StoreTheme } from './types-D7dDI9Lr.cjs';
4
+ import { Q as QueryKeys, k as StoreContextValue, l as StoreFeatures, S as StoreLocale, n as StoreTheme } from './types-_8YqnkO-.cjs';
5
5
 
6
6
  type QueryOptions<TData, TError = Error> = Omit<UseQueryOptions<TData, TError>, 'queryKey' | 'queryFn'>;
7
7
  type MutationOptions<TData, TError = Error, TVariables = unknown> = Omit<UseMutationOptions<TData, TError, TVariables>, 'mutationFn'>;
package/dist/index.cjs CHANGED
@@ -858,10 +858,11 @@ var useProcessCheckout = () => {
858
858
  mutationKey: queryKeys.checkout.mutations.process(),
859
859
  mutationFn: (input) => client.checkout.process(input),
860
860
  onSuccess: (checkout) => {
861
+ const cart = queryClient.getQueryData(queryKeys.cart.details()) ?? null;
861
862
  queryClient.invalidateQueries({ queryKey: queryKeys.cart.all });
862
863
  queryClient.invalidateQueries({ queryKey: queryKeys.checkout.all });
863
864
  if (emitEvent) {
864
- emitEvent(createSuccessEvent("checkout:processed", { checkout }));
865
+ emitEvent(createSuccessEvent("checkout:processed", { checkout, cart }));
865
866
  }
866
867
  },
867
868
  onError: (error) => {
@@ -1698,12 +1699,17 @@ function createAnalyticsHandler(provider) {
1698
1699
  coupon_code: event.data.code
1699
1700
  });
1700
1701
  break;
1701
- case "checkout:processed":
1702
+ case "checkout:processed": {
1703
+ const { checkout, cart } = event.data;
1704
+ const parsedTotal = cart ? parseFloat(cart.totals.total_price) : void 0;
1702
1705
  provider.log("purchase", {
1703
- order_id: event.data.checkout.order_id,
1704
- payment_method: event.data.checkout.payment_method
1706
+ order_id: checkout.order_id,
1707
+ payment_method: checkout.payment_method,
1708
+ order_total: Number.isFinite(parsedTotal) ? parsedTotal : void 0,
1709
+ items_count: cart?.items_count
1705
1710
  });
1706
1711
  break;
1712
+ }
1707
1713
  }
1708
1714
  };
1709
1715
  }