@plasmicpkgs/commerce 0.0.7 → 0.0.8

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.
@@ -1234,12 +1234,13 @@ function AddToCartButton(props) {
1234
1234
  var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1235
1235
  var _form$getValues$Produ;
1236
1236
 
1237
- var quantity, variantId;
1237
+ var quantity, _form$getValues$Produ2, variantId;
1238
+
1238
1239
  return runtime_1.wrap(function _callee$(_context) {
1239
1240
  while (1) {
1240
1241
  switch (_context.prev = _context.next) {
1241
1242
  case 0:
1242
- quantity = (_form$getValues$Produ = +form.getValues()["ProductQuantity"]) != null ? _form$getValues$Produ : 1;
1243
+ quantity = +((_form$getValues$Produ = form.getValues()["ProductQuantity"]) != null ? _form$getValues$Produ : 1);
1243
1244
 
1244
1245
  if (!(isNaN(quantity) || quantity < 1)) {
1245
1246
  _context.next = 3;
@@ -1256,7 +1257,7 @@ function AddToCartButton(props) {
1256
1257
  break;
1257
1258
  }
1258
1259
 
1259
- variantId = form.getValues()["ProductVariant"];
1260
+ variantId = (_form$getValues$Produ2 = form.getValues()["ProductVariant"]) != null ? _form$getValues$Produ2 : product.variants[0].id;
1260
1261
  _context.next = 7;
1261
1262
  return addItem({
1262
1263
  productId: product.id,
@@ -1435,6 +1436,13 @@ var useBrands = function useBrands(input) {
1435
1436
  }, hook))(input);
1436
1437
  };
1437
1438
 
1439
+ var useCommerceExtraFeatures = function useCommerceExtraFeatures() {
1440
+ var _useCommerce = useCommerce(),
1441
+ providerRef = _useCommerce.providerRef;
1442
+
1443
+ return providerRef.current.extraFeatures;
1444
+ };
1445
+
1438
1446
  var productCollectionMeta = {
1439
1447
  name: "plasmic-commerce-product-collection",
1440
1448
  displayName: "Product Collection",
@@ -1473,6 +1481,14 @@ var productCollectionMeta = {
1473
1481
  })) != null ? _ctx$categories$map : [];
1474
1482
  }
1475
1483
  },
1484
+ includeSubCategories: {
1485
+ type: "boolean",
1486
+ hidden: function hidden(props, ctx) {
1487
+ var _ctx$features;
1488
+
1489
+ return !(ctx != null && (_ctx$features = ctx.features) != null && _ctx$features.includeSubCategories);
1490
+ }
1491
+ },
1476
1492
  brand: {
1477
1493
  type: "choice",
1478
1494
  options: function options(props, ctx) {
@@ -1504,27 +1520,33 @@ function ProductCollection(props) {
1504
1520
  children = props.children,
1505
1521
  count = props.count,
1506
1522
  category = props.category,
1523
+ includeSubCategories = props.includeSubCategories,
1507
1524
  brand = props.brand,
1508
1525
  noLayout = props.noLayout,
1509
1526
  setControlContextData = props.setControlContextData;
1510
1527
 
1528
+ var _useCategories = useCategories(),
1529
+ categories = _useCategories.data;
1530
+
1531
+ var _useBrands = useBrands(),
1532
+ brands = _useBrands.data;
1533
+
1511
1534
  var _useSearch = useSearch({
1512
1535
  categoryId: category,
1513
1536
  brandId: brand,
1514
- count: count
1537
+ count: count,
1538
+ categories: categories != null ? categories : [],
1539
+ includeSubCategories: includeSubCategories
1515
1540
  }),
1516
1541
  data = _useSearch.data;
1517
1542
 
1518
- var _useCategories = useCategories(),
1519
- categories = _useCategories.data;
1520
-
1521
- var _useBrands = useBrands(),
1522
- brands = _useBrands.data;
1543
+ var features = useCommerceExtraFeatures();
1523
1544
 
1524
1545
  if (categories && brands) {
1525
1546
  setControlContextData == null ? void 0 : setControlContextData({
1526
1547
  categories: categories,
1527
- brands: brands
1548
+ brands: brands,
1549
+ features: features
1528
1550
  });
1529
1551
  }
1530
1552
 
@@ -2009,10 +2031,6 @@ function registerCart(loader, customCartMeta) {
2009
2031
  doRegisterComponent(CartComponent, customCartMeta != null ? customCartMeta : cartMeta);
2010
2032
  }
2011
2033
 
2012
- var x = function x() {
2013
- return 2;
2014
- };
2015
-
2016
2034
 
2017
2035
 
2018
2036
  var product = {
@@ -2123,5 +2141,4 @@ exports.useProduct = useProduct$1;
2123
2141
  exports.useRemoveItem = useRemoveItem;
2124
2142
  exports.useSearch = useSearch;
2125
2143
  exports.useUpdateItem = useUpdateItem;
2126
- exports.x = x;
2127
2144
  //# sourceMappingURL=commerce.cjs.development.js.map