@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.js CHANGED
@@ -810,14 +810,15 @@ function useAddCartLines(options) {
810
810
  const { mutateCart, metafieldIdentifiers } = useCartContext();
811
811
  const addLines = react.useCallback(
812
812
  async (_key, { arg }) => {
813
- const { cartId, lines } = arg;
813
+ const { cartId, lines, updateCookie = true } = arg;
814
814
  const id = cartId || cartCookieAdapter?.getCartId(locale);
815
815
  let updatedCart;
816
816
  if (!id) {
817
817
  updatedCart = await shopifySdk.createCart(client, {
818
818
  lines,
819
819
  metafieldIdentifiers,
820
- cookieAdapter: cartCookieAdapter
820
+ cookieAdapter: cartCookieAdapter,
821
+ updateCookie
821
822
  });
822
823
  } else {
823
824
  updatedCart = await shopifySdk.addCartLines(client, {
@@ -1014,14 +1015,10 @@ function useApplyCartCodes(options) {
1014
1015
  const { mutateCart, cart, metafieldIdentifiers } = useCartContext();
1015
1016
  const applyCodes = react.useCallback(
1016
1017
  async (_key, { arg }) => {
1017
- const { cartId: providedCartId, discountCodes, replaceExistingCodes } = arg;
1018
+ const { cartId, discountCodes, replaceExistingCodes } = arg;
1018
1019
  if (!discountCodes?.length) {
1019
1020
  throw new Error("Invalid input used for this operation: Miss discountCode");
1020
1021
  }
1021
- const cartId = providedCartId || cart?.id;
1022
- if (!cartId) {
1023
- return void 0;
1024
- }
1025
1022
  const updatedCart = await shopifySdk.updateCartCodes(client, {
1026
1023
  cartId,
1027
1024
  discountCodes: replaceExistingCodes ? discountCodes : [
@@ -1051,8 +1048,7 @@ function useRemoveCartCodes(options) {
1051
1048
  const { mutateCart, cart, metafieldIdentifiers } = useCartContext();
1052
1049
  const removeCodes = react.useCallback(
1053
1050
  async (_key, { arg }) => {
1054
- const { cartId: providedCartId, discountCodes } = arg;
1055
- const cartId = providedCartId || cart?.id;
1051
+ const { cartId, discountCodes } = arg;
1056
1052
  const codes = cart?.discountCodes?.filter((code) => !!code.applicable) || [];
1057
1053
  const leftCodes = codes.filter((code) => discountCodes?.length ? !discountCodes.includes(code.code) : code.code).map((code) => code.code);
1058
1054
  const updatedCart = await shopifySdk.updateCartCodes(client, {