@atomic-solutions/woocommerce-react 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2026 Atomic Solutions
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,125 @@
1
+ # @atomic-solutions/react-woocommerce
2
+
3
+ > React Query hooks and provider for WooCommerce Store API
4
+
5
+ React integration layer for `@atomic-solutions/woocommerce-utils`. Provides React Query hooks and context provider for building WooCommerce storefronts in React and React Native.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pnpm add @atomic-solutions/react-woocommerce
11
+ ```
12
+
13
+ ### Peer Dependencies
14
+
15
+ ```bash
16
+ pnpm add @atomic-solutions/woocommerce-utils @tanstack/react-query react
17
+ ```
18
+
19
+ ## Quick Start
20
+
21
+ ### 1. Create Client
22
+
23
+ ```tsx
24
+ import { createClient } from '@atomic-solutions/woocommerce-utils';
25
+
26
+ const client = createClient({
27
+ baseURL: 'https://your-store.com/wp-json',
28
+ cartHeaders: {
29
+ get: async () => ({
30
+ nonce: await AsyncStorage.getItem('woo_nonce'),
31
+ cartToken: await AsyncStorage.getItem('woo_cart_token'),
32
+ }),
33
+ save: async ({ nonce, cartToken }) => {
34
+ if (nonce) await AsyncStorage.setItem('woo_nonce', nonce);
35
+ if (cartToken) await AsyncStorage.setItem('woo_cart_token', cartToken);
36
+ },
37
+ clear: async () => {
38
+ await AsyncStorage.removeItem('woo_nonce');
39
+ await AsyncStorage.removeItem('woo_cart_token');
40
+ },
41
+ },
42
+ });
43
+ ```
44
+
45
+ ### 2. Setup Provider
46
+
47
+ ```tsx
48
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
49
+ import { WooCommerceProvider } from '@atomic-solutions/react-woocommerce';
50
+
51
+ const queryClient = new QueryClient();
52
+
53
+ function App() {
54
+ return (
55
+ <QueryClientProvider client={queryClient}>
56
+ <WooCommerceProvider client={client}>
57
+ <YourApp />
58
+ </WooCommerceProvider>
59
+ </QueryClientProvider>
60
+ );
61
+ }
62
+ ```
63
+
64
+ ### 3. Use Hooks
65
+
66
+ ```tsx
67
+ import { useProducts, useAddToCart } from '@atomic-solutions/react-woocommerce';
68
+
69
+ function ProductList() {
70
+ const { data: products, isLoading } = useProducts({
71
+ per_page: 20,
72
+ });
73
+
74
+ const addToCart = useAddToCart();
75
+
76
+ if (isLoading) return <Loading />;
77
+
78
+ return (
79
+ <FlatList
80
+ data={products}
81
+ renderItem={({ item }) => (
82
+ <ProductCard
83
+ product={item}
84
+ onAddToCart={() =>
85
+ addToCart.mutate({
86
+ id: item.id,
87
+ quantity: 1,
88
+ })
89
+ }
90
+ />
91
+ )}
92
+ />
93
+ );
94
+ }
95
+ ```
96
+
97
+ ## Available Hooks
98
+
99
+ ### Products
100
+ - `useProducts(params)` - List products
101
+ - `useInfiniteProducts(params)` - Infinite scroll products
102
+ - `useProduct(id)` - Single product
103
+ - `useProductCategories()` - List categories
104
+ - `useProductCategoryTree()` - Hierarchical category tree
105
+
106
+ ### Cart
107
+ - `useCart()` - Get cart
108
+ - `useAddToCart()` - Add item to cart
109
+ - `useUpdateCartItem()` - Update cart item quantity
110
+ - `useRemoveFromCart()` - Remove item from cart
111
+ - `useApplyCoupon()` - Apply coupon code
112
+ - `useRemoveCoupon()` - Remove coupon
113
+ - `useUpdateCustomer()` - Update customer info
114
+ - `useSelectShippingRate()` - Select shipping method
115
+
116
+ ### Checkout
117
+ - `useCheckout()` - Get checkout data
118
+ - `useProcessCheckout()` - Process order
119
+
120
+ ### Orders
121
+ - `useOrder(id)` - Get order by ID
122
+
123
+ ## License
124
+
125
+ MIT © Atomic Solutions