dynamic /
foxystripe
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Dynamic\FoxyStripe\Page; |
||
| 4 | |||
| 5 | use SilverStripe\Control\Controller; |
||
| 6 | use SilverStripe\ORM\PaginatedList; |
||
| 7 | use SilverStripe\Security\Member; |
||
| 8 | use SilverStripe\Security\Security; |
||
| 9 | |||
| 10 | class OrderHistoryPage extends \Page |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var string |
||
| 14 | */ |
||
| 15 | private static $singular_name = 'Order History Page'; |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 16 | |||
| 17 | /** |
||
| 18 | * @var string |
||
| 19 | */ |
||
| 20 | private static $plural_name = 'Order History Pages'; |
||
|
0 ignored issues
–
show
|
|||
| 21 | |||
| 22 | /** |
||
| 23 | * @var string |
||
| 24 | */ |
||
| 25 | private static $description = 'Show a customers past orders. Requires authentication'; |
||
|
0 ignored issues
–
show
|
|||
| 26 | |||
| 27 | /** |
||
| 28 | * return all current Member's Orders. |
||
| 29 | * |
||
| 30 | * @param int $limit |
||
| 31 | * |
||
| 32 | * @return bool|PaginatedList |
||
| 33 | * |
||
| 34 | * @throws \Exception |
||
| 35 | */ |
||
| 36 | public function getOrders($limit = 10) |
||
| 37 | { |
||
| 38 | if ($Member = Security::getCurrentUser()) { |
||
| 39 | $Orders = $Member->Orders()->sort('TransactionDate', 'DESC'); |
||
| 40 | |||
| 41 | $list = new PaginatedList($Orders, Controller::curr()->getRequest()); |
||
| 42 | $list->setPageLength($limit); |
||
| 43 | |||
| 44 | return $list; |
||
| 45 | } |
||
| 46 | |||
| 47 | return false; |
||
| 48 | } |
||
| 49 | } |
||
| 50 |