Skip to content

ProductMatrix - Restricted Pricing not Enforced #57

@digitalalphas

Description

@digitalalphas

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; };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions