@anker-in/shopify-react 1.0.1 → 1.0.2

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.
@@ -713,14 +713,15 @@ function useAddCartLines(options) {
713
713
  const { mutateCart, metafieldIdentifiers } = useCartContext();
714
714
  const addLines = useCallback(
715
715
  async (_key, { arg }) => {
716
- const { cartId, lines } = arg;
716
+ const { cartId, lines, updateCookie = true } = arg;
717
717
  const id = cartId || cartCookieAdapter?.getCartId(locale);
718
718
  let updatedCart;
719
719
  if (!id) {
720
720
  updatedCart = await createCart(client, {
721
721
  lines,
722
722
  metafieldIdentifiers,
723
- cookieAdapter: cartCookieAdapter
723
+ cookieAdapter: cartCookieAdapter,
724
+ updateCookie
724
725
  });
725
726
  } else {
726
727
  updatedCart = await addCartLines(client, {
@@ -882,14 +883,10 @@ function useApplyCartCodes(options) {
882
883
  const { mutateCart, cart, metafieldIdentifiers } = useCartContext();
883
884
  const applyCodes = useCallback(
884
885
  async (_key, { arg }) => {
885
- const { cartId: providedCartId, discountCodes, replaceExistingCodes } = arg;
886
+ const { cartId, discountCodes, replaceExistingCodes } = arg;
886
887
  if (!discountCodes?.length) {
887
888
  throw new Error("Invalid input used for this operation: Miss discountCode");
888
889
  }
889
- const cartId = providedCartId || cart?.id;
890
- if (!cartId) {
891
- return void 0;
892
- }
893
890
  const updatedCart = await updateCartCodes(client, {
894
891
  cartId,
895
892
  discountCodes: replaceExistingCodes ? discountCodes : [
@@ -919,8 +916,7 @@ function useRemoveCartCodes(options) {
919
916
  const { mutateCart, cart, metafieldIdentifiers } = useCartContext();
920
917
  const removeCodes = useCallback(
921
918
  async (_key, { arg }) => {
922
- const { cartId: providedCartId, discountCodes } = arg;
923
- const cartId = providedCartId || cart?.id;
919
+ const { cartId, discountCodes } = arg;
924
920
  const codes = cart?.discountCodes?.filter((code) => !!code.applicable) || [];
925
921
  const leftCodes = codes.filter((code) => discountCodes?.length ? !discountCodes.includes(code.code) : code.code).map((code) => code.code);
926
922
  const updatedCart = await updateCartCodes(client, {