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 }) => {
3434 const { data, refetch } = useQuery ( GET_CART , {
3535 notifyOnNetworkStatusChange : true ,
3636 onCompleted : ( ) => {
37+ refetch ( ) ;
3738 // Update cart in the localStorage.
3839 const updatedCart = getFormattedCart ( data ) ;
3940
@@ -54,12 +55,14 @@ const AddToCartButton = ({ product }) => {
5455 input : productQueryInput ,
5556 } ,
5657 onCompleted : ( ) => {
58+ console . log ( "Completed" )
59+ // Update the cart with new values in React context.
60+ refetch ( ) ;
5761 // If error.
5862 if ( addToCartError ) {
5963 setRequestError ( addToCartError . graphQLErrors [ 0 ] . message ) ;
6064 }
61- // Update the cart with new values in React context.
62- refetch ( ) ;
65+
6366 // Show View Cart Button
6467 setShowViewCart ( true ) ;
6568 setshowAddToCart ( true ) ;
@@ -74,7 +77,6 @@ const AddToCartButton = ({ product }) => {
7477 const handleAddToCartClick = ( ) => {
7578 setRequestError ( null ) ;
7679 addToCart ( ) ;
77- // Update the cart with new values in React context.
7880 refetch ( ) ;
7981 } ;
8082
You can’t perform that action at this time.
0 commit comments