You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently DiscountConstraint extends DataExtension. This was merely to encapsulate the additional db / relation fields that need be extended on a Discount. Also encapsulated is the checking functions that look at those fields and decide if an order/item is within the constraint.
The problem is that it is quite messy. These classes are being instantiated on their own, with functions that are used quite statically. If one of the check or filter functions is called on a $discount object, then it will call only one of the constraints function's.
A restructuring could look like this:
BlahConstraint extends DiscountConstraint{
//has this constraint been added to the given discount//we automatically skip constraints that haven't been configured during checkingfunction applies(){
return$this->discount->FooList()->exists();
}
//does the order comply with this constraint
function check(){
//check if (something to do with the order) exists within FooList
}
//functionfilter(DataList$discounts) should be optional
}
BlahConstraint_DiscountExtensionextendsDiscountConstraintExtension{
private static $has_many = array(
'FooList' => 'Foo'
);
}
// elsewhere the DiscountConstraintExtensions are applied, based on a configured list of DiscountConstraints
The text was updated successfully, but these errors were encountered:
Currently DiscountConstraint extends DataExtension. This was merely to encapsulate the additional db / relation fields that need be extended on a Discount. Also encapsulated is the checking functions that look at those fields and decide if an order/item is within the constraint.
The problem is that it is quite messy. These classes are being instantiated on their own, with functions that are used quite statically. If one of the
check
orfilter
functions is called on a $discount object, then it will call only one of the constraints function's.A restructuring could look like this:
The text was updated successfully, but these errors were encountered: