@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.
package/dist/index.mjs CHANGED
@@ -802,14 +802,15 @@ function useAddCartLines(options) {
802
802
  const { mutateCart, metafieldIdentifiers } = useCartContext();
803
803
  const addLines = useCallback(
804
804
  async (_key, { arg }) => {
805
- const { cartId, lines } = arg;
805
+ const { cartId, lines, updateCookie = true } = arg;
806
806
  const id = cartId || cartCookieAdapter?.getCartId(locale);
807
807
  let updatedCart;
808
808
  if (!id) {
809
809
  updatedCart = await createCart(client, {
810
810
  lines,
811
811
  metafieldIdentifiers,
812
- cookieAdapter: cartCookieAdapter
812
+ cookieAdapter: cartCookieAdapter,
813
+ updateCookie
813
814
  });
814
815
  } else {
815
816
  updatedCart = await addCartLines(client, {
@@ -1006,14 +1007,10 @@ function useApplyCartCodes(options) {
1006
1007
  const { mutateCart, cart, metafieldIdentifiers } = useCartContext();
1007
1008
  const applyCodes = useCallback(
1008
1009
  async (_key, { arg }) => {
1009
- const { cartId: providedCartId, discountCodes, replaceExistingCodes } = arg;
1010
+ const { cartId, discountCodes, replaceExistingCodes } = arg;
1010
1011
  if (!discountCodes?.length) {
1011
1012
  throw new Error("Invalid input used for this operation: Miss discountCode");
1012
1013
  }
1013
- const cartId = providedCartId || cart?.id;
1014
- if (!cartId) {
1015
- return void 0;
1016
- }
1017
1014
  const updatedCart = await updateCartCodes(client, {
1018
1015
  cartId,
1019
1016
  discountCodes: replaceExistingCodes ? discountCodes : [
@@ -1043,8 +1040,7 @@ function useRemoveCartCodes(options) {
1043
1040
  const { mutateCart, cart, metafieldIdentifiers } = useCartContext();
1044
1041
  const removeCodes = useCallback(
1045
1042
  async (_key, { arg }) => {
1046
- const { cartId: providedCartId, discountCodes } = arg;
1047
- const cartId = providedCartId || cart?.id;
1043
+ const { cartId, discountCodes } = arg;
1048
1044
  const codes = cart?.discountCodes?.filter((code) => !!code.applicable) || [];
1049
1045
  const leftCodes = codes.filter((code) => discountCodes?.length ? !discountCodes.includes(code.code) : code.code).map((code) => code.code);
1050
1046
  const updatedCart = await updateCartCodes(client, {