@plasmicpkgs/commerce-shopify 0.0.151 → 0.0.154
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/commerce-shopify.cjs.development.js +26 -26
- package/dist/commerce-shopify.cjs.development.js.map +1 -1
- package/dist/commerce-shopify.cjs.production.min.js +1 -1
- package/dist/commerce-shopify.cjs.production.min.js.map +1 -1
- package/dist/commerce-shopify.esm.js +27 -27
- package/dist/commerce-shopify.esm.js.map +1 -1
- package/dist/shopify.d.ts +0 -1
- package/dist/utils/normalize.d.ts +4 -4
- package/dist/utils/queries/get-checkout-query.d.ts +1 -1
- package/package.json +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import registerGlobalContext from '@plasmicapp/host/registerGlobalContext';
|
|
2
2
|
import React, { useMemo, useCallback } from 'react';
|
|
3
|
-
import { FetcherError, ValidationError, CommerceError, useCart, useCommerce as useCommerce$1, getCommerceProvider as getCommerceProvider$1 } from '@plasmicpkgs/commerce';
|
|
3
|
+
import { FetcherError, ValidationError, CommerceError, useCart, useCommerce as useCommerce$1, getCommerceProvider as getCommerceProvider$1, globalActionsRegistrations, CartActionsProvider } from '@plasmicpkgs/commerce';
|
|
4
4
|
import Cookies from 'js-cookie';
|
|
5
5
|
import debounce from 'debounce';
|
|
6
6
|
|
|
@@ -877,7 +877,7 @@ var getCheckoutId = function getCheckoutId(id) {
|
|
|
877
877
|
Forked from https://github.com/vercel/commerce/tree/main/packages/shopify/src
|
|
878
878
|
Changes: None
|
|
879
879
|
*/
|
|
880
|
-
var checkoutDetailsFragment = /* GraphQL */"\n fragment checkoutDetails on Checkout {\n id\n webUrl\n subtotalPriceV2 {\n amount\n currencyCode\n }\n totalTaxV2 {\n amount\n currencyCode\n }\n totalPriceV2 {\n amount\n currencyCode\n }\n completedAt\n createdAt\n taxesIncluded\n lineItems(first: 250) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n id\n title\n variant {\n id\n sku\n title\n selectedOptions {\n name\n value\n }\n image {\n originalSrc\n altText\n width\n height\n }\n priceV2 {\n amount\n currencyCode\n }\n compareAtPriceV2 {\n amount\n currencyCode\n }\n product {\n handle\n }\n }\n quantity\n }\n }\n }\n }\n";
|
|
880
|
+
var checkoutDetailsFragment = /* GraphQL */"\n fragment checkoutDetails on Checkout {\n id\n webUrl\n subtotalPriceV2 {\n amount\n currencyCode\n }\n totalTaxV2 {\n amount\n currencyCode\n }\n totalPriceV2 {\n amount\n currencyCode\n }\n completedAt\n createdAt\n taxesIncluded\n lineItems(first: 250) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n }\n edges {\n node {\n id\n title\n variant {\n id\n sku\n title\n selectedOptions {\n name\n value\n }\n image {\n originalSrc\n altText\n width\n height\n }\n priceV2 {\n amount\n currencyCode\n }\n compareAtPriceV2 {\n amount\n currencyCode\n }\n product {\n id\n handle\n }\n }\n quantity\n }\n }\n }\n }\n";
|
|
881
881
|
var getCheckoutQuery = /* GraphQL */"\n query getCheckout($checkoutId: ID!) {\n node(id: $checkoutId) {\n ...checkoutDetails\n }\n }\n " + checkoutDetailsFragment + "\n";
|
|
882
882
|
|
|
883
883
|
/*
|
|
@@ -1108,7 +1108,7 @@ var normalizeProductOption = function normalizeProductOption(_ref2) {
|
|
|
1108
1108
|
displayName = _ref2.name,
|
|
1109
1109
|
values = _ref2.values;
|
|
1110
1110
|
return {
|
|
1111
|
-
__typename:
|
|
1111
|
+
__typename: "MultipleChoiceOption",
|
|
1112
1112
|
id: id,
|
|
1113
1113
|
displayName: displayName.toLowerCase(),
|
|
1114
1114
|
values: values.map(function (value) {
|
|
@@ -1116,7 +1116,7 @@ var normalizeProductOption = function normalizeProductOption(_ref2) {
|
|
|
1116
1116
|
label: value
|
|
1117
1117
|
};
|
|
1118
1118
|
if (displayName.match(/colou?r/gi)) {
|
|
1119
|
-
var mapedColor = colorMap[value.toLowerCase().replace(/ /g,
|
|
1119
|
+
var mapedColor = colorMap[value.toLowerCase().replace(/ /g, "")];
|
|
1120
1120
|
if (mapedColor) {
|
|
1121
1121
|
output = _extends({}, output, {
|
|
1122
1122
|
hexColors: [mapedColor]
|
|
@@ -1190,7 +1190,7 @@ function normalizeProduct(_ref8) {
|
|
|
1190
1190
|
name: name,
|
|
1191
1191
|
vendor: vendor,
|
|
1192
1192
|
path: "/" + handle,
|
|
1193
|
-
slug: handle == null ? void 0 : handle.replace(/^\/+|\/+$/g,
|
|
1193
|
+
slug: handle == null ? void 0 : handle.replace(/^\/+|\/+$/g, ""),
|
|
1194
1194
|
price: money(priceRange == null ? void 0 : priceRange.minVariantPrice),
|
|
1195
1195
|
images: normalizeProductImages(images),
|
|
1196
1196
|
variants: variants ? normalizeProductVariants(variants) : [],
|
|
@@ -1211,8 +1211,8 @@ function normalizeCart(checkout) {
|
|
|
1211
1211
|
return {
|
|
1212
1212
|
id: checkout.id,
|
|
1213
1213
|
url: checkout.webUrl,
|
|
1214
|
-
customerId:
|
|
1215
|
-
email:
|
|
1214
|
+
customerId: "",
|
|
1215
|
+
email: "",
|
|
1216
1216
|
createdAt: checkout.createdAt,
|
|
1217
1217
|
currency: {
|
|
1218
1218
|
code: (_checkout$totalPriceV = checkout.totalPriceV2) == null ? void 0 : _checkout$totalPriceV.currencyCode
|
|
@@ -1235,15 +1235,15 @@ function normalizeLineItem(_ref9) {
|
|
|
1235
1235
|
return {
|
|
1236
1236
|
id: id,
|
|
1237
1237
|
variantId: String(variant == null ? void 0 : variant.id),
|
|
1238
|
-
productId: String(variant == null ? void 0 : variant.id),
|
|
1238
|
+
productId: String(variant == null ? void 0 : variant.product.id),
|
|
1239
1239
|
name: "" + title,
|
|
1240
1240
|
quantity: quantity,
|
|
1241
1241
|
variant: {
|
|
1242
1242
|
id: String(variant == null ? void 0 : variant.id),
|
|
1243
|
-
sku: (_variant$sku = variant == null ? void 0 : variant.sku) != null ? _variant$sku :
|
|
1243
|
+
sku: (_variant$sku = variant == null ? void 0 : variant.sku) != null ? _variant$sku : "",
|
|
1244
1244
|
name: variant == null ? void 0 : variant.title,
|
|
1245
1245
|
image: {
|
|
1246
|
-
url: (variant == null ? void 0 : (_variant$image = variant.image) == null ? void 0 : _variant$image.originalSrc) ||
|
|
1246
|
+
url: (variant == null ? void 0 : (_variant$image = variant.image) == null ? void 0 : _variant$image.originalSrc) || "/product-img-placeholder.svg"
|
|
1247
1247
|
},
|
|
1248
1248
|
requiresShipping: (_variant$requiresShip = variant == null ? void 0 : variant.requiresShipping) != null ? _variant$requiresShip : false,
|
|
1249
1249
|
price: variant == null ? void 0 : (_variant$priceV = variant.priceV2) == null ? void 0 : _variant$priceV.amount,
|
|
@@ -1251,7 +1251,7 @@ function normalizeLineItem(_ref9) {
|
|
|
1251
1251
|
},
|
|
1252
1252
|
path: String(variant == null ? void 0 : (_variant$product = variant.product) == null ? void 0 : _variant$product.handle),
|
|
1253
1253
|
discounts: [],
|
|
1254
|
-
options: (variant == null ? void 0 : variant.title) ==
|
|
1254
|
+
options: (variant == null ? void 0 : variant.title) == "Default Title" ? [] : variant == null ? void 0 : variant.selectedOptions
|
|
1255
1255
|
};
|
|
1256
1256
|
}
|
|
1257
1257
|
/*
|
|
@@ -1850,41 +1850,37 @@ var handler$5 = {
|
|
|
1850
1850
|
mutate = _useCart.mutate;
|
|
1851
1851
|
return useCallback(debounce( /*#__PURE__*/function () {
|
|
1852
1852
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(input) {
|
|
1853
|
-
var _input$id
|
|
1854
|
-
var itemId,
|
|
1853
|
+
var _input$id;
|
|
1854
|
+
var itemId, data;
|
|
1855
1855
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1856
1856
|
while (1) {
|
|
1857
1857
|
switch (_context2.prev = _context2.next) {
|
|
1858
1858
|
case 0:
|
|
1859
1859
|
itemId = (_input$id = input.id) != null ? _input$id : item == null ? void 0 : item.id;
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
if (!(!itemId || !productId || !variantId)) {
|
|
1863
|
-
_context2.next = 5;
|
|
1860
|
+
if (!(!itemId || input.quantity == null)) {
|
|
1861
|
+
_context2.next = 3;
|
|
1864
1862
|
break;
|
|
1865
1863
|
}
|
|
1866
1864
|
throw new ValidationError({
|
|
1867
1865
|
message: "Invalid input used for this operation"
|
|
1868
1866
|
});
|
|
1869
|
-
case
|
|
1870
|
-
_context2.next =
|
|
1867
|
+
case 3:
|
|
1868
|
+
_context2.next = 5;
|
|
1871
1869
|
return fetch({
|
|
1872
1870
|
input: {
|
|
1873
1871
|
item: {
|
|
1874
|
-
productId: productId,
|
|
1875
|
-
variantId: variantId,
|
|
1876
1872
|
quantity: input.quantity
|
|
1877
1873
|
},
|
|
1878
1874
|
itemId: itemId
|
|
1879
1875
|
}
|
|
1880
1876
|
});
|
|
1881
|
-
case
|
|
1877
|
+
case 5:
|
|
1882
1878
|
data = _context2.sent;
|
|
1883
|
-
_context2.next =
|
|
1879
|
+
_context2.next = 8;
|
|
1884
1880
|
return mutate(data, false);
|
|
1885
|
-
case
|
|
1881
|
+
case 8:
|
|
1886
1882
|
return _context2.abrupt("return", data);
|
|
1887
|
-
case
|
|
1883
|
+
case 9:
|
|
1888
1884
|
case "end":
|
|
1889
1885
|
return _context2.stop();
|
|
1890
1886
|
}
|
|
@@ -2120,8 +2116,9 @@ var getCommerceProvider = function getCommerceProvider(storeDomain, accessToken)
|
|
|
2120
2116
|
return getCommerceProvider$1(getShopifyProvider(storeDomain, accessToken));
|
|
2121
2117
|
};
|
|
2122
2118
|
|
|
2119
|
+
var globalContextName = "plasmic-commerce-shopify-provider";
|
|
2123
2120
|
var commerceProviderMeta = {
|
|
2124
|
-
name:
|
|
2121
|
+
name: globalContextName,
|
|
2125
2122
|
displayName: "Shopify Provider",
|
|
2126
2123
|
props: {
|
|
2127
2124
|
storeDomain: {
|
|
@@ -2133,6 +2130,7 @@ var commerceProviderMeta = {
|
|
|
2133
2130
|
defaultValue: "ef7d41c7bf7e1c214074d0d3047bcd7b"
|
|
2134
2131
|
}
|
|
2135
2132
|
},
|
|
2133
|
+
unstable__globalActions: globalActionsRegistrations,
|
|
2136
2134
|
description: "Your store domain usually looks like **storename.myshopify.com**.\n\nFor your access token, get it by following [this video](https://www.youtube.com/watch?v=wB_6cM7tdv4).\n\nSee also the [getting started video](https://www.youtube.com/watch?v=1OJ_gXmta2Q).",
|
|
2137
2135
|
importPath: "@plasmicpkgs/commerce-shopify",
|
|
2138
2136
|
importName: "CommerceProviderComponent"
|
|
@@ -2144,7 +2142,9 @@ function CommerceProviderComponent(props) {
|
|
|
2144
2142
|
var CommerceProvider = React.useMemo(function () {
|
|
2145
2143
|
return getCommerceProvider(storeDomain, accessToken);
|
|
2146
2144
|
}, [storeDomain, accessToken]);
|
|
2147
|
-
return React.createElement(CommerceProvider, null,
|
|
2145
|
+
return React.createElement(CommerceProvider, null, React.createElement(CartActionsProvider, {
|
|
2146
|
+
globalContextName: globalContextName
|
|
2147
|
+
}, children));
|
|
2148
2148
|
}
|
|
2149
2149
|
function registerCommerceProvider(loader, customCommerceProviderMeta) {
|
|
2150
2150
|
var doRegisterComponent = function doRegisterComponent() {
|