Completed
Push — copilot/remove-outdated-badges... ( 4a4e1f...d46ff8 )
by
unknown
11:28 queued 11:15
created
src/ORM/CustomerExtension.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -16,49 +16,49 @@
 block discarded – undo
16 16
  */
17 17
 class CustomerExtension extends DataExtension
18 18
 {
19
-    /**
20
-     * @var array
21
-     */
22
-    private static $db = [
23
-        'Customer_ID' => 'Int',
24
-    ];
19
+	/**
20
+	 * @var array
21
+	 */
22
+	private static $db = [
23
+		'Customer_ID' => 'Int',
24
+	];
25 25
 
26
-    /**
27
-     * @var array
28
-     */
29
-    private static $has_many = [
30
-        'Orders' => Order::class,
31
-    ];
26
+	/**
27
+	 * @var array
28
+	 */
29
+	private static $has_many = [
30
+		'Orders' => Order::class,
31
+	];
32 32
 
33
-    /**
34
-     * @var array
35
-     */
36
-    private static $indexes = [
37
-        'Customer_ID' => true, // make unique
38
-    ];
33
+	/**
34
+	 * @var array
35
+	 */
36
+	private static $indexes = [
37
+		'Customer_ID' => true, // make unique
38
+	];
39 39
 
40
-    /**
41
-     * @throws \Psr\Container\NotFoundExceptionInterface
42
-     */
43
-    public function onBeforeWrite()
44
-    {
45
-        parent::onBeforeWrite();
40
+	/**
41
+	 * @throws \Psr\Container\NotFoundExceptionInterface
42
+	 */
43
+	public function onBeforeWrite()
44
+	{
45
+		parent::onBeforeWrite();
46 46
 
47
-        // if Member data was imported from FoxyCart, PasswordEncryption will be set to 'none'.
48
-        // Change to sh1_v2.4 to ensure SilverStripe is using the same hash as FoxyCart API 1.1
49
-        if (!$this->owner->PasswordEncryption && (
50
-                $this->owner->PasswordEncryption == null || $this->owner->PasswordEncryption == 'none'
51
-            )) {
52
-            $this->owner->PasswordEncryption = 'sha1_v2.4';
53
-        }
47
+		// if Member data was imported from FoxyCart, PasswordEncryption will be set to 'none'.
48
+		// Change to sh1_v2.4 to ensure SilverStripe is using the same hash as FoxyCart API 1.1
49
+		if (!$this->owner->PasswordEncryption && (
50
+				$this->owner->PasswordEncryption == null || $this->owner->PasswordEncryption == 'none'
51
+			)) {
52
+			$this->owner->PasswordEncryption = 'sha1_v2.4';
53
+		}
54 54
 
55
-        // Send updated customer data to Foxy Cart via API
56
-        $response = FoxyCart::putCustomer($this->owner);
55
+		// Send updated customer data to Foxy Cart via API
56
+		$response = FoxyCart::putCustomer($this->owner);
57 57
 
58
-        // Grab customer_id record from FoxyCart response, store in Member
59
-        if ($response) {
60
-            $foxyResponse = new \SimpleXMLElement($response);
61
-            $this->owner->Customer_ID = (int)$foxyResponse->customer_id;
62
-        }
63
-    }
58
+		// Grab customer_id record from FoxyCart response, store in Member
59
+		if ($response) {
60
+			$foxyResponse = new \SimpleXMLElement($response);
61
+			$this->owner->Customer_ID = (int)$foxyResponse->customer_id;
62
+		}
63
+	}
64 64
 }
Please login to merge, or discard this patch.
src/ORM/FoxyStripeProductFormFieldExtension.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -11,18 +11,18 @@
 block discarded – undo
11 11
  */
12 12
 class FoxyStripeProductFormFieldExtension extends DataExtension
13 13
 {
14
-    /**
15
-     * @param $attributes
16
-     */
17
-    public function updateAttributes(&$attributes)
18
-    {
19
-        if (Controller::curr() instanceof ContentController &&
20
-            Controller::curr()->data()->Classname == 'DonationProduct'
21
-        ) {
22
-            if (preg_match('/^(product_id)/', $this->owner->getName())) {
23
-                $attributes['h:name'] = $attributes['name'];
24
-                unset($attributes['name']);
25
-            }
26
-        }
27
-    }
14
+	/**
15
+	 * @param $attributes
16
+	 */
17
+	public function updateAttributes(&$attributes)
18
+	{
19
+		if (Controller::curr() instanceof ContentController &&
20
+			Controller::curr()->data()->Classname == 'DonationProduct'
21
+		) {
22
+			if (preg_match('/^(product_id)/', $this->owner->getName())) {
23
+				$attributes['h:name'] = $attributes['name'];
24
+				unset($attributes['name']);
25
+			}
26
+		}
27
+	}
28 28
 }
Please login to merge, or discard this patch.
src/ORM/FoxyStripePageExtension.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -9,21 +9,21 @@
 block discarded – undo
9 9
 
10 10
 class FoxyStripePageExtension extends Extension
11 11
 {
12
-    /**
13
-     * @throws \SilverStripe\ORM\ValidationException
14
-     */
15
-    public function onAfterInit()
16
-    {
17
-        $config = FoxyStripeSetting::current_foxystripe_setting();
12
+	/**
13
+	 * @throws \SilverStripe\ORM\ValidationException
14
+	 */
15
+	public function onAfterInit()
16
+	{
17
+		$config = FoxyStripeSetting::current_foxystripe_setting();
18 18
 
19
-        if ($config->EnableSidecart) {
20
-            Requirements::javascript(
21
-                "https://cdn.foxycart.com/" . FoxyCart::getFoxyCartStoreName() . "/loader.js",
22
-                [
23
-                    "async" => true,
24
-                    "defer" => true,
25
-                ]
26
-            );
27
-        }
28
-    }
19
+		if ($config->EnableSidecart) {
20
+			Requirements::javascript(
21
+				"https://cdn.foxycart.com/" . FoxyCart::getFoxyCartStoreName() . "/loader.js",
22
+				[
23
+					"async" => true,
24
+					"defer" => true,
25
+				]
26
+			);
27
+		}
28
+	}
29 29
 }
Please login to merge, or discard this patch.
src/Page/DonationProduct.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -6,43 +6,43 @@
 block discarded – undo
6 6
 
7 7
 class DonationProduct extends ProductPage
8 8
 {
9
-    /**
10
-     * @var string
11
-     */
12
-    private static $singular_name = 'Donation';
13
-
14
-    /**
15
-     * @var string
16
-     */
17
-    private static $plural_name = 'Donations';
18
-
19
-    /**
20
-     * @var array
21
-     */
22
-    //private static $allowed_children = [];
23
-
24
-    /**
25
-     * @var bool
26
-     */
27
-    private static $can_be_root = true;
28
-
29
-    /**
30
-     * @var string
31
-     */
32
-    private static $table_name = 'DonationProduct';
33
-
34
-    /**
35
-     * @return FieldList
36
-     */
37
-    public function getCMSFields()
38
-    {
39
-        $fields = parent::getCMSFields();
40
-
41
-        $fields->removeByName([
42
-            'Weight',
43
-            'Price',
44
-        ]);
45
-
46
-        return $fields;
47
-    }
9
+	/**
10
+	 * @var string
11
+	 */
12
+	private static $singular_name = 'Donation';
13
+
14
+	/**
15
+	 * @var string
16
+	 */
17
+	private static $plural_name = 'Donations';
18
+
19
+	/**
20
+	 * @var array
21
+	 */
22
+	//private static $allowed_children = [];
23
+
24
+	/**
25
+	 * @var bool
26
+	 */
27
+	private static $can_be_root = true;
28
+
29
+	/**
30
+	 * @var string
31
+	 */
32
+	private static $table_name = 'DonationProduct';
33
+
34
+	/**
35
+	 * @return FieldList
36
+	 */
37
+	public function getCMSFields()
38
+	{
39
+		$fields = parent::getCMSFields();
40
+
41
+		$fields->removeByName([
42
+			'Weight',
43
+			'Price',
44
+		]);
45
+
46
+		return $fields;
47
+	}
48 48
 }
Please login to merge, or discard this patch.
src/Page/ProductPage.php 1 patch
Indentation   +463 added lines, -463 removed lines patch added patch discarded remove patch
@@ -56,189 +56,189 @@  discard block
 block discarded – undo
56 56
  */
57 57
 class ProductPage extends \Page implements PermissionProvider
58 58
 {
59
-    /**
60
-     * @var string
61
-     */
62
-    private static $default_parent = ProductHolder::class;
63
-
64
-    /**
65
-     * @var bool
66
-     */
67
-    private static $can_be_root = false;
68
-
69
-    /**
70
-     * @var array
71
-     */
72
-    private static $db = [
73
-        'Price' => 'Currency',
74
-        'Weight' => 'Decimal',
75
-        'Code' => 'Varchar(100)',
76
-        'ReceiptTitle' => 'HTMLVarchar(255)',
77
-        'Available' => 'Boolean',
78
-    ];
79
-
80
-    /**
81
-     * @var array
82
-     */
83
-    private static $has_one = [
84
-        'Category' => ProductCategory::class,
85
-    ];
86
-
87
-    /**
88
-     * @var array
89
-     */
90
-    private static $has_many = [
91
-        'ProductOptions' => OptionItem::class,
92
-        'OrderDetails' => OrderDetail::class,
93
-    ];
94
-
95
-    /**
96
-     * @var array
97
-     */
98
-    private static $many_many = [
99
-        'Images' => Image::class,
100
-    ];
101
-
102
-    /**
103
-     * @var array
104
-     */
105
-    private static $many_many_extraFields = [
106
-        'Images' => [
107
-            'SortOrder' => 'Int',
108
-        ],
109
-    ];
110
-
111
-    /**
112
-     * @var array
113
-     */
114
-    private static $owns = [
115
-        'Images',
116
-    ];
117
-
118
-    /**
119
-     * @var array
120
-     */
121
-    private static $belongs_many_many = [
122
-        'ProductHolders' => ProductHolder::class,
123
-    ];
124
-
125
-    /**
126
-     * @var string
127
-     */
128
-    private static $singular_name = 'Product';
129
-
130
-    /**
131
-     * @var string
132
-     */
133
-    private static $plural_name = 'Products';
134
-
135
-    /**
136
-     * @var string
137
-     */
138
-    private static $description = 'A product that can be added to the shopping cart';
139
-
140
-    /**
141
-     * @var array
142
-     */
143
-    private static $indexes = [
144
-        'Code' => [
145
-            'type' => 'unique',
146
-            'columns' => ['Code'],
147
-        ],
148
-    ];
149
-
150
-    /**
151
-     * @var array
152
-     */
153
-    private static $defaults = [
154
-        'ShowInMenus' => false,
155
-        'Available' => true,
156
-        'Weight' => '0.0',
157
-    ];
158
-
159
-    /**
160
-     * @var array
161
-     */
162
-    private static $summary_fields = [
163
-        'Image.CMSThumbnail',
164
-        'Title',
165
-        'Code',
166
-        'Price.Nice',
167
-        'Category.Title',
168
-    ];
169
-
170
-    /**
171
-     * @var array
172
-     */
173
-    private static $searchable_fields = [
174
-        'Title',
175
-        'Code',
176
-        'Available',
177
-        'Category.ID',
178
-    ];
179
-
180
-    /**
181
-     * @var string
182
-     */
183
-    private static $table_name = 'ProductPage';
184
-
185
-    /**
186
-     * Construct a new ProductPage.
187
-     *
188
-     * @param array|null $record Used internally for rehydrating an object from database content.
189
-     *                           Bypasses setters on this class, and hence should not be used
190
-     *                           for populating data on new records.
191
-     * @param boolean $isSingleton This this to true if this is a singleton() object, a stub for calling methods.
192
-     *                             Singletons don't have their defaults set.
193
-     * @param array $queryParams List of DataQuery params necessary to lazy load, or load related objects.
194
-     */
195
-    public function __construct($record = null, $isSingleton = false, $queryParams = [])
196
-    {
197
-        parent::__construct($record, $isSingleton, $queryParams);
198
-
199
-        if (Controller::has_curr()) {
200
-            if (Controller::curr() instanceof ContentController) {
201
-                Requirements::javascript('dynamic/foxystripe: javascript/quantity.js');
202
-                Requirements::css('dynamic/foxystripe: client/dist/css/quantityfield.css');
203
-            }
204
-        }
205
-    }
206
-
207
-    /**
208
-     * @param bool $includerelations
209
-     *
210
-     * @return array
211
-     */
212
-    public function fieldLabels($includerelations = true)
213
-    {
214
-        $labels = parent::fieldLabels();
215
-
216
-        $labels['Title'] = _t('ProductPage.TitleLabel', 'Name');
217
-        $labels['Code'] = _t('ProductPage.CodeLabel', 'Code');
218
-        $labels['Price.Nice'] = _t('ProductPage.PriceLabel', 'Price');
219
-        $labels['Available.Nice'] = _t('ProductPage.AvailableLabel', 'Available');
220
-        $labels['Category.ID'] = _t('ProductPage.IDLabel', 'Category');
221
-        $labels['Category.Title'] = _t('ProductPage.CategoryTitleLabel', 'Category');
222
-        $labels['Image.CMSThumbnail'] = _t('ProductPage.ImageLabel', 'Image');
223
-
224
-        return $labels;
225
-    }
226
-
227
-    /**
228
-     * @return \SilverStripe\Forms\FieldList
229
-     */
230
-    public function getCMSFields()
231
-    {
232
-        $this->beforeUpdateCMSFields(function (FieldList $fields) {
233
-            // Cateogry Dropdown field w/ add new
234
-            $source = function () {
235
-                return ProductCategory::get()->map()->toArray();
236
-            };
237
-            $catField = DropdownField::create('CategoryID', _t('ProductPage.Category', 'FoxyCart Category'), $source())
238
-                ->setEmptyString('')
239
-                ->setDescription(_t(
240
-                    'ProductPage.CategoryDescription',
241
-                    'Required, must also exist in 
59
+	/**
60
+	 * @var string
61
+	 */
62
+	private static $default_parent = ProductHolder::class;
63
+
64
+	/**
65
+	 * @var bool
66
+	 */
67
+	private static $can_be_root = false;
68
+
69
+	/**
70
+	 * @var array
71
+	 */
72
+	private static $db = [
73
+		'Price' => 'Currency',
74
+		'Weight' => 'Decimal',
75
+		'Code' => 'Varchar(100)',
76
+		'ReceiptTitle' => 'HTMLVarchar(255)',
77
+		'Available' => 'Boolean',
78
+	];
79
+
80
+	/**
81
+	 * @var array
82
+	 */
83
+	private static $has_one = [
84
+		'Category' => ProductCategory::class,
85
+	];
86
+
87
+	/**
88
+	 * @var array
89
+	 */
90
+	private static $has_many = [
91
+		'ProductOptions' => OptionItem::class,
92
+		'OrderDetails' => OrderDetail::class,
93
+	];
94
+
95
+	/**
96
+	 * @var array
97
+	 */
98
+	private static $many_many = [
99
+		'Images' => Image::class,
100
+	];
101
+
102
+	/**
103
+	 * @var array
104
+	 */
105
+	private static $many_many_extraFields = [
106
+		'Images' => [
107
+			'SortOrder' => 'Int',
108
+		],
109
+	];
110
+
111
+	/**
112
+	 * @var array
113
+	 */
114
+	private static $owns = [
115
+		'Images',
116
+	];
117
+
118
+	/**
119
+	 * @var array
120
+	 */
121
+	private static $belongs_many_many = [
122
+		'ProductHolders' => ProductHolder::class,
123
+	];
124
+
125
+	/**
126
+	 * @var string
127
+	 */
128
+	private static $singular_name = 'Product';
129
+
130
+	/**
131
+	 * @var string
132
+	 */
133
+	private static $plural_name = 'Products';
134
+
135
+	/**
136
+	 * @var string
137
+	 */
138
+	private static $description = 'A product that can be added to the shopping cart';
139
+
140
+	/**
141
+	 * @var array
142
+	 */
143
+	private static $indexes = [
144
+		'Code' => [
145
+			'type' => 'unique',
146
+			'columns' => ['Code'],
147
+		],
148
+	];
149
+
150
+	/**
151
+	 * @var array
152
+	 */
153
+	private static $defaults = [
154
+		'ShowInMenus' => false,
155
+		'Available' => true,
156
+		'Weight' => '0.0',
157
+	];
158
+
159
+	/**
160
+	 * @var array
161
+	 */
162
+	private static $summary_fields = [
163
+		'Image.CMSThumbnail',
164
+		'Title',
165
+		'Code',
166
+		'Price.Nice',
167
+		'Category.Title',
168
+	];
169
+
170
+	/**
171
+	 * @var array
172
+	 */
173
+	private static $searchable_fields = [
174
+		'Title',
175
+		'Code',
176
+		'Available',
177
+		'Category.ID',
178
+	];
179
+
180
+	/**
181
+	 * @var string
182
+	 */
183
+	private static $table_name = 'ProductPage';
184
+
185
+	/**
186
+	 * Construct a new ProductPage.
187
+	 *
188
+	 * @param array|null $record Used internally for rehydrating an object from database content.
189
+	 *                           Bypasses setters on this class, and hence should not be used
190
+	 *                           for populating data on new records.
191
+	 * @param boolean $isSingleton This this to true if this is a singleton() object, a stub for calling methods.
192
+	 *                             Singletons don't have their defaults set.
193
+	 * @param array $queryParams List of DataQuery params necessary to lazy load, or load related objects.
194
+	 */
195
+	public function __construct($record = null, $isSingleton = false, $queryParams = [])
196
+	{
197
+		parent::__construct($record, $isSingleton, $queryParams);
198
+
199
+		if (Controller::has_curr()) {
200
+			if (Controller::curr() instanceof ContentController) {
201
+				Requirements::javascript('dynamic/foxystripe: javascript/quantity.js');
202
+				Requirements::css('dynamic/foxystripe: client/dist/css/quantityfield.css');
203
+			}
204
+		}
205
+	}
206
+
207
+	/**
208
+	 * @param bool $includerelations
209
+	 *
210
+	 * @return array
211
+	 */
212
+	public function fieldLabels($includerelations = true)
213
+	{
214
+		$labels = parent::fieldLabels();
215
+
216
+		$labels['Title'] = _t('ProductPage.TitleLabel', 'Name');
217
+		$labels['Code'] = _t('ProductPage.CodeLabel', 'Code');
218
+		$labels['Price.Nice'] = _t('ProductPage.PriceLabel', 'Price');
219
+		$labels['Available.Nice'] = _t('ProductPage.AvailableLabel', 'Available');
220
+		$labels['Category.ID'] = _t('ProductPage.IDLabel', 'Category');
221
+		$labels['Category.Title'] = _t('ProductPage.CategoryTitleLabel', 'Category');
222
+		$labels['Image.CMSThumbnail'] = _t('ProductPage.ImageLabel', 'Image');
223
+
224
+		return $labels;
225
+	}
226
+
227
+	/**
228
+	 * @return \SilverStripe\Forms\FieldList
229
+	 */
230
+	public function getCMSFields()
231
+	{
232
+		$this->beforeUpdateCMSFields(function (FieldList $fields) {
233
+			// Cateogry Dropdown field w/ add new
234
+			$source = function () {
235
+				return ProductCategory::get()->map()->toArray();
236
+			};
237
+			$catField = DropdownField::create('CategoryID', _t('ProductPage.Category', 'FoxyCart Category'), $source())
238
+				->setEmptyString('')
239
+				->setDescription(_t(
240
+					'ProductPage.CategoryDescription',
241
+					'Required, must also exist in 
242 242
                     <a href="https://admin.foxycart.com/admin.php?ThisAction=ManageProductCategories" target="_blank">
243 243
                         FoxyCart Categories
244 244
                     </a>.
@@ -246,119 +246,119 @@  discard block
 block discarded – undo
246 246
                         <a href="admin/settings">
247 247
                             Settings > FoxyStripe > Categories
248 248
                         </a>'
249
-                ));
250
-            if (class_exists('QuickAddNewExtension')) {
251
-                $catField->useAddNew('ProductCategory', $source);
252
-            }
253
-
254
-            $fields->addFieldsToTab(
255
-                'Root.Main',
256
-                [
257
-                    TextField::create('Code')
258
-                        ->setTitle(_t('ProductPage.Code', 'Product Code'))
259
-                        ->setDescription(_t(
260
-                            'ProductPage.CodeDescription',
261
-                            'Required, must be unique. Product identifier used by FoxyCart in transactions'
262
-                        )),
263
-                    CurrencyField::create('Price')
264
-                        ->setTitle(_t('ProductPage.Price', 'Price'))
265
-                        ->setDescription(_t(
266
-                            'ProductPage.PriceDescription',
267
-                            'Base price for this product. Can be modified using Product Options'
268
-                        )),
269
-                    NumericField::create('Weight')
270
-                        ->setTitle(_t('ProductPage.Weight', 'Weight'))
271
-                        ->setDescription(_t(
272
-                            'ProductPage.WeightDescription',
273
-                            'Base weight for this product in lbs. Can be modified using Product Options'
274
-                        ))
275
-                        ->setScale(2),
276
-                    $catField,
277
-                ],
278
-                'Content'
279
-            );
280
-
281
-            // Product Options field
282
-            $config = GridFieldConfig_RelationEditor::create();
283
-            $config->addComponent(new GridFieldOrderableRows('SortOrder'));
284
-            $products = $this->ProductOptions()->sort('SortOrder');
285
-            $config->removeComponentsByType(GridFieldAddExistingAutocompleter::class);
286
-            $prodOptField = GridField::create(
287
-                'ProductOptions',
288
-                _t('ProductPage.ProductOptions', 'Options'),
289
-                $products,
290
-                $config
291
-            );
292
-
293
-            // Details tab
294
-            $fields->addFieldsToTab('Root.Details', [
295
-                CheckboxField::create('Available')
296
-                    ->setTitle(_t('ProductPage.Available', 'Available for purchase'))
297
-                    ->setDescription(_t(
298
-                        'ProductPage.AvailableDescription',
299
-                        'If unchecked, will remove "Add to Cart" form and instead display "Currently unavailable"'
300
-                    )),
301
-                TextField::create('ReceiptTitle')
302
-                    ->setTitle(_t('ProductPage.ReceiptTitle', 'Product Title for Receipt'))
303
-                    ->setDescription(_t(
304
-                        'ProductPage.ReceiptTitleDescription',
305
-                        'Optional'
306
-                    )),
307
-            ]);
308
-
309
-            // Options Tab
310
-            $fields->addFieldsToTab('Root.Options', [
311
-                $prodOptField
312
-                    ->setDescription(_t(
313
-                        'Page.OptionsDescrip',
314
-                        '<p>Product Options allow products to be customized by attributes such as size or color.
249
+				));
250
+			if (class_exists('QuickAddNewExtension')) {
251
+				$catField->useAddNew('ProductCategory', $source);
252
+			}
253
+
254
+			$fields->addFieldsToTab(
255
+				'Root.Main',
256
+				[
257
+					TextField::create('Code')
258
+						->setTitle(_t('ProductPage.Code', 'Product Code'))
259
+						->setDescription(_t(
260
+							'ProductPage.CodeDescription',
261
+							'Required, must be unique. Product identifier used by FoxyCart in transactions'
262
+						)),
263
+					CurrencyField::create('Price')
264
+						->setTitle(_t('ProductPage.Price', 'Price'))
265
+						->setDescription(_t(
266
+							'ProductPage.PriceDescription',
267
+							'Base price for this product. Can be modified using Product Options'
268
+						)),
269
+					NumericField::create('Weight')
270
+						->setTitle(_t('ProductPage.Weight', 'Weight'))
271
+						->setDescription(_t(
272
+							'ProductPage.WeightDescription',
273
+							'Base weight for this product in lbs. Can be modified using Product Options'
274
+						))
275
+						->setScale(2),
276
+					$catField,
277
+				],
278
+				'Content'
279
+			);
280
+
281
+			// Product Options field
282
+			$config = GridFieldConfig_RelationEditor::create();
283
+			$config->addComponent(new GridFieldOrderableRows('SortOrder'));
284
+			$products = $this->ProductOptions()->sort('SortOrder');
285
+			$config->removeComponentsByType(GridFieldAddExistingAutocompleter::class);
286
+			$prodOptField = GridField::create(
287
+				'ProductOptions',
288
+				_t('ProductPage.ProductOptions', 'Options'),
289
+				$products,
290
+				$config
291
+			);
292
+
293
+			// Details tab
294
+			$fields->addFieldsToTab('Root.Details', [
295
+				CheckboxField::create('Available')
296
+					->setTitle(_t('ProductPage.Available', 'Available for purchase'))
297
+					->setDescription(_t(
298
+						'ProductPage.AvailableDescription',
299
+						'If unchecked, will remove "Add to Cart" form and instead display "Currently unavailable"'
300
+					)),
301
+				TextField::create('ReceiptTitle')
302
+					->setTitle(_t('ProductPage.ReceiptTitle', 'Product Title for Receipt'))
303
+					->setDescription(_t(
304
+						'ProductPage.ReceiptTitleDescription',
305
+						'Optional'
306
+					)),
307
+			]);
308
+
309
+			// Options Tab
310
+			$fields->addFieldsToTab('Root.Options', [
311
+				$prodOptField
312
+					->setDescription(_t(
313
+						'Page.OptionsDescrip',
314
+						'<p>Product Options allow products to be customized by attributes such as size or color.
315 315
                     Options can also modify the product\'s price, weight or code.<br></p>'
316
-                    )),
317
-            ]);
318
-
319
-            // Images tab
320
-            $images = SortableUploadField::create('Images')
321
-                ->setSortColumn('SortOrder')
322
-                ->setIsMultiUpload(true)
323
-                ->setAllowedFileCategories('image')
324
-                ->setFolderName('Uploads/Products/Images');
325
-
326
-            $fields->addFieldsToTab('Root.Images', [
327
-                $images,
328
-            ]);
329
-
330
-            if (FoxyCart::store_name_warning() !== null) {
331
-                $fields->addFieldToTab('Root.Main', LiteralField::create('StoreSubDomainHeaderWarning', _t(
332
-                    'ProductPage.StoreSubDomainHeaderWarning',
333
-                    '<p class="message error">Store sub-domain must be entered in the 
316
+					)),
317
+			]);
318
+
319
+			// Images tab
320
+			$images = SortableUploadField::create('Images')
321
+				->setSortColumn('SortOrder')
322
+				->setIsMultiUpload(true)
323
+				->setAllowedFileCategories('image')
324
+				->setFolderName('Uploads/Products/Images');
325
+
326
+			$fields->addFieldsToTab('Root.Images', [
327
+				$images,
328
+			]);
329
+
330
+			if (FoxyCart::store_name_warning() !== null) {
331
+				$fields->addFieldToTab('Root.Main', LiteralField::create('StoreSubDomainHeaderWarning', _t(
332
+					'ProductPage.StoreSubDomainHeaderWarning',
333
+					'<p class="message error">Store sub-domain must be entered in the 
334 334
                         <a href="/admin/settings/">site settings</a></p>'
335
-                )), 'Title');
336
-            }
337
-        });
338
-
339
-        return parent::getCMSFields();
340
-    }
341
-
342
-    /**
343
-     * @return RequiredFields
344
-     */
345
-    public function getCMSValidator()
346
-    {
347
-        return new RequiredFields(['CategoryID', 'Price', 'Weight', 'Code']);
348
-    }
349
-
350
-    /**
351
-     * @return \SilverStripe\ORM\ValidationResult
352
-     */
353
-    public function validate()
354
-    {
355
-        $result = parent::validate();
356
-
357
-        if (ProductPage::get()->filter('Code', $this->Code)->exclude('ID', $this->ID)->first()) {
358
-            $result->addError('Code must be unique for each product.');
359
-        }
360
-
361
-        /*if($this->ID>0){
335
+				)), 'Title');
336
+			}
337
+		});
338
+
339
+		return parent::getCMSFields();
340
+	}
341
+
342
+	/**
343
+	 * @return RequiredFields
344
+	 */
345
+	public function getCMSValidator()
346
+	{
347
+		return new RequiredFields(['CategoryID', 'Price', 'Weight', 'Code']);
348
+	}
349
+
350
+	/**
351
+	 * @return \SilverStripe\ORM\ValidationResult
352
+	 */
353
+	public function validate()
354
+	{
355
+		$result = parent::validate();
356
+
357
+		if (ProductPage::get()->filter('Code', $this->Code)->exclude('ID', $this->ID)->first()) {
358
+			$result->addError('Code must be unique for each product.');
359
+		}
360
+
361
+		/*if($this->ID>0){
362 362
             if ($this->Price <= 0) {
363 363
                 $result->addError('Price must be a positive value');
364 364
             }
@@ -370,173 +370,173 @@  discard block
 block discarded – undo
370 370
             }
371 371
         }*/
372 372
 
373
-        return $result;
374
-    }
375
-
376
-    /**
377
-     * @return \SilverStripe\ORM\ManyManyList
378
-     */
379
-    public function getSortedImages()
380
-    {
381
-        return $this->Images()->Sort('SortOrder');
382
-    }
383
-
384
-    /**
385
-     * @return \SilverStripe\ORM\ManyManyList
386
-     */
387
-    public function SortedImages()
388
-    {
389
-        return $this->getSortedImages();
390
-    }
391
-
392
-    /**
393
-     * @return Image|bool
394
-     */
395
-    public function getImage()
396
-    {
397
-        if ($this->getSortedImages()->count() > 0) {
398
-            return $this->getSortedImages()->first();
399
-        }
400
-
401
-        return false;
402
-    }
403
-
404
-    /**
405
-     * @return Image|bool
406
-     */
407
-    public function Image()
408
-    {
409
-        return $this->getImage();
410
-    }
411
-
412
-    /**
413
-     * @throws \Exception
414
-     */
415
-    public function onBeforeWrite()
416
-    {
417
-        parent::onBeforeWrite();
418
-        if (!$this->CategoryID) {
419
-            $default = ProductCategory::get()->filter(['Code' => 'DEFAULT'])->first();
420
-            $this->CategoryID = $default->ID;
421
-        }
422
-
423
-        //update many_many lists when multi-group is on
424
-        if (FoxyStripeSetting::current_foxystripe_setting()->MultiGroup) {
425
-            $holders = $this->ProductHolders();
426
-            $product = self::get()->byID($this->ID);
427
-            if (isset($product->ParentID)) {
428
-                $origParent = $product->ParentID;
429
-            } else {
430
-                $origParent = null;
431
-            }
432
-            $currentParent = $this->ParentID;
433
-            if ($origParent != $currentParent) {
434
-                if ($holders->find('ID', $origParent)) {
435
-                    $holders->removeByID($origParent);
436
-                }
437
-            }
438
-            $holders->add($currentParent);
439
-        }
440
-
441
-        $this->Title = trim($this->Title);
442
-        $this->Code = trim($this->Code);
443
-        $this->ReceiptTitle = trim($this->ReceiptTitle);
444
-    }
445
-
446
-    public function onAfterWrite()
447
-    {
448
-        parent::onAfterWrite();
449
-    }
450
-
451
-    public function onBeforeDelete()
452
-    {
453
-        if ($this->Status != 'Published') {
454
-            if ($this->ProductOptions()) {
455
-                $options = $this->getComponents('ProductOptions');
456
-                foreach ($options as $option) {
457
-                    $option->delete();
458
-                }
459
-            }
460
-        }
461
-        parent::onBeforeDelete();
462
-    }
463
-
464
-    /**
465
-     * @param null $productCode
466
-     * @param null $optionName
467
-     * @param null $optionValue
468
-     * @param string $method
469
-     * @param bool $output
470
-     * @param bool $urlEncode
471
-     *
472
-     * @return null|string
473
-     */
474
-    public static function getGeneratedValue(
475
-        $productCode = null,
476
-        $optionName = null,
477
-        $optionValue = null,
478
-        $method = 'name',
479
-        $output = false,
480
-        $urlEncode = false
481
-    ) {
482
-        $optionName = ($optionName !== null) ? preg_replace('/\s/', '_', $optionName) : $optionName;
483
-
484
-        return (FoxyStripeSetting::current_foxystripe_setting()->CartValidation)
485
-            ? \FoxyCart_Helper::fc_hash_value($productCode, $optionName, $optionValue, $method, $output, $urlEncode) :
486
-            $optionValue;
487
-    }
488
-
489
-    /**
490
-     * @param Member $member
491
-     *
492
-     * @return bool
493
-     */
494
-    public function canEdit($member = null)
495
-    {
496
-        return Permission::check('Product_CANCRUD', 'any', $member);
497
-    }
498
-
499
-    public function canDelete($member = null)
500
-    {
501
-        return Permission::check('Product_CANCRUD', 'any', $member);
502
-    }
503
-
504
-    public function canCreate($member = null, $context = [])
505
-    {
506
-        return Permission::check('Product_CANCRUD', 'any', $member);
507
-    }
508
-
509
-    public function canPublish($member = null)
510
-    {
511
-        return Permission::check('Product_CANCRUD', 'any', $member);
512
-    }
513
-
514
-    public function providePermissions()
515
-    {
516
-        return [
517
-            'Product_CANCRUD' => 'Allow user to manage Products and related objects',
518
-        ];
519
-    }
520
-
521
-    /**
522
-     * @return bool
523
-     */
524
-    public function getIsAvailable()
525
-    {
526
-        if (!$this->Available) {
527
-            return false;
528
-        }
529
-
530
-        if (!$this->ProductOptions()->exists()) {
531
-            return true;
532
-        }
533
-
534
-        foreach ($this->ProductOptions() as $option) {
535
-            if ($option->Available) {
536
-                return true;
537
-            }
538
-        }
539
-
540
-        return false;
541
-    }
373
+		return $result;
374
+	}
375
+
376
+	/**
377
+	 * @return \SilverStripe\ORM\ManyManyList
378
+	 */
379
+	public function getSortedImages()
380
+	{
381
+		return $this->Images()->Sort('SortOrder');
382
+	}
383
+
384
+	/**
385
+	 * @return \SilverStripe\ORM\ManyManyList
386
+	 */
387
+	public function SortedImages()
388
+	{
389
+		return $this->getSortedImages();
390
+	}
391
+
392
+	/**
393
+	 * @return Image|bool
394
+	 */
395
+	public function getImage()
396
+	{
397
+		if ($this->getSortedImages()->count() > 0) {
398
+			return $this->getSortedImages()->first();
399
+		}
400
+
401
+		return false;
402
+	}
403
+
404
+	/**
405
+	 * @return Image|bool
406
+	 */
407
+	public function Image()
408
+	{
409
+		return $this->getImage();
410
+	}
411
+
412
+	/**
413
+	 * @throws \Exception
414
+	 */
415
+	public function onBeforeWrite()
416
+	{
417
+		parent::onBeforeWrite();
418
+		if (!$this->CategoryID) {
419
+			$default = ProductCategory::get()->filter(['Code' => 'DEFAULT'])->first();
420
+			$this->CategoryID = $default->ID;
421
+		}
422
+
423
+		//update many_many lists when multi-group is on
424
+		if (FoxyStripeSetting::current_foxystripe_setting()->MultiGroup) {
425
+			$holders = $this->ProductHolders();
426
+			$product = self::get()->byID($this->ID);
427
+			if (isset($product->ParentID)) {
428
+				$origParent = $product->ParentID;
429
+			} else {
430
+				$origParent = null;
431
+			}
432
+			$currentParent = $this->ParentID;
433
+			if ($origParent != $currentParent) {
434
+				if ($holders->find('ID', $origParent)) {
435
+					$holders->removeByID($origParent);
436
+				}
437
+			}
438
+			$holders->add($currentParent);
439
+		}
440
+
441
+		$this->Title = trim($this->Title);
442
+		$this->Code = trim($this->Code);
443
+		$this->ReceiptTitle = trim($this->ReceiptTitle);
444
+	}
445
+
446
+	public function onAfterWrite()
447
+	{
448
+		parent::onAfterWrite();
449
+	}
450
+
451
+	public function onBeforeDelete()
452
+	{
453
+		if ($this->Status != 'Published') {
454
+			if ($this->ProductOptions()) {
455
+				$options = $this->getComponents('ProductOptions');
456
+				foreach ($options as $option) {
457
+					$option->delete();
458
+				}
459
+			}
460
+		}
461
+		parent::onBeforeDelete();
462
+	}
463
+
464
+	/**
465
+	 * @param null $productCode
466
+	 * @param null $optionName
467
+	 * @param null $optionValue
468
+	 * @param string $method
469
+	 * @param bool $output
470
+	 * @param bool $urlEncode
471
+	 *
472
+	 * @return null|string
473
+	 */
474
+	public static function getGeneratedValue(
475
+		$productCode = null,
476
+		$optionName = null,
477
+		$optionValue = null,
478
+		$method = 'name',
479
+		$output = false,
480
+		$urlEncode = false
481
+	) {
482
+		$optionName = ($optionName !== null) ? preg_replace('/\s/', '_', $optionName) : $optionName;
483
+
484
+		return (FoxyStripeSetting::current_foxystripe_setting()->CartValidation)
485
+			? \FoxyCart_Helper::fc_hash_value($productCode, $optionName, $optionValue, $method, $output, $urlEncode) :
486
+			$optionValue;
487
+	}
488
+
489
+	/**
490
+	 * @param Member $member
491
+	 *
492
+	 * @return bool
493
+	 */
494
+	public function canEdit($member = null)
495
+	{
496
+		return Permission::check('Product_CANCRUD', 'any', $member);
497
+	}
498
+
499
+	public function canDelete($member = null)
500
+	{
501
+		return Permission::check('Product_CANCRUD', 'any', $member);
502
+	}
503
+
504
+	public function canCreate($member = null, $context = [])
505
+	{
506
+		return Permission::check('Product_CANCRUD', 'any', $member);
507
+	}
508
+
509
+	public function canPublish($member = null)
510
+	{
511
+		return Permission::check('Product_CANCRUD', 'any', $member);
512
+	}
513
+
514
+	public function providePermissions()
515
+	{
516
+		return [
517
+			'Product_CANCRUD' => 'Allow user to manage Products and related objects',
518
+		];
519
+	}
520
+
521
+	/**
522
+	 * @return bool
523
+	 */
524
+	public function getIsAvailable()
525
+	{
526
+		if (!$this->Available) {
527
+			return false;
528
+		}
529
+
530
+		if (!$this->ProductOptions()->exists()) {
531
+			return true;
532
+		}
533
+
534
+		foreach ($this->ProductOptions() as $option) {
535
+			if ($option->Available) {
536
+				return true;
537
+			}
538
+		}
539
+
540
+		return false;
541
+	}
542 542
 }
Please login to merge, or discard this patch.
src/Page/OrderHistoryPage.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -9,41 +9,41 @@
 block discarded – undo
9 9
 
10 10
 class OrderHistoryPage extends \Page
11 11
 {
12
-    /**
13
-     * @var string
14
-     */
15
-    private static $singular_name = 'Order History Page';
16
-
17
-    /**
18
-     * @var string
19
-     */
20
-    private static $plural_name = 'Order History Pages';
21
-
22
-    /**
23
-     * @var string
24
-     */
25
-    private static $description = 'Show a customers past orders. Requires authentication';
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
-    }
12
+	/**
13
+	 * @var string
14
+	 */
15
+	private static $singular_name = 'Order History Page';
16
+
17
+	/**
18
+	 * @var string
19
+	 */
20
+	private static $plural_name = 'Order History Pages';
21
+
22
+	/**
23
+	 * @var string
24
+	 */
25
+	private static $description = 'Show a customers past orders. Requires authentication';
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 49
 }
Please login to merge, or discard this patch.
src/Page/ProductHolder.php 1 patch
Indentation   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -18,161 +18,161 @@
 block discarded – undo
18 18
  */
19 19
 class ProductHolder extends \Page
20 20
 {
21
-    /**
22
-     * @var string
23
-     */
24
-    private static $singular_name = 'Product Group';
25
-
26
-    /**
27
-     * @var string
28
-     */
29
-    private static $plural_name = 'Product Groups';
30
-
31
-    /**
32
-     * @var string
33
-     */
34
-    private static $description = 'Display a list of related products';
35
-
36
-    /**
37
-     * @var array
38
-     */
39
-    private static $many_many = [
40
-        'Products' => ProductPage::class,
41
-    ];
42
-
43
-    /**
44
-     * @var array
45
-     */
46
-    private static $many_many_extraFields = [
47
-        'Products' => [
48
-            'SortOrder' => 'Int',
49
-        ],
50
-    ];
51
-
52
-    /**
53
-     * @var array
54
-     */
55
-    /*
21
+	/**
22
+	 * @var string
23
+	 */
24
+	private static $singular_name = 'Product Group';
25
+
26
+	/**
27
+	 * @var string
28
+	 */
29
+	private static $plural_name = 'Product Groups';
30
+
31
+	/**
32
+	 * @var string
33
+	 */
34
+	private static $description = 'Display a list of related products';
35
+
36
+	/**
37
+	 * @var array
38
+	 */
39
+	private static $many_many = [
40
+		'Products' => ProductPage::class,
41
+	];
42
+
43
+	/**
44
+	 * @var array
45
+	 */
46
+	private static $many_many_extraFields = [
47
+		'Products' => [
48
+			'SortOrder' => 'Int',
49
+		],
50
+	];
51
+
52
+	/**
53
+	 * @var array
54
+	 */
55
+	/*
56 56
     private static $allowed_children = [
57 57
         ProductHolder::class,
58 58
         ProductPage::class,
59 59
     ];
60 60
     */
61 61
 
62
-    /**
63
-     * @var string
64
-     */
65
-    private static $table_name = 'ProductHolder';
66
-
67
-    /**
68
-     * @return FieldList
69
-     */
70
-    public function getCMSFields()
71
-    {
72
-        $this->beforeUpdateCMSFields(function (FieldList $fields) {
73
-            if (FoxyStripeSetting::current_foxystripe_setting()->MultiGroup) {
74
-                $config = GridFieldConfig_RelationEditor::create();
75
-                $config->addComponent(new GridFieldOrderableRows('SortOrder'));
76
-                $config->removeComponentsByType('GridFieldAddExistingAutocompleter');
77
-                $config->addComponent(new GridFieldAddExistingSearchButton());
78
-
79
-                $fields->addFieldToTab(
80
-                    'Root.Products',
81
-                    GridField::create(
82
-                        'Products',
83
-                        _t('ProductHolder.Products', 'Products'),
84
-                        $this->Products(),
85
-                        $config
86
-                    )
87
-                );
88
-            }
89
-        });
90
-
91
-        return parent::getCMSFields();
92
-    }
93
-
94
-    /**
95
-     * @return DataList
96
-     */
97
-    public function Products()
98
-    {
99
-        return $this->getManyManyComponents('Products')->sort('SortOrder');
100
-    }
101
-
102
-    /**
103
-     * loadDescendantProductGroupIDListInto function.
104
-     *
105
-     * @param mixed &$idList
106
-     */
107
-    public function loadDescendantProductGroupIDListInto(&$idList)
108
-    {
109
-        if ($children = $this->AllChildren()) {
110
-            foreach ($children as $child) {
111
-                if (in_array($child->ID, $idList)) {
112
-                    continue;
113
-                }
114
-
115
-                if ($child instanceof self) {
116
-                    $idList[] = $child->ID;
117
-                    $child->loadDescendantProductGroupIDListInto($idList);
118
-                }
119
-            }
120
-        }
121
-    }
122
-
123
-    /**
124
-     * ProductGroupIDs function.
125
-     *
126
-     * @return array
127
-     */
128
-    public function ProductGroupIDs()
129
-    {
130
-        $holderIDs = [];
131
-        $this->loadDescendantProductGroupIDListInto($holderIDs);
132
-
133
-        return $holderIDs;
134
-    }
135
-
136
-    /**
137
-     * @param int $limit
138
-     *
139
-     * @return PaginatedList
140
-     *
141
-     * @throws \Exception
142
-     */
143
-    public function ProductList($limit = 10)
144
-    {
145
-        $config = FoxyStripeSetting::current_foxystripe_setting();
146
-
147
-        if ($config->ProductLimit > 0) {
148
-            $limit = $config->ProductLimit;
149
-        }
150
-
151
-        if ($config->MultiGroup) {
152
-            $entries = $this->Products()->sort('SortOrder');
153
-        } else {
154
-            $filter = '"ParentID" = ' . $this->ID;
155
-
156
-            // Build a list of all IDs for ProductGroups that are children
157
-            $holderIDs = $this->ProductGroupIDs();
158
-
159
-            // If no ProductHolders, no ProductPages. So return false
160
-            if ($holderIDs) {
161
-                // Otherwise, do the actual query
162
-                if ($filter) {
163
-                    $filter .= ' OR ';
164
-                }
165
-                $filter .= '"ParentID" IN (' . implode(',', $holderIDs) . ')';
166
-            }
167
-
168
-            $order = '"SiteTree"."Title" ASC';
169
-
170
-            $entries = ProductPage::get()->where($filter);
171
-        }
172
-
173
-        $list = new PaginatedList($entries, Controller::curr()->getRequest());
174
-        $list->setPageLength($limit);
175
-
176
-        return $list;
177
-    }
62
+	/**
63
+	 * @var string
64
+	 */
65
+	private static $table_name = 'ProductHolder';
66
+
67
+	/**
68
+	 * @return FieldList
69
+	 */
70
+	public function getCMSFields()
71
+	{
72
+		$this->beforeUpdateCMSFields(function (FieldList $fields) {
73
+			if (FoxyStripeSetting::current_foxystripe_setting()->MultiGroup) {
74
+				$config = GridFieldConfig_RelationEditor::create();
75
+				$config->addComponent(new GridFieldOrderableRows('SortOrder'));
76
+				$config->removeComponentsByType('GridFieldAddExistingAutocompleter');
77
+				$config->addComponent(new GridFieldAddExistingSearchButton());
78
+
79
+				$fields->addFieldToTab(
80
+					'Root.Products',
81
+					GridField::create(
82
+						'Products',
83
+						_t('ProductHolder.Products', 'Products'),
84
+						$this->Products(),
85
+						$config
86
+					)
87
+				);
88
+			}
89
+		});
90
+
91
+		return parent::getCMSFields();
92
+	}
93
+
94
+	/**
95
+	 * @return DataList
96
+	 */
97
+	public function Products()
98
+	{
99
+		return $this->getManyManyComponents('Products')->sort('SortOrder');
100
+	}
101
+
102
+	/**
103
+	 * loadDescendantProductGroupIDListInto function.
104
+	 *
105
+	 * @param mixed &$idList
106
+	 */
107
+	public function loadDescendantProductGroupIDListInto(&$idList)
108
+	{
109
+		if ($children = $this->AllChildren()) {
110
+			foreach ($children as $child) {
111
+				if (in_array($child->ID, $idList)) {
112
+					continue;
113
+				}
114
+
115
+				if ($child instanceof self) {
116
+					$idList[] = $child->ID;
117
+					$child->loadDescendantProductGroupIDListInto($idList);
118
+				}
119
+			}
120
+		}
121
+	}
122
+
123
+	/**
124
+	 * ProductGroupIDs function.
125
+	 *
126
+	 * @return array
127
+	 */
128
+	public function ProductGroupIDs()
129
+	{
130
+		$holderIDs = [];
131
+		$this->loadDescendantProductGroupIDListInto($holderIDs);
132
+
133
+		return $holderIDs;
134
+	}
135
+
136
+	/**
137
+	 * @param int $limit
138
+	 *
139
+	 * @return PaginatedList
140
+	 *
141
+	 * @throws \Exception
142
+	 */
143
+	public function ProductList($limit = 10)
144
+	{
145
+		$config = FoxyStripeSetting::current_foxystripe_setting();
146
+
147
+		if ($config->ProductLimit > 0) {
148
+			$limit = $config->ProductLimit;
149
+		}
150
+
151
+		if ($config->MultiGroup) {
152
+			$entries = $this->Products()->sort('SortOrder');
153
+		} else {
154
+			$filter = '"ParentID" = ' . $this->ID;
155
+
156
+			// Build a list of all IDs for ProductGroups that are children
157
+			$holderIDs = $this->ProductGroupIDs();
158
+
159
+			// If no ProductHolders, no ProductPages. So return false
160
+			if ($holderIDs) {
161
+				// Otherwise, do the actual query
162
+				if ($filter) {
163
+					$filter .= ' OR ';
164
+				}
165
+				$filter .= '"ParentID" IN (' . implode(',', $holderIDs) . ')';
166
+			}
167
+
168
+			$order = '"SiteTree"."Title" ASC';
169
+
170
+			$entries = ProductPage::get()->where($filter);
171
+		}
172
+
173
+		$list = new PaginatedList($entries, Controller::curr()->getRequest());
174
+		$list->setPageLength($limit);
175
+
176
+		return $list;
177
+	}
178 178
 }
Please login to merge, or discard this patch.
src/Migration/SiteConfigMigration.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -21,38 +21,38 @@
 block discarded – undo
21 21
  */
22 22
 class SiteConfigMigration extends DataExtension
23 23
 {
24
-    /**
25
-     * @var array
26
-     */
27
-    private static $db = array(
28
-        'StoreName' => 'Varchar(255)',
29
-        'StoreKey' => 'Varchar(60)',
30
-        'MultiGroup' => 'Boolean',
31
-        'ProductLimit' => 'Int',
32
-        'CartValidation' => 'Boolean',
33
-        'MaxQuantity' => 'Int',
34
-        'CustomSSL' => 'Boolean',
35
-        'RemoteDomain' => 'Varchar(255)',
36
-    );
24
+	/**
25
+	 * @var array
26
+	 */
27
+	private static $db = array(
28
+		'StoreName' => 'Varchar(255)',
29
+		'StoreKey' => 'Varchar(60)',
30
+		'MultiGroup' => 'Boolean',
31
+		'ProductLimit' => 'Int',
32
+		'CartValidation' => 'Boolean',
33
+		'MaxQuantity' => 'Int',
34
+		'CustomSSL' => 'Boolean',
35
+		'RemoteDomain' => 'Varchar(255)',
36
+	);
37 37
 
38
-    /**
39
-     *
40
-     */
41
-    public function onAfterWrite()
42
-    {
43
-        parent::onAfterWrite();
38
+	/**
39
+	 *
40
+	 */
41
+	public function onAfterWrite()
42
+	{
43
+		parent::onAfterWrite();
44 44
 
45
-        $config = FoxyStripeSetting::current_foxystripe_setting();
45
+		$config = FoxyStripeSetting::current_foxystripe_setting();
46 46
 
47
-        $config->StoreName = $this->owner->StoreName;
48
-        $config->StoreKey = $this->owner->StoreKey;
49
-        $config->MultiGroup = $this->owner->MultiGroup;
50
-        $config->ProductLimit = $this->owner->ProductLimit;
51
-        $config->CartValidation = $this->owner->CartValidation;
52
-        $config->MaxQuantity = $this->owner->MaxQuantity;
53
-        $config->CustomSSL = $this->owner->CustomSSL;
54
-        $config->RemoteDomain = $this->owner->RemoteDomain;
47
+		$config->StoreName = $this->owner->StoreName;
48
+		$config->StoreKey = $this->owner->StoreKey;
49
+		$config->MultiGroup = $this->owner->MultiGroup;
50
+		$config->ProductLimit = $this->owner->ProductLimit;
51
+		$config->CartValidation = $this->owner->CartValidation;
52
+		$config->MaxQuantity = $this->owner->MaxQuantity;
53
+		$config->CustomSSL = $this->owner->CustomSSL;
54
+		$config->RemoteDomain = $this->owner->RemoteDomain;
55 55
 
56
-        $config->write();
57
-    }
56
+		$config->write();
57
+	}
58 58
 }
Please login to merge, or discard this patch.
src/Form/FoxyStripeDropdownField.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -54,46 +54,46 @@
 block discarded – undo
54 54
  */
55 55
 class FoxyStripeDropdownField extends DropdownField
56 56
 {
57
-    /**
58
-     * Mark certain elements as disabled,
59
-     * regardless of the {@link setDisabled()} settings.
60
-     *
61
-     * @param array $items Collection of array keys, as defined in the $source array
62
-     *
63
-     * @return $this
64
-     */
65
-    public function setDisabledItems($items)
66
-    {
67
-        $controller = Controller::curr();
68
-        $code = $controller->data()->Code;
69
-        $updated = [];
70
-        if (is_array($items) && !empty($items)) {
71
-            foreach ($items as $item) {
72
-                array_push($updated, ProductPage::getGeneratedValue($code, $this->getName(), $item, 'value'));
73
-            }
74
-        }
75
-        $this->disabledItems = $updated;
57
+	/**
58
+	 * Mark certain elements as disabled,
59
+	 * regardless of the {@link setDisabled()} settings.
60
+	 *
61
+	 * @param array $items Collection of array keys, as defined in the $source array
62
+	 *
63
+	 * @return $this
64
+	 */
65
+	public function setDisabledItems($items)
66
+	{
67
+		$controller = Controller::curr();
68
+		$code = $controller->data()->Code;
69
+		$updated = [];
70
+		if (is_array($items) && !empty($items)) {
71
+			foreach ($items as $item) {
72
+				array_push($updated, ProductPage::getGeneratedValue($code, $this->getName(), $item, 'value'));
73
+			}
74
+		}
75
+		$this->disabledItems = $updated;
76 76
 
77
-        return $this;
78
-    }
77
+		return $this;
78
+	}
79 79
 
80
-    /**
81
-     * @param mixed $source
82
-     *
83
-     * @return $this
84
-     */
85
-    public function setSource($source)
86
-    {
87
-        $controller = Controller::curr();
88
-        $code = $controller->data()->Code;
89
-        $updated = [];
90
-        if (is_array($source) && !empty($source)) {
91
-            foreach ($source as $key => $val) {
92
-                $updated[ProductPage::getGeneratedValue($code, $this->getName(), $key, 'value')] = $val;
93
-            }
94
-        }
95
-        $this->source = $updated;
80
+	/**
81
+	 * @param mixed $source
82
+	 *
83
+	 * @return $this
84
+	 */
85
+	public function setSource($source)
86
+	{
87
+		$controller = Controller::curr();
88
+		$code = $controller->data()->Code;
89
+		$updated = [];
90
+		if (is_array($source) && !empty($source)) {
91
+			foreach ($source as $key => $val) {
92
+				$updated[ProductPage::getGeneratedValue($code, $this->getName(), $key, 'value')] = $val;
93
+			}
94
+		}
95
+		$this->source = $updated;
96 96
 
97
-        return $this;
98
-    }
97
+		return $this;
98
+	}
99 99
 }
Please login to merge, or discard this patch.