Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/app/common/directives/oc-quantity-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ function OCQuantityInput(toastr, OrderCloud, $rootScope) {
product: '=',
lineitem: '=',
label: '@',
order: '='
order: '=',
onUpdate: '&'
},
templateUrl: 'common/templates/quantityInput.tpl.html',
replace: true,
Expand All @@ -22,13 +23,15 @@ function OCQuantityInput(toastr, OrderCloud, $rootScope) {
scope.item = scope.lineitem;
scope.content = "lineitem";
scope.updateQuantity = function() {
console.log('hit');
if (scope.item.Quantity > 0) {
OrderCloud.LineItems.Patch(scope.order.ID, scope.item.ID, {Quantity: scope.item.Quantity})
.then(function () {
.then(function (data) {
data.Product = scope.lineitem.Product;
scope.item = data;
scope.lineitem = data;
if (typeof scope.onUpdate === "function") scope.onUpdate(scope.lineitem);
toastr.success('Quantity Updated');
$rootScope.$broadcast('OC:UpdateOrder', scope.order.ID, 'Calculating Order Total');

});
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/app/common/templates/quantityInput.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
ng-min="{{item.Product.StandardPriceSchedule.MinQuantity}}"
ng-max="{{item.Product.StandardPriceSchedule.MaxQuantity}}"
ng-model="item.Quantity"
ng-model-options="{ debounce: 1500 }"
ng-model-options="{ debounce: 1000 }"
ng-change="updateQuantity()"
placeholder="Quantity">
<select id="itemQuantity"
Expand All @@ -42,7 +42,6 @@
ng-if="item.Product.StandardPriceSchedule.RestrictedQuantity"
class="form-control"
ng-model="item.Quantity"
ng-model-options="{ debounce: 1500 }"
ng-change="updateQuantity()"
ng-options="priceBreak.Quantity as priceBreak.Quantity for priceBreak in item.Product.StandardPriceSchedule.PriceBreaks"></select>
<small class="help-block" ng-if="item.Product.QuantityMultiplier > 1">
Expand Down