Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProductMatrix - Restricted Pricing not Enforced #57

Open
digitalalphas opened this issue Nov 16, 2017 · 0 comments
Open

ProductMatrix - Restricted Pricing not Enforced #57

digitalalphas opened this issue Nov 16, 2017 · 0 comments

Comments

@digitalalphas
Copy link

If a product is setup with Restricted price schedule, the user still sees an open textbox instead of a dropdown on the product page. A quick glance at the code, this solution appears to accommodate restricted price schedules but there is actually a bug preventing the dropdown to show and work correctly.

In order to get this working for a client, I switched "product.PriceSchedule" to "product.StandardPriceSchedule" in the template and added the function getRestrictedQtyText to the controller (modified version of quantityfield's function, to include the markup value in the results).

From:
(template snippet - 2 specs)
'<select id="451qa_input_qty" class="form-control" ng-change="qtyChanged()" ng-if="product.PriceSchedule.RestrictedQuantity" ng-model="item.Quantity" ng-options="pb.Quantity as getRestrictedQtyText(pb, product.QuantityMultiplier) for pb in product.PriceSchedule.PriceBreaks"><option value=""></option></select>', '<input id="451qa_input_qty" placeholder="0" autocomplete="off" class="form-control" ng-class="{\'qty-invalid\':item.QtyError}" ng-change="qtyChanged()" ng-if="!product.PriceSchedule.RestrictedQuantity" type="text" name="qtyInput" ng-model="item.Quantity"/>',
(template snippet - 1 spec)
'<select id="451qa_input_qty" class="form-control" ng-change="qtyChanged()" ng-if="product.PriceSchedule.RestrictedQuantity" ng-model="group[0].Quantity" ng-options="pb.Quantity as getRestrictedQtyText(pb, product.QuantityMultiplier) for pb in product.PriceSchedule.PriceBreaks"><option value=""></option></select>', '<input id="451qa_input_qty" placeholder="0" autocomplete="off" class="form-control" ng-class="{\'qty-invalid\':item.QtyError}" ng-change="qtyChanged()" ng-if="!product.PriceSchedule.RestrictedQuantity" type="text" name="qtyInput" ng-model="group[0].Quantity"/>',

To:
(template snippet - 2 specs)
'<select id="451qa_input_qty" class="form-control" ng-change="qtyChanged()" ng-if="product.StandardPriceSchedule.RestrictedQuantity" ng-model="item.Quantity" ng-options="pb.Quantity as getRestrictedQtyText(pb, product.QuantityMultiplier, item.Markup) for pb in product.StandardPriceSchedule.PriceBreaks"><option value=""></option></select>', '<input id="451qa_input_qty" placeholder="0" autocomplete="off" class="form-control" ng-class="{\'qty-invalid\':item.QtyError}" ng-change="qtyChanged()" ng-if="!product.StandardPriceSchedule.RestrictedQuantity" type="text" name="qtyInput" ng-model="item.Quantity"/>',
(template snippet - 1 spec)
'<select id="451qa_input_qty" class="form-control" ng-change="qtyChanged()" ng-if="product.StandardPriceSchedule.RestrictedQuantity" ng-model="group[0].Quantity" ng-options="pb.Quantity as getRestrictedQtyText(pb, product.QuantityMultiplier, group.Markup) for pb in product.StandardPriceSchedule.PriceBreaks"><option value=""></option></select>', '<input id="451qa_input_qty" placeholder="0" autocomplete="off" class="form-control" ng-class="{\'qty-invalid\':item.QtyError}" ng-change="qtyChanged()" ng-if="!product.StandardPriceSchedule.RestrictedQuantity" type="text" name="qtyInput" ng-model="group[0].Quantity"/>',

New function in ProductMatrixCtrl:
$scope.getRestrictedQtyText = function(priceBreak, qtyMultiplier, markUp){ if(!markUp) markUp = 0; var qtyText = priceBreak.Quantity * qtyMultiplier; if(qtyMultiplier > 1) qtyText += ' - $' + Number((priceBreak.Price + markUp) * priceBreak.Quantity).toFixed(2); else qtyText += ' - $' + Number(qtyText * (priceBreak.Price + markUp)).toFixed(2); return qtyText; };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant