diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f000c8c4..d9f26dcd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -51,6 +51,8 @@ jobs: - name: Build if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' }} uses: VirtoCommerce/vc-github-actions/build-theme@master + with: + versionSuffix: ${{ steps.image.outputs.suffix }} - name: Publish if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' }} @@ -76,4 +78,4 @@ jobs: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: ${{ steps.publish.outputs.artifactPath }} asset_name: ${{ steps.publish.outputs.artifactName }} - asset_content_type: application/zip \ No newline at end of file + asset_content_type: application/zip diff --git a/assets/js/account/account-orders.js b/assets/js/account/account-orders.js index 10da1a19..f7da90b6 100644 --- a/assets/js/account/account-orders.js +++ b/assets/js/account/account-orders.js @@ -125,6 +125,36 @@ angular.module('storefront.account') $window.open(url, '_blank'); } + // $ctrl.reorder = function() { + // var productIdsQuery = $ctrl.order.items.map(item => { + // return 'productIds=' + item.productId; + // }).join("&"); + + // catalogService.getProducts(productIdsQuery).then(response => { + // if (response.data && response.data.length) { + // var configurationProducts = response.data.map(item => { + // return angular.extend(item, { quantity: _.findWhere($ctrl.order.items, {productId: item.id}).quantity }); + // }); + // var inventoryError = configurationProducts.some(product => { + // return product.availableQuantity < product.quantity; + // }); + // var dialogData = toDialogDataModel(configurationProducts, null, inventoryError, null); + // dialogService.showDialog(dialogData, 'recentlyAddedCartItemDialogController', 'storefront.recently-added-cart-item-dialog.tpl', 'lg'); + // if (!inventoryError) { + // var items = configurationProducts.map(product => { + // return { id: product.id, quantity: product.quantity }; + // }); + // cartService.addLineItems(items).then(res => { + // var result = res.data; + // if (result.isSuccess) { + // $rootScope.$broadcast('cartItemsChanged'); + // } + // }); + // } + // } + // }); + // } + $ctrl.paymentMethodChanged = function () { loader.wrapLoading(function() { $ctrl.selectedPaymentMethod = _.find($ctrl.paymentMethods, function (pm) { return pm.code == $ctrl.selectedPaymentMethodCode; }); @@ -165,6 +195,11 @@ angular.module('storefront.account') addProductToCartById(productId, quantity); }); + $scope.$on('configurationAdded', function (event, data) { + const {configuration} = data; + addConfigurationToCart(configuration); + }); + var components = []; $ctrl.addComponent = function (component) { components.push(component); @@ -188,7 +223,7 @@ angular.module('storefront.account') }; function addProductToCartById(productId, quantity) { - catalogService.getProduct([productId]).then(function (response) { + catalogService.getProduct([productId]).then(response => { if (response.data && response.data.length) { var product = response.data[0]; addProductToCart(product, quantity); @@ -196,17 +231,58 @@ angular.module('storefront.account') }); } - function addProductToCart(product, quantity) { - var dialogData = toDialogDataModel(product, quantity); - dialogService.showDialog(dialogData, 'recentlyAddedCartItemDialogController', 'storefront.recently-added-cart-item-dialog.tpl'); - cartService.addLineItem(product.id, quantity).then(function (response) { - $rootScope.$broadcast('cartItemsChanged'); + function addConfigurationToCart(configuration) { + let productIdsQuery = configuration.items.map(item => { + return 'productIds=' + item.productId; + }).join("&"); + + catalogService.getProducts(productIdsQuery).then(response => { + if (response.data && response.data.length) { + let configurationProducts = response.data.map(item => { + return angular.extend(item, { quantity: _.findWhere(configuration.items, {productId: item.id}).quantity }); + }); + let inventoryError = configurationProducts.some(product => { + return product.availableQuantity < product.quantity; + }); + let dialogData = toDialogDataModel(configurationProducts, configuration.quantity, inventoryError, configuration.productId); + dialogService.showDialog(dialogData, 'recentlyAddedCartItemDialogController', 'storefront.recently-added-cart-item-dialog.tpl', 'lg'); + if (!inventoryError) { + let items = configurationProducts.map(product => { + return { id: product.id, quantity: product.quantity, configuredProductId: configuration.productId }; + }); + cartService.addLineItems(items).then(res => { + let result = res.data; + if (result.isSuccess) { + $rootScope.$broadcast('cartItemsChanged'); + } + }); + } + } }); } - function toDialogDataModel(product, quantity) { - return { items: [angular.extend({ }, product, { quantity: quantity })] }; + function addProductToCart(product, quantity) { + var inventoryError = product.availableQuantity < quantity; + angular.extend(product, { quantity }); + var dialogData = toDialogDataModel([product], null, inventoryError, null); + dialogService.showDialog(dialogData, 'recentlyAddedCartItemDialogController', 'storefront.recently-added-cart-item-dialog.tpl', 'lg'); + if (!inventoryError) { + cartService.addLineItem(product.id, quantity).then(() => { + $rootScope.$broadcast('cartItemsChanged'); + }); + } + } + + function toDialogDataModel(products, configurationQty, inventoryError, configuredProductId) { + let productIds = products.map(product => { + return product.productId; + }); + let items = products.map(product => { + return angular.extend({ }, product, { inventoryError: product.availableQuantity < product.quantity, configuredProductId: configuredProductId }) + }); + return { productIds, items, inventoryError, configuredProductId, configurationQty }; } + }] }) .filter('orderToSummarizedStatusLabel', [function () { diff --git a/assets/js/account/account-orders.tpl.liquid b/assets/js/account/account-orders.tpl.liquid index 711e957c..d4ca3a61 100644 --- a/assets/js/account/account-orders.tpl.liquid +++ b/assets/js/account/account-orders.tpl.liquid @@ -75,7 +75,7 @@
{% capture order_number %}{% raw %}{{$ctrl.orderNumber}}{% endraw %}{% endcapture %} -

{{ 'customer.order.title' | t: order_number }}

+

{{ 'customer.order.title' | t: order_number }}

{{ 'customer.orders.status' | t }}:

@@ -98,11 +98,9 @@
-
-
-
- -
+
+
+
diff --git a/assets/js/app/consts.js.liquid b/assets/js/app/consts.js.liquid index a0dc21e5..61391bdf 100644 --- a/assets/js/app/consts.js.liquid +++ b/assets/js/app/consts.js.liquid @@ -10,6 +10,7 @@ angular.module('storefrontApp.consts', []) .constant('sortAscending', 'asc') .constant('sortDescending', 'desc') .constant('orderStatuses', ['Unpaid','Paid','Completed']) +.constant('storeCurrency', {{ current_currency | json }}) .constant('itemResponseGroup', { None: 0, ItemInfo: 1, diff --git a/assets/js/checkout/checkout-configurable-line-item.js b/assets/js/checkout/checkout-configurable-line-item.js index 73b5c870..c7057351 100644 --- a/assets/js/checkout/checkout-configurable-line-item.js +++ b/assets/js/checkout/checkout-configurable-line-item.js @@ -8,8 +8,7 @@ storefrontApp.component('vcCheckoutConfigurableLineItem', { bindings: { item: '=', onChangeQty: '&', - onRemove: '&', - cartItems: '<' + onRemove: '&' }, controller: ['$scope', 'availablePaymentPlans', 'baseUrl', function ($scope, availablePaymentPlans, baseUrl) { var ctrl = this; @@ -28,12 +27,12 @@ storefrontApp.component('vcCheckoutConfigurableLineItem', { this.changeQty = function () { if (ctrl.onChangeQty) { - ctrl.onChangeQty({ item: ctrl.item.configuredLineItem }); + ctrl.onChangeQty({ item: ctrl.item }); } }; this.remove = function () { - ctrl.onRemove({ item: ctrl.item.configuredLineItem }); + ctrl.onRemove({ item: ctrl.item }); } this.validate = function () { @@ -53,7 +52,7 @@ storefrontApp.component('vcCheckoutConfigurableLineItem', { function getConfiguredLineItems(item) { _.each(item.parts, function (part) { - part.items = [ctrl.cartItems.find(x => x.id === part.selectedItemId)]; + part.items = [item.items.find(x => x.id === part.selectedItemId)]; }); } diff --git a/assets/js/checkout/checkout-configurable-line-item.tpl.html.liquid b/assets/js/checkout/checkout-configurable-line-item.tpl.html.liquid index c5483db4..e110892e 100644 --- a/assets/js/checkout/checkout-configurable-line-item.tpl.html.liquid +++ b/assets/js/checkout/checkout-configurable-line-item.tpl.html.liquid @@ -1,33 +1,33 @@
- {% raw %}{{ $ctrl.item.configuredLineItem.name }}{% endraw %} + {% raw %}{{ $ctrl.item.product.name }}{% endraw %}
-

-

Item

+

+

Item

Price {% if settings.show_prices_with_taxes %} - + {% else %} - + {% endif %} / each

- +

-