Skip to content

Commit

Permalink
feat(Cart): ✨ Added maxAge of 8 days to the Cart cookie (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarocavalcanti committed Jul 13, 2023
1 parent 2cf5aba commit df5ce09
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions constants/carts.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const CART_COOKIE = 'atlas-shopify-cart';
export const EIGHT_DAYS_IN_SECONDS = (60 * 60 * 24 * 8);
4 changes: 2 additions & 2 deletions hooks/useShopifyCart.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import RETRIEVE_CART from '../queries/Cart';
import ADD_TO_CART from '../mutations/AddToCart';
import REMOVE_FROM_CART from '../mutations/RemoveFromCart';
import UPDATE_CART_QUANTITY from '../mutations/QuantityCart';
import { CART_COOKIE } from '../constants/carts';
import { CART_COOKIE, EIGHT_DAYS_IN_SECONDS } from '../constants/carts';

/**
* Render the ShopifyCartProvider component.
Expand Down Expand Up @@ -49,7 +49,7 @@ export function ShopifyCartProvider({ children }) {
variables: { input: {} },
})
.then((response) => {
cookies.set(CART_COOKIE, response.data.cartCreate.cart.id);
cookies.set(CART_COOKIE, response.data.cartCreate.cart.id, { maxAge: EIGHT_DAYS_IN_SECONDS });
setCartData(response.data.cartCreate.cart);
})
.catch((err) => console.error(err));
Expand Down

1 comment on commit df5ce09

@headless-wordpress-by-wp-engine

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out the recent updates to your Atlas environment:

App Environment URL Build
atlas-shopify-blueprint develop https://hp…wered.com ✅ (logs)

Learn more about building on Atlas in our documentation.

Please sign in to comment.