Skip to content

Commit

Permalink
add priority to promotions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Kerin committed Nov 1, 2013
1 parent 340e155 commit 9ef19d7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion classes/Kohana/Jam/Behavior/Promotable/Store/Purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ public function update_promotion_items(Model_Store_Purchase $store_purchase)
*/
public function available_promotions()
{
return Jam::all('promotion')->not_expired();
return Jam::all('promotion')->not_expired()->order_by('priority', 'ASC');
}
}
1 change: 1 addition & 0 deletions classes/Kohana/Model/Promotion.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public static function initialize(Jam_Meta $meta)
'currency' => Jam::field('string'),
'identifier' => Jam::field('string'),
'description' => Jam::field('text'),
'priority' => Jam::field('integer', array('default' => 1)),
'model' => Jam::field('polymorphic'),
'created_at' => Jam::field('timestamp', array(
'format' => 'Y-m-d H:i:s',
Expand Down
1 change: 1 addition & 0 deletions tests/test_data/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ CREATE TABLE `promotions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`identifier` varchar(255) DEFAULT NULL,
`priority` int(11) DEFAULT 0,
`model` varchar(100) DEFAULT NULL,
`requirement` varchar(255) DEFAULT NULL,
`amount` int(11) DEFAULT NULL,
Expand Down

0 comments on commit 9ef19d7

Please sign in to comment.