File tree Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ const AddToCart = ({
96
96
variationId,
97
97
fullWidth = false ,
98
98
} : IProductRootObject ) => {
99
- const { setCart, cart } = useContext ( CartContext ) ;
99
+ const { setCart, isLoading : isCartLoading } = useContext ( CartContext ) ;
100
100
const [ requestError , setRequestError ] = useState < boolean > ( false ) ;
101
101
102
102
const productId = product ?. databaseId ? product ?. databaseId : variationId ;
@@ -141,10 +141,6 @@ const AddToCart = ({
141
141
} ) ;
142
142
143
143
const handleAddToCart = ( ) => {
144
- if ( ! cart ) {
145
- console . log ( 'Cart is not yet initialized. Please wait.' ) ;
146
- return ;
147
- }
148
144
addToCart ( ) ;
149
145
// Refetch cart after 2 seconds
150
146
setTimeout ( ( ) => {
@@ -156,10 +152,10 @@ const AddToCart = ({
156
152
< >
157
153
< Button
158
154
handleButtonClick = { ( ) => handleAddToCart ( ) }
159
- buttonDisabled = { addToCartLoading || requestError || ! cart }
155
+ buttonDisabled = { addToCartLoading || requestError || isCartLoading }
160
156
fullWidth = { fullWidth }
161
157
>
162
- { ! cart ? 'Loading...' : 'KJØP' }
158
+ { isCartLoading ? 'Loading...' : 'KJØP' }
163
159
</ Button >
164
160
</ >
165
161
) ;
You can’t perform that action at this time.
0 commit comments