File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ const AddToCartButton = ({ product }) => {
34
34
const { data, refetch } = useQuery ( GET_CART , {
35
35
notifyOnNetworkStatusChange : true ,
36
36
onCompleted : ( ) => {
37
+ refetch ( ) ;
37
38
// Update cart in the localStorage.
38
39
const updatedCart = getFormattedCart ( data ) ;
39
40
@@ -54,12 +55,14 @@ const AddToCartButton = ({ product }) => {
54
55
input : productQueryInput ,
55
56
} ,
56
57
onCompleted : ( ) => {
58
+ console . log ( "Completed" )
59
+ // Update the cart with new values in React context.
60
+ refetch ( ) ;
57
61
// If error.
58
62
if ( addToCartError ) {
59
63
setRequestError ( addToCartError . graphQLErrors [ 0 ] . message ) ;
60
64
}
61
- // Update the cart with new values in React context.
62
- refetch ( ) ;
65
+
63
66
// Show View Cart Button
64
67
setShowViewCart ( true ) ;
65
68
setshowAddToCart ( true ) ;
@@ -74,7 +77,6 @@ const AddToCartButton = ({ product }) => {
74
77
const handleAddToCartClick = ( ) => {
75
78
setRequestError ( null ) ;
76
79
addToCart ( ) ;
77
- // Update the cart with new values in React context.
78
80
refetch ( ) ;
79
81
} ;
80
82
You can’t perform that action at this time.
0 commit comments