Total Complexity | 6 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
10 | class PurchasableExtension extends Extension |
||
11 | { |
||
12 | /** |
||
13 | * @var array |
||
14 | */ |
||
15 | private static $allowed_actions = array( |
||
|
|||
16 | 'AddToCartForm', |
||
17 | ); |
||
18 | |||
19 | public function onAfterInit() |
||
20 | { |
||
21 | if ($this->owner->data()->isAvailable()) { |
||
22 | if ($this->owner->data()->OptionTypes()->exists()) { |
||
23 | Requirements::javascript('silverstripe/admin: thirdparty/jquery/jquery.js'); |
||
24 | Requirements::javascript('dynamic/silverstripe-foxy: client/dist/javascript/product_options.js'); |
||
25 | } |
||
26 | Requirements::customScript(<<<JS |
||
27 | var productID = {$this->owner->data()->ID}; |
||
28 | JS |
||
29 | ); |
||
30 | } |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * @return FoxyStripePurchaseForm |
||
35 | */ |
||
36 | public function AddToCartForm() |
||
37 | { |
||
38 | if ($this->owner->data()->isAvailable()) { |
||
39 | $form = AddToCartForm::create($this->owner, __FUNCTION__, null, null, null, $this->owner->data()); |
||
40 | } else { |
||
41 | $form = false; |
||
42 | } |
||
43 | $this->owner->extend('updateAddToCartForm', $form); |
||
44 | return $form; |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @return string |
||
49 | */ |
||
50 | public function StoreURL() |
||
54 | } |
||
55 | } |
||
56 |