|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SilverShop\Page; |
|
4
|
|
|
|
|
5
|
|
|
use Page; |
|
|
|
|
|
|
6
|
|
|
use SilverStripe\CMS\Model\SiteTree; |
|
7
|
|
|
use SilverStripe\Control\Controller; |
|
8
|
|
|
use SilverStripe\Forms\DropdownField; |
|
9
|
|
|
use SilverStripe\Forms\FieldList; |
|
10
|
|
|
use SilverStripe\Forms\TreeDropdownField; |
|
11
|
|
|
use SilverStripe\ORM\DB; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* View and edit the cart in a full page. |
|
15
|
|
|
* Visitor can continue shopping, or proceed to checkout. |
|
16
|
|
|
*/ |
|
17
|
|
|
class CartPage extends Page |
|
18
|
|
|
{ |
|
19
|
|
|
private static $has_one = [ |
|
|
|
|
|
|
20
|
|
|
'CheckoutPage' => CheckoutPage::class, |
|
21
|
|
|
'ContinuePage' => SiteTree::class, |
|
22
|
|
|
]; |
|
23
|
|
|
|
|
24
|
|
|
private static $icon = 'silvershop/core: client/dist/images/icons/cart.gif'; |
|
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
private static $table_name = 'SilverShop_CartPage'; |
|
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Returns the link to the checkout page on this site |
|
30
|
|
|
* |
|
31
|
|
|
* @param boolean $urlSegment If set to TRUE, only returns the URLSegment field |
|
32
|
|
|
* |
|
33
|
|
|
* @return string Link to checkout page |
|
34
|
|
|
*/ |
|
35
|
|
|
public static function find_link($urlSegment = false, $action = false, $id = false) |
|
36
|
|
|
{ |
|
37
|
|
|
$base = CartPageController::config()->url_segment; |
|
38
|
|
|
if ($page = self::get()->first()) { |
|
39
|
|
|
$base = $page->Link(); |
|
40
|
|
|
} |
|
41
|
|
|
return Controller::join_links($base, $action, $id); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function getCMSFields() |
|
45
|
|
|
{ |
|
46
|
|
|
$this->beforeUpdateCMSFields( |
|
47
|
|
|
function (FieldList $fields) { |
|
48
|
|
|
if ($checkouts = CheckoutPage::get()) { |
|
49
|
|
|
$fields->addFieldToTab( |
|
50
|
|
|
'Root.Links', |
|
51
|
|
|
DropdownField::create( |
|
52
|
|
|
'CheckoutPageID', |
|
53
|
|
|
$this->fieldLabel('CheckoutPage'), |
|
54
|
|
|
$checkouts->map("ID", "Title") |
|
55
|
|
|
) |
|
56
|
|
|
); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
$fields->addFieldToTab( |
|
60
|
|
|
'Root.Links', |
|
61
|
|
|
TreeDropdownField::create( |
|
62
|
|
|
'ContinuePageID', |
|
63
|
|
|
$this->fieldLabel('ContinuePage'), |
|
64
|
|
|
SiteTree::class |
|
65
|
|
|
) |
|
66
|
|
|
); |
|
67
|
|
|
} |
|
68
|
|
|
); |
|
69
|
|
|
|
|
70
|
|
|
return parent::getCMSFields(); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* This module always requires a page model. |
|
75
|
|
|
*/ |
|
76
|
|
|
public function requireDefaultRecords() |
|
77
|
|
|
{ |
|
78
|
|
|
parent::requireDefaultRecords(); |
|
79
|
|
|
if (!self::get()->exists() && $this->config()->create_default_pages) { |
|
80
|
|
|
$page = self::create()->update( |
|
81
|
|
|
[ |
|
82
|
|
|
'Title' => 'Shopping Cart', |
|
83
|
|
|
'URLSegment' => CartPageController::config()->url_segment, |
|
84
|
|
|
'ShowInMenus' => 0, |
|
85
|
|
|
] |
|
86
|
|
|
); |
|
87
|
|
|
$page->write(); |
|
88
|
|
|
$page->publishSingle(); |
|
89
|
|
|
$page->flushCache(); |
|
90
|
|
|
DB::alteration_message('Cart page created', 'created'); |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths