This repository has been archived by the owner on Apr 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VDS-800: Integrate configurable products backend with theme (#173)
* Integrate configurable backend with product page * Revert change for storefrontApp variable * Integrate configurable backend to checkout page * Integrate configurable backend to order detail page * Integrate configurable backend to configurable product card * Add missing dependencies * Fix custom part icon case * Fix console error on empty part items * Set default price 0 for unavailable configured product * Fix wrong default price for configurables * Hide panel if there's no parts
- Loading branch information
Showing
10 changed files
with
106 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 27 additions & 9 deletions
36
assets/js/controllers/product-card/configurable-product-card.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,40 @@ | ||
var storefrontApp = angular.module('storefrontApp'); | ||
|
||
storefrontApp.controller('configurableProductCardController', ['$scope', 'catalogService', '$filter', 'roundHelper', 'storeCurrency', | ||
function ($scope, catalogService, $filter, roundHelper, storeCurrency) { | ||
storefrontApp.controller('configurableProductCardController', ['$scope', 'catalogService', '$filter', 'storeCurrency', 'pricingService', | ||
function ($scope, catalogService, $filter, storeCurrency, pricingService) { | ||
$scope.isProductUnavailable = false; | ||
|
||
$scope.getDefaultPrice = function() { | ||
return $filter('currency')($scope.defaultPrice, storeCurrency.symbol); | ||
} | ||
|
||
$scope.initProductConfiguration = function(productId) { | ||
catalogService.getProductConfiguration(productId).then(function(response) { | ||
$scope.productParts = response.data; | ||
$scope.defaultProductParts = []; | ||
_.each($scope.productParts, function (part) { | ||
$scope.defaultProductParts.push(part.items.find(x => x.id === part.selectedItemId)); | ||
catalogService.getProduct([productId]).then(response => { | ||
let defaultPartsTotalsObject = []; | ||
$scope.productParts = response.data[0].parts; | ||
|
||
if ($scope.productParts.length) { | ||
_.each($scope.productParts, part => { | ||
if (!part.items || !part.items.length) { | ||
$scope.isProductUnavailable = true; | ||
return; | ||
} | ||
defaultPartsTotalsObject.push({id: part.items.find(x => x.id === part.selectedItemId).id, quantity: 1}); | ||
}); | ||
|
||
$scope.defaultPrice = roundHelper.bankersRound($scope.defaultProductParts.reduce((prev, cur) => prev + cur.price.actualPrice.amount, 0)); | ||
}); | ||
if (!$scope.isProductUnavailable) { | ||
pricingService.getProductsTotal(defaultPartsTotalsObject).then(result => { | ||
$scope.defaultPrice = $scope.showPricesWithTaxes ? result.data.totalWithTax.amount : result.data.total.amount; | ||
}); | ||
} else { | ||
$scope.defaultPrice = 0; | ||
} | ||
|
||
} else { | ||
$scope.defaultPrice = 0; | ||
} | ||
|
||
}); | ||
} | ||
|
||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.