@anker-in/shopify-react 1.0.0 → 1.0.1-beta.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/hooks/index.d.mts +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +5 -9
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +5 -9
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.js +5 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/hooks/index.d.mts
CHANGED
package/dist/hooks/index.d.ts
CHANGED
package/dist/hooks/index.js
CHANGED
|
@@ -722,14 +722,15 @@ function useAddCartLines(options) {
|
|
|
722
722
|
const { mutateCart, metafieldIdentifiers } = useCartContext();
|
|
723
723
|
const addLines = react.useCallback(
|
|
724
724
|
async (_key, { arg }) => {
|
|
725
|
-
const { cartId, lines } = arg;
|
|
725
|
+
const { cartId, lines, updateCookie = true } = arg;
|
|
726
726
|
const id = cartId || cartCookieAdapter?.getCartId(locale);
|
|
727
727
|
let updatedCart;
|
|
728
728
|
if (!id) {
|
|
729
729
|
updatedCart = await shopifySdk.createCart(client, {
|
|
730
730
|
lines,
|
|
731
731
|
metafieldIdentifiers,
|
|
732
|
-
cookieAdapter: cartCookieAdapter
|
|
732
|
+
cookieAdapter: cartCookieAdapter,
|
|
733
|
+
updateCookie
|
|
733
734
|
});
|
|
734
735
|
} else {
|
|
735
736
|
updatedCart = await shopifySdk.addCartLines(client, {
|
|
@@ -891,14 +892,10 @@ function useApplyCartCodes(options) {
|
|
|
891
892
|
const { mutateCart, cart, metafieldIdentifiers } = useCartContext();
|
|
892
893
|
const applyCodes = react.useCallback(
|
|
893
894
|
async (_key, { arg }) => {
|
|
894
|
-
const { cartId
|
|
895
|
+
const { cartId, discountCodes, replaceExistingCodes } = arg;
|
|
895
896
|
if (!discountCodes?.length) {
|
|
896
897
|
throw new Error("Invalid input used for this operation: Miss discountCode");
|
|
897
898
|
}
|
|
898
|
-
const cartId = providedCartId || cart?.id;
|
|
899
|
-
if (!cartId) {
|
|
900
|
-
return void 0;
|
|
901
|
-
}
|
|
902
899
|
const updatedCart = await shopifySdk.updateCartCodes(client, {
|
|
903
900
|
cartId,
|
|
904
901
|
discountCodes: replaceExistingCodes ? discountCodes : [
|
|
@@ -928,8 +925,7 @@ function useRemoveCartCodes(options) {
|
|
|
928
925
|
const { mutateCart, cart, metafieldIdentifiers } = useCartContext();
|
|
929
926
|
const removeCodes = react.useCallback(
|
|
930
927
|
async (_key, { arg }) => {
|
|
931
|
-
const { cartId
|
|
932
|
-
const cartId = providedCartId || cart?.id;
|
|
928
|
+
const { cartId, discountCodes } = arg;
|
|
933
929
|
const codes = cart?.discountCodes?.filter((code) => !!code.applicable) || [];
|
|
934
930
|
const leftCodes = codes.filter((code) => discountCodes?.length ? !discountCodes.includes(code.code) : code.code).map((code) => code.code);
|
|
935
931
|
const updatedCart = await shopifySdk.updateCartCodes(client, {
|