Skip to content

Commit

Permalink
WIP: multi code discount constraint
Browse files Browse the repository at this point in the history
Relates to: #31
  • Loading branch information
jedateach committed Sep 15, 2014
1 parent 772923a commit 77151e3
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions code/constraints/MultiCodeDiscountConstraint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

class MultiCodeDiscountConstraint extends DiscountConstraint{

private static $has_many = array(
"Codes" => "DiscountCode"
);

function updateCMSFields(FieldList $fields){
//add datalist for codes
//create a datalist component for generating codes
}

public function filter(DataList $list) {
//TODO: join with Codes

return $list;
}

public function check(Discount $discount) {
$code = strtolower($this->findCouponCode());

//TODO: look for code in list

return true;
}

protected function findCouponCode() {
return isset($this->context['CouponCode']) ? $this->context['CouponCode'] : null;
}

}

class DiscountCode extends DataObject{

private static $db = array(
"Code" => "Varchar(25)"
);

}

0 comments on commit 77151e3

Please sign in to comment.