@@ -129,14 +129,14 @@ discard block |
||
129 | 129 | { |
130 | 130 | $config = SiteConfig::current_site_config(); |
131 | 131 | |
132 | - if ($config->ProductLimit>0) { |
|
132 | + if ($config->ProductLimit > 0) { |
|
133 | 133 | $limit = $config->ProductLimit; |
134 | 134 | } |
135 | 135 | |
136 | 136 | if ($config->MultiGroup) { |
137 | 137 | $entries = $this->Products()->sort('SortOrder'); |
138 | - } else { |
|
139 | - $filter = '"ParentID" = ' . $this->ID; |
|
138 | + }else { |
|
139 | + $filter = '"ParentID" = '.$this->ID; |
|
140 | 140 | |
141 | 141 | // Build a list of all IDs for ProductGroups that are children |
142 | 142 | $holderIDs = $this->ProductGroupIDs(); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | if ($filter) { |
148 | 148 | $filter .= ' OR '; |
149 | 149 | } |
150 | - $filter .= '"ParentID" IN (' . implode(',', $holderIDs) . ")"; |
|
150 | + $filter .= '"ParentID" IN ('.implode(',', $holderIDs).")"; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | $order = '"SiteTree"."Title" ASC'; |
@@ -23,11 +23,11 @@ |
||
23 | 23 | { |
24 | 24 | $object = $this->objFromFixture('OptionGroup', 'size'); |
25 | 25 | $orig = $object->Title; |
26 | - $object->Title = '2' . $orig; |
|
26 | + $object->Title = '2'.$orig; |
|
27 | 27 | $this->setExpectedException('ValidationException'); |
28 | 28 | $object->write(); |
29 | 29 | |
30 | - $object->Title = $orig . '&'; |
|
30 | + $object->Title = $orig.'&'; |
|
31 | 31 | $this->setExpectedException('ValidationException'); |
32 | 32 | $object->write(); |
33 | 33 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $fields->push(HiddenField::create(ProductPage::getGeneratedValue($code, 'product_id', |
121 | 121 | $this->product->ID))->setValue($this->product->ID)); |
122 | 122 | $fields->push(HiddenField::create(ProductPage::getGeneratedValue($code, 'price', |
123 | - $this->product->Price))->setValue($this->product->Price));//can't override id |
|
123 | + $this->product->Price))->setValue($this->product->Price)); //can't override id |
|
124 | 124 | $fields->push(HiddenField::create(ProductPage::getGeneratedValue($code, 'weight', |
125 | 125 | $this->product->Weight))->setValue($this->product->Weight)); |
126 | 126 | |
@@ -148,11 +148,11 @@ discard block |
||
148 | 148 | |
149 | 149 | $fields->push(DropdownField::create('quantity', 'Quantity', $quantity)); |
150 | 150 | |
151 | - $fields->push(HeaderField::create('submitPrice', '$' . $this->product->Price, 4)->addExtraClass('submit-price')); |
|
151 | + $fields->push(HeaderField::create('submitPrice', '$'.$this->product->Price, 4)->addExtraClass('submit-price')); |
|
152 | 152 | $fields->push(HeaderField::create('unavailableText', 'Selection unavailable', 4)->addExtraClass('hidden unavailable-text')); |
153 | 153 | |
154 | 154 | $this->extend('updatePurchaseFormFields', $fields); |
155 | - } else { |
|
155 | + }else { |
|
156 | 156 | $fields->push(HeaderField::create('submitPrice', 'Currently Out of Stock'), 4); |
157 | 157 | } |
158 | 158 | |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | protected function getProductOptionSet() |
190 | 190 | { |
191 | 191 | |
192 | - $assignAvailable = function ($self) { |
|
192 | + $assignAvailable = function($self) { |
|
193 | 193 | $this->extend('updateFoxyStripePurchaseForm', $form); |
194 | 194 | $self->Available = ($self->getAvailability()) ? true : false; |
195 | 195 | }; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | 'Image used throughout site to represent this product'); |
96 | 96 | |
97 | 97 | // Cateogry Dropdown field w/ add new |
98 | - $source = function () { |
|
98 | + $source = function() { |
|
99 | 99 | return ProductCategory::get()->map()->toArray(); |
100 | 100 | }; |
101 | 101 | $catField = DropdownField::create('CategoryID', _t('ProductPage.Category', 'FoxyCart Category'), $source()) |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | if (class_exists('GridFieldSortableRows')) { |
140 | 140 | $config->addComponent(new GridFieldSortableRows('SortOrder')); |
141 | 141 | $products = $this->ProductOptions()->sort('SortOrder'); |
142 | - } else { |
|
142 | + }else { |
|
143 | 143 | $products = $this->ProductOptions(); |
144 | 144 | } |
145 | 145 | $config->removeComponentsByType('GridFieldAddExistingAutocompleter'); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | ->setFolderName('Uploads/Products') |
196 | 196 | ->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png')) |
197 | 197 | ->setAllowedMaxFileNumber(1), |
198 | - HeaderField::create('ProductImagesHD', _t('ProductPage.ProductImagesHD' . 'Product Image Gallery'), 2), |
|
198 | + HeaderField::create('ProductImagesHD', _t('ProductPage.ProductImagesHD'.'Product Image Gallery'), 2), |
|
199 | 199 | $prodImagesField |
200 | 200 | ->setDescription(_t( |
201 | 201 | 'ProductPage.ProductImagesDescription', |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $product = ProductPage::get()->byID($this->ID); |
242 | 242 | if (isset($product->ParentID)) { |
243 | 243 | $origParent = $product->ParentID; |
244 | - } else { |
|
244 | + }else { |
|
245 | 245 | $origParent = null; |
246 | 246 | } |
247 | 247 | $currentParent = $this->ParentID; |
@@ -322,14 +322,13 @@ discard block |
||
322 | 322 | ) { |
323 | 323 | $optionName = ($optionName !== null) ? preg_replace('/\s/', '_', $optionName) : $optionName; |
324 | 324 | return (SiteConfig::current_site_config()->CartValidation) |
325 | - ? FoxyCart_Helper::fc_hash_value($productCode, $optionName, $optionValue, $method, $output, $urlEncode) : |
|
326 | - $optionValue; |
|
325 | + ? FoxyCart_Helper::fc_hash_value($productCode, $optionName, $optionValue, $method, $output, $urlEncode) : $optionValue; |
|
327 | 326 | } |
328 | 327 | |
329 | 328 | // get FoxyCart Store Name for JS call |
330 | 329 | public function getCartScript() |
331 | 330 | { |
332 | - return '<script src="https://cdn.foxycart.com/' . FoxyCart::getFoxyCartStoreName() . '/loader.js" async defer></script>'; |
|
331 | + return '<script src="https://cdn.foxycart.com/'.FoxyCart::getFoxyCartStoreName().'/loader.js" async defer></script>'; |
|
333 | 332 | } |
334 | 333 | |
335 | 334 | /** |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $parentCode = $product->Code; |
91 | 91 | |
92 | 92 | // ProductOptionGroup Dropdown field w/ add new |
93 | - $groups = function () { |
|
93 | + $groups = function() { |
|
94 | 94 | return OptionGroup::get()->map()->toArray(); |
95 | 95 | }; |
96 | 96 | $groupFields = singleton('OptionGroup')->getCMSFields(); |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * @param bool $returnWithOnlyPlusMinus |
225 | 225 | * @return string |
226 | 226 | */ |
227 | - public static function getOptionModifierActionSymbol($oma, $returnWithOnlyPlusMinus=false) |
|
227 | + public static function getOptionModifierActionSymbol($oma, $returnWithOnlyPlusMinus = false) |
|
228 | 228 | { |
229 | 229 | switch ($oma) { |
230 | 230 | case 'Subtract': |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | { |
292 | 292 | $modPrice = ($this->PriceModifier) ? (string)$this->PriceModifier : '0'; |
293 | 293 | $title = $this->Title; |
294 | - $title .= ($this->PriceModifier != 0) ? ': ('.OptionItem::getOptionModifierActionSymbol($this->PriceModifierAction, $returnWithOnlyPlusMinus=true).'$'.$modPrice.')' : ''; |
|
294 | + $title .= ($this->PriceModifier != 0) ? ': ('.OptionItem::getOptionModifierActionSymbol($this->PriceModifierAction, $returnWithOnlyPlusMinus = true).'$'.$modPrice.')' : ''; |
|
295 | 295 | return $title; |
296 | 296 | } |
297 | 297 | |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | */ |
301 | 301 | public function getAvailability() |
302 | 302 | { |
303 | - $available = ($this->Available == 1) ? true : false ; |
|
303 | + $available = ($this->Available == 1) ? true : false; |
|
304 | 304 | |
305 | 305 | $this->extend('updateOptionAvailability', $available); |
306 | 306 |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | } |
128 | 128 | } |
129 | 129 | if (count($errors)) { |
130 | - \SS_Log::log('setCurrentStore errors - ' . json_encode($errors), \SS_Log::WARN); |
|
130 | + \SS_Log::log('setCurrentStore errors - '.json_encode($errors), \SS_Log::WARN); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | |
143 | 143 | $errors = array_merge($errors, $client->getErrors($result)); |
144 | 144 | if (count($errors)) { |
145 | - \SS_Log::log('updateStore errors - ' . json_encode($errors), \SS_Log::WARN); |
|
145 | + \SS_Log::log('updateStore errors - '.json_encode($errors), \SS_Log::WARN); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | |
170 | 170 | $errors = array_merge($errors, $client->getErrors($result)); |
171 | 171 | if (count($errors)) { |
172 | - \SS_Log::log('setItemCategoriesURL errors - ' . json_encode($errors), \SS_Log::WARN); |
|
172 | + \SS_Log::log('setItemCategoriesURL errors - '.json_encode($errors), \SS_Log::WARN); |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | |
195 | 195 | $errors = array_merge($errors, $client->getErrors($result)); |
196 | 196 | if (count($errors)) { |
197 | - \SS_Log::log('setItemCategories errors - ' . json_encode($errors), \SS_Log::WARN); |
|
197 | + \SS_Log::log('setItemCategories errors - '.json_encode($errors), \SS_Log::WARN); |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | } |
218 | 218 | $errors = array_merge($errors, $client->getErrors($result)); |
219 | 219 | if (count($errors)) { |
220 | - \SS_Log::log('getCategory errors - ' . json_encode($errors), \SS_Log::WARN); |
|
220 | + \SS_Log::log('getCategory errors - '.json_encode($errors), \SS_Log::WARN); |
|
221 | 221 | } |
222 | 222 | } |
223 | 223 | } |
@@ -234,12 +234,12 @@ discard block |
||
234 | 234 | |
235 | 235 | if ($category = $this->getCategory($data['code'])) { |
236 | 236 | $result = $client->patch($category, $data); |
237 | - } else { |
|
237 | + }else { |
|
238 | 238 | $result = $client->post($this->getItemCategoriesURL(), $data); |
239 | 239 | } |
240 | 240 | $errors = array_merge($errors, $client->getErrors($result)); |
241 | 241 | if (count($errors)) { |
242 | - \SS_Log::log('putCategory errors - ' . json_encode($errors), \SS_Log::WARN); |
|
242 | + \SS_Log::log('putCategory errors - '.json_encode($errors), \SS_Log::WARN); |
|
243 | 243 | } |
244 | 244 | } |
245 | 245 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | |
257 | 257 | $errors = array_merge($errors, $client->getErrors($result)); |
258 | 258 | if (count($errors)) { |
259 | - \SS_Log::log('deleteCategory errors - ' . json_encode($errors), \SS_Log::WARN); |
|
259 | + \SS_Log::log('deleteCategory errors - '.json_encode($errors), \SS_Log::WARN); |
|
260 | 260 | } |
261 | 261 | } |
262 | 262 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | protected static $disable_themes = true; |
7 | 7 | protected static $use_draft_site = false; |
8 | 8 | |
9 | - public function setUp(){ |
|
9 | + public function setUp() { |
|
10 | 10 | parent::setUp(); |
11 | 11 | |
12 | 12 | ini_set('display_errors', 1); |
@@ -14,10 +14,10 @@ discard block |
||
14 | 14 | error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED); |
15 | 15 | } |
16 | 16 | |
17 | - public function logOut(){ |
|
17 | + public function logOut() { |
|
18 | 18 | $this->session()->clear('loggedInAs'); |
19 | 19 | } |
20 | 20 | |
21 | - public function testProductPage(){} |
|
21 | + public function testProductPage() {} |
|
22 | 22 | |
23 | 23 | } |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | use Dynamic\FoxyStripe\Model\FoxyStripeClient; |
4 | 4 | |
5 | -class FoxyStripeSiteConfig extends DataExtension{ |
|
5 | +class FoxyStripeSiteConfig extends DataExtension { |
|
6 | 6 | |
7 | 7 | private static $db = array( |
8 | 8 | 'StoreTitle' => 'Varchar(255)', |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | 'ProductLimit' => 10 |
39 | 39 | ); |
40 | 40 | |
41 | - public function updateCMSFields(FieldList $fields){ |
|
41 | + public function updateCMSFields(FieldList $fields) { |
|
42 | 42 | |
43 | 43 | // set TabSet names to avoid spaces from camel case |
44 | 44 | $fields->addFieldToTab('Root', new TabSet('FoxyStripe', 'FoxyStripe')); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | ]); |
123 | 123 | |
124 | 124 | // configuration warning |
125 | - if(FoxyCart::store_name_warning()!==null){ |
|
125 | + if (FoxyCart::store_name_warning() !== null) { |
|
126 | 126 | $fields->insertBefore(LiteralField::create( |
127 | 127 | "StoreSubDomainHeaderWarning", |
128 | 128 | _t( |
@@ -213,14 +213,14 @@ discard block |
||
213 | 213 | |
214 | 214 | $siteConfig = SiteConfig::current_site_config(); |
215 | 215 | |
216 | - if(!$siteConfig->StoreKey) { |
|
216 | + if (!$siteConfig->StoreKey) { |
|
217 | 217 | $key = FoxyCart::setStoreKey(); |
218 | - while(!ctype_alnum($key)){ |
|
218 | + while (!ctype_alnum($key)) { |
|
219 | 219 | $key = FoxyCart::setStoreKey(); |
220 | 220 | } |
221 | 221 | $siteConfig->StoreKey = $key; |
222 | 222 | $siteConfig->write(); |
223 | - DB::alteration_message($siteConfig->ClassName.": created FoxyCart Store Key " . $key, 'created'); |
|
223 | + DB::alteration_message($siteConfig->ClassName.": created FoxyCart Store Key ".$key, 'created'); |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | |
286 | 286 | $errors = array_merge($errors, $client->getErrors($result)); |
287 | 287 | if (count($errors)) { |
288 | - \SS_Log::log('FoxyStripeSiteConfig::onBeforeWrite errors - ' . json_encode($errors), \SS_Log::WARN); |
|
288 | + \SS_Log::log('FoxyStripeSiteConfig::onBeforeWrite errors - '.json_encode($errors), \SS_Log::WARN); |
|
289 | 289 | } |
290 | 290 | } |
291 | 291 | } |
@@ -4,9 +4,9 @@ discard block |
||
4 | 4 | |
5 | 5 | class FoxyStripeSiteConfig extends DataExtension{ |
6 | 6 | |
7 | - private static $db = array( |
|
8 | - 'StoreTitle' => 'Varchar(255)', |
|
9 | - 'StoreName' => 'Varchar(255)', |
|
7 | + private static $db = array( |
|
8 | + 'StoreTitle' => 'Varchar(255)', |
|
9 | + 'StoreName' => 'Varchar(255)', |
|
10 | 10 | 'StoreURL' => 'Varchar(255)', |
11 | 11 | 'ReceiptURL' => 'Varchar(255)', |
12 | 12 | 'StoreEmail' => 'Varchar(255)', |
@@ -24,21 +24,21 @@ discard block |
||
24 | 24 | 'UseSingleSignOn' => 'Boolean', |
25 | 25 | 'AllowMultiship' => 'Boolean', |
26 | 26 | 'StoreTimezone' => 'Varchar(100)', |
27 | - 'MultiGroup' => 'Boolean', |
|
28 | - 'ProductLimit' => 'Int', |
|
29 | - 'MaxQuantity' => 'Int', |
|
27 | + 'MultiGroup' => 'Boolean', |
|
28 | + 'ProductLimit' => 'Int', |
|
29 | + 'MaxQuantity' => 'Int', |
|
30 | 30 | 'client_id' => 'Varchar(255)', |
31 | 31 | 'client_secret' => 'Varchar(255)', |
32 | 32 | 'access_token' => 'Varchar(255)', |
33 | 33 | 'refresh_token' => 'Varchar(255)', |
34 | - ); |
|
34 | + ); |
|
35 | 35 | |
36 | 36 | // Set Default values |
37 | 37 | private static $defaults = array( |
38 | 38 | 'ProductLimit' => 10 |
39 | 39 | ); |
40 | 40 | |
41 | - public function updateCMSFields(FieldList $fields){ |
|
41 | + public function updateCMSFields(FieldList $fields){ |
|
42 | 42 | |
43 | 43 | // set TabSet names to avoid spaces from camel case |
44 | 44 | $fields->addFieldToTab('Root', new TabSet('FoxyStripe', 'FoxyStripe')); |
@@ -46,17 +46,17 @@ discard block |
||
46 | 46 | // settings tab |
47 | 47 | $fields->addFieldsToTab('Root.FoxyStripe.Settings', array( |
48 | 48 | // Store Details |
49 | - HeaderField::create('StoreDetails', _t('FoxyStripeSiteConfig.StoreDetails', 'Store Settings'), 3), |
|
50 | - LiteralField::create('DetailsIntro', _t( |
|
51 | - 'FoxyStripeSiteConfig.DetailsIntro', |
|
49 | + HeaderField::create('StoreDetails', _t('FoxyStripeSiteConfig.StoreDetails', 'Store Settings'), 3), |
|
50 | + LiteralField::create('DetailsIntro', _t( |
|
51 | + 'FoxyStripeSiteConfig.DetailsIntro', |
|
52 | 52 | '<p>Maps to data in your <a href="https://admin.foxycart.com/admin.php?ThisAction=EditStore" target="_blank">FoxyCart store settings</a>.' |
53 | 53 | )), |
54 | 54 | TextField::create('StoreTitle') |
55 | 55 | ->setTitle(_t('FoxyStripeSiteConfig.StoreTitle', 'Store Name')) |
56 | 56 | ->setDescription(_t('FoxyStripeSiteConfig.StoreTitleDescription', 'The name of your store as you\'d like it displayed to your customers')), |
57 | - TextField::create('StoreName') |
|
58 | - ->setTitle(_t('FoxyStripeSiteConfig.StoreName', 'Store Domain')) |
|
59 | - ->setDescription(_t('FoxyStripeSiteConfig.StoreNameDescription', 'This is a unique FoxyCart subdomain for your cart, checkout, and receipt')), |
|
57 | + TextField::create('StoreName') |
|
58 | + ->setTitle(_t('FoxyStripeSiteConfig.StoreName', 'Store Domain')) |
|
59 | + ->setDescription(_t('FoxyStripeSiteConfig.StoreNameDescription', 'This is a unique FoxyCart subdomain for your cart, checkout, and receipt')), |
|
60 | 60 | TextField::create('StoreURL') |
61 | 61 | ->setTitle(_t('FoxyStripeSiteConfig.StoreURL', 'Store URL')) |
62 | 62 | ->setDescription(_t('FoxyStripeSiteConfig.StoreURLDescription', 'The URL of your online store')), |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | TextField::create('StoreLogoURL', 'Logo URL') |
79 | 79 | ->setAttribute('placeholder', 'http://') |
80 | 80 | |
81 | - // Advanced Settings |
|
81 | + // Advanced Settings |
|
82 | 82 | /* |
83 | 83 | HeaderField::create('AdvanceHeader', _t('FoxyStripeSiteConfig.AdvancedHeader', 'Advanced Settings'), 3), |
84 | 84 | LiteralField::create('AdvancedIntro', _t( |
@@ -122,72 +122,72 @@ discard block |
||
122 | 122 | ]); |
123 | 123 | |
124 | 124 | // configuration warning |
125 | - if(FoxyCart::store_name_warning()!==null){ |
|
126 | - $fields->insertBefore(LiteralField::create( |
|
125 | + if(FoxyCart::store_name_warning()!==null){ |
|
126 | + $fields->insertBefore(LiteralField::create( |
|
127 | 127 | "StoreSubDomainHeaderWarning", |
128 | 128 | _t( |
129 | 129 | 'FoxyStripeSiteConfig.StoreSubDomainHeadingWarning', |
130 | 130 | "<p class=\"message error\">Store sub-domain must be entered in the <a href=\"/admin/settings/\">site settings</a></p>" |
131 | 131 | ) |
132 | 132 | ), 'StoreDetails'); |
133 | - } |
|
133 | + } |
|
134 | 134 | |
135 | 135 | // products tab |
136 | - $fields->addFieldsToTab('Root.FoxyStripe.Products', array( |
|
137 | - HeaderField::create('ProductHeader', _t('FoxyStripeSiteConfig.ProductHeader', 'Products'), 3), |
|
138 | - CheckboxField::create('MultiGroup') |
|
139 | - ->setTitle(_t('FoxyStripeSiteConfig.MultiGroup', 'Multiple Groups')) |
|
140 | - ->setDescription(_t( |
|
136 | + $fields->addFieldsToTab('Root.FoxyStripe.Products', array( |
|
137 | + HeaderField::create('ProductHeader', _t('FoxyStripeSiteConfig.ProductHeader', 'Products'), 3), |
|
138 | + CheckboxField::create('MultiGroup') |
|
139 | + ->setTitle(_t('FoxyStripeSiteConfig.MultiGroup', 'Multiple Groups')) |
|
140 | + ->setDescription(_t( |
|
141 | 141 | 'FoxyStripeSiteConfig.MultiGroupDescription', |
142 | 142 | 'Allows products to be shown in multiple Product Groups' |
143 | 143 | )), |
144 | - HeaderField::create('ProductGroupHD', _t('FoxyStripeSiteConfig.ProductGroupHD', 'Product Groups'), 3), |
|
145 | - NumericField::create('ProductLimit') |
|
146 | - ->setTitle(_t('FoxyStripeSiteConfig.ProductLimit', 'Products per Page')) |
|
147 | - ->setDescription(_t( |
|
144 | + HeaderField::create('ProductGroupHD', _t('FoxyStripeSiteConfig.ProductGroupHD', 'Product Groups'), 3), |
|
145 | + NumericField::create('ProductLimit') |
|
146 | + ->setTitle(_t('FoxyStripeSiteConfig.ProductLimit', 'Products per Page')) |
|
147 | + ->setDescription(_t( |
|
148 | 148 | 'FoxyStripeSiteConfig.ProductLimitDescription', |
149 | 149 | 'Number of Products to show per page on a Product Group' |
150 | 150 | )), |
151 | - HeaderField::create('ProductQuantityHD', _t('FoxyStripeSiteConfig.ProductQuantityHD', 'Product Form Max Quantity'), 3), |
|
152 | - NumericField::create('MaxQuantity') |
|
153 | - ->setTitle(_t('FoxyStripeSiteConfig.MaxQuantity', 'Max Quantity')) |
|
154 | - ->setDescription(_t( |
|
151 | + HeaderField::create('ProductQuantityHD', _t('FoxyStripeSiteConfig.ProductQuantityHD', 'Product Form Max Quantity'), 3), |
|
152 | + NumericField::create('MaxQuantity') |
|
153 | + ->setTitle(_t('FoxyStripeSiteConfig.MaxQuantity', 'Max Quantity')) |
|
154 | + ->setDescription(_t( |
|
155 | 155 | 'FoxyStripeSiteConfig.MaxQuantityDescription', |
156 | 156 | 'Sets max quantity for product form dropdown (add to cart form - default 10)' |
157 | 157 | )) |
158 | - )); |
|
158 | + )); |
|
159 | 159 | |
160 | 160 | // categories tab |
161 | - $fields->addFieldsToTab('Root.FoxyStripe.Categories', array( |
|
162 | - HeaderField::create('CategoryHD', _t('FoxyStripeSiteConfig.CategoryHD', 'FoxyStripe Categories'), 3), |
|
163 | - LiteralField::create('CategoryDescrip', _t( |
|
161 | + $fields->addFieldsToTab('Root.FoxyStripe.Categories', array( |
|
162 | + HeaderField::create('CategoryHD', _t('FoxyStripeSiteConfig.CategoryHD', 'FoxyStripe Categories'), 3), |
|
163 | + LiteralField::create('CategoryDescrip', _t( |
|
164 | 164 | 'FoxyStripeSiteConfig.CategoryDescrip', |
165 | 165 | '<p>FoxyCart Categories offer a way to give products additional behaviors that cannot be accomplished by product options alone, including category specific coupon codes, shipping and handling fees, and email receipts. <a href="https://wiki.foxycart.com/v/2.0/categories" target="_blank">Learn More</a></p><p>Categories you\'ve created in FoxyStripe must also be created in your <a href="https://admin.foxycart.com/admin.php?ThisAction=ManageProductCategories" target="_blank">FoxyCart Categories</a> admin panel.</p>' |
166 | 166 | )), |
167 | - GridField::create( |
|
167 | + GridField::create( |
|
168 | 168 | 'ProductCategory', |
169 | 169 | _t('FoxyStripeSiteConfig.ProductCategory', 'FoxyCart Categories'), |
170 | 170 | ProductCategory::get(), |
171 | 171 | GridFieldConfig_RecordEditor::create() |
172 | 172 | ) |
173 | - )); |
|
173 | + )); |
|
174 | 174 | |
175 | 175 | // option groups tab |
176 | - $fields->addFieldsToTab('Root.FoxyStripe.Groups', array( |
|
177 | - HeaderField::create('OptionGroupsHead', _t('FoxyStripeSiteConfig', 'Product Option Groups'), 3), |
|
178 | - LiteralField::create('OptionGroupsDescrip', _t( |
|
176 | + $fields->addFieldsToTab('Root.FoxyStripe.Groups', array( |
|
177 | + HeaderField::create('OptionGroupsHead', _t('FoxyStripeSiteConfig', 'Product Option Groups'), 3), |
|
178 | + LiteralField::create('OptionGroupsDescrip', _t( |
|
179 | 179 | 'FoxyStripeSiteConfig.OptionGroupsDescrip', |
180 | 180 | '<p>Product Option Groups allow you to name a set of product options.</p>' |
181 | 181 | )), |
182 | - GridField::create( |
|
182 | + GridField::create( |
|
183 | 183 | 'OptionGroup', |
184 | 184 | _t('FoxyStripeSiteConfig.OptionGroup', 'Product Option Groups'), |
185 | 185 | OptionGroup::get(), |
186 | 186 | GridFieldConfig_RecordEditor::create() |
187 | 187 | ) |
188 | - )); |
|
188 | + )); |
|
189 | 189 | |
190 | - // api tab |
|
190 | + // api tab |
|
191 | 191 | $fields->addFieldsToTab('Root.FoxyStripe.API', [ |
192 | 192 | HeaderField::create('APIHD', 'FoxyCart API Settings', 3), |
193 | 193 | TextField::create('client_id', 'FoxyCart Client ID'), |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | TextField::create('refresh_token', 'FoxyCart Refresh Token'), |
197 | 197 | ]); |
198 | 198 | |
199 | - } |
|
199 | + } |
|
200 | 200 | |
201 | 201 | private static function getSSOLink() { |
202 | 202 | return Director::absoluteBaseURL()."foxystripe/sso/"; |
@@ -38,6 +38,9 @@ |
||
38 | 38 | } |
39 | 39 | } |
40 | 40 | |
41 | + /** |
|
42 | + * @param string $encrypted |
|
43 | + */ |
|
41 | 44 | public function handleDataFeed($encrypted, $decrypted){ |
42 | 45 | |
43 | 46 | $orders = new SimpleXMLElement($decrypted); |
@@ -2,41 +2,41 @@ discard block |
||
2 | 2 | |
3 | 3 | class FoxyStripe_Controller extends Page_Controller { |
4 | 4 | |
5 | - const URLSegment = 'foxystripe'; |
|
5 | + const URLSegment = 'foxystripe'; |
|
6 | 6 | |
7 | - public function getURLSegment() { |
|
8 | - return self::URLSegment; |
|
9 | - } |
|
7 | + public function getURLSegment() { |
|
8 | + return self::URLSegment; |
|
9 | + } |
|
10 | 10 | |
11 | - static $allowed_actions = array( |
|
12 | - 'index', |
|
11 | + static $allowed_actions = array( |
|
12 | + 'index', |
|
13 | 13 | 'sso' |
14 | - ); |
|
14 | + ); |
|
15 | 15 | |
16 | - public function index() { |
|
16 | + public function index() { |
|
17 | 17 | |
18 | - // handle POST from FoxyCart API transaction |
|
19 | - if ((isset($_POST["FoxyData"]) OR isset($_POST['FoxySubscriptionData']))) { |
|
18 | + // handle POST from FoxyCart API transaction |
|
19 | + if ((isset($_POST["FoxyData"]) OR isset($_POST['FoxySubscriptionData']))) { |
|
20 | 20 | |
21 | - $FoxyData_encrypted = (isset($_POST["FoxyData"])) ? |
|
21 | + $FoxyData_encrypted = (isset($_POST["FoxyData"])) ? |
|
22 | 22 | urldecode($_POST["FoxyData"]) : |
23 | 23 | urldecode($_POST["FoxySubscriptionData"]); |
24 | - $FoxyData_decrypted = rc4crypt::decrypt(FoxyCart::getStoreKey(),$FoxyData_encrypted); |
|
24 | + $FoxyData_decrypted = rc4crypt::decrypt(FoxyCart::getStoreKey(),$FoxyData_encrypted); |
|
25 | 25 | |
26 | 26 | // parse the response and save the order |
27 | - self::handleDataFeed($FoxyData_encrypted, $FoxyData_decrypted); |
|
27 | + self::handleDataFeed($FoxyData_encrypted, $FoxyData_decrypted); |
|
28 | 28 | |
29 | - // extend to allow for additional integrations with Datafeed |
|
30 | - $this->extend('addIntegrations', $FoxyData_encrypted); |
|
29 | + // extend to allow for additional integrations with Datafeed |
|
30 | + $this->extend('addIntegrations', $FoxyData_encrypted); |
|
31 | 31 | |
32 | - return 'foxy'; |
|
32 | + return 'foxy'; |
|
33 | 33 | |
34 | - } else { |
|
34 | + } else { |
|
35 | 35 | |
36 | - return "No FoxyData or FoxySubscriptionData received."; |
|
36 | + return "No FoxyData or FoxySubscriptionData received."; |
|
37 | 37 | |
38 | - } |
|
39 | - } |
|
38 | + } |
|
39 | + } |
|
40 | 40 | |
41 | 41 | public function handleDataFeed($encrypted, $decrypted){ |
42 | 42 | |
@@ -63,10 +63,10 @@ discard block |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | |
66 | - // Single Sign on integration with FoxyCart |
|
66 | + // Single Sign on integration with FoxyCart |
|
67 | 67 | public function sso() { |
68 | 68 | |
69 | - // GET variables from FoxyCart Request |
|
69 | + // GET variables from FoxyCart Request |
|
70 | 70 | $fcsid = $this->request->getVar('fcsid'); |
71 | 71 | $timestampNew = strtotime('+30 days'); |
72 | 72 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $redirect_complete = 'https://' . FoxyCart::getFoxyCartStoreName() . '.foxycart.com/checkout?fc_auth_token=' . $auth_token . |
86 | 86 | '&fcsid=' . $fcsid . '&fc_customer_id=' . $Member->Customer_ID . '×tamp=' . $timestampNew; |
87 | 87 | |
88 | - $this->redirect($redirect_complete); |
|
88 | + $this->redirect($redirect_complete); |
|
89 | 89 | |
90 | 90 | } |
91 | 91 |
@@ -19,9 +19,8 @@ discard block |
||
19 | 19 | if ((isset($_POST["FoxyData"]) OR isset($_POST['FoxySubscriptionData']))) { |
20 | 20 | |
21 | 21 | $FoxyData_encrypted = (isset($_POST["FoxyData"])) ? |
22 | - urldecode($_POST["FoxyData"]) : |
|
23 | - urldecode($_POST["FoxySubscriptionData"]); |
|
24 | - $FoxyData_decrypted = rc4crypt::decrypt(FoxyCart::getStoreKey(),$FoxyData_encrypted); |
|
22 | + urldecode($_POST["FoxyData"]) : urldecode($_POST["FoxySubscriptionData"]); |
|
23 | + $FoxyData_decrypted = rc4crypt::decrypt(FoxyCart::getStoreKey(), $FoxyData_encrypted); |
|
25 | 24 | |
26 | 25 | // parse the response and save the order |
27 | 26 | self::handleDataFeed($FoxyData_encrypted, $FoxyData_decrypted); |
@@ -31,14 +30,14 @@ discard block |
||
31 | 30 | |
32 | 31 | return 'foxy'; |
33 | 32 | |
34 | - } else { |
|
33 | + }else { |
|
35 | 34 | |
36 | 35 | return "No FoxyData or FoxySubscriptionData received."; |
37 | 36 | |
38 | 37 | } |
39 | 38 | } |
40 | 39 | |
41 | - public function handleDataFeed($encrypted, $decrypted){ |
|
40 | + public function handleDataFeed($encrypted, $decrypted) { |
|
42 | 41 | |
43 | 42 | $orders = new SimpleXMLElement($decrypted); |
44 | 43 | |
@@ -48,12 +47,11 @@ discard block |
||
48 | 47 | // if FoxyCart order id, then parse order |
49 | 48 | if (isset($transaction->id)) { |
50 | 49 | |
51 | - ($order = Order::get()->filter('Order_ID', (int) $transaction->id)->First()) ? |
|
52 | - $order = Order::get()->filter('Order_ID', (int) $transaction->id)->First() : |
|
53 | - $order = Order::create(); |
|
50 | + ($order = Order::get()->filter('Order_ID', (int)$transaction->id)->First()) ? |
|
51 | + $order = Order::get()->filter('Order_ID', (int)$transaction->id)->First() : $order = Order::create(); |
|
54 | 52 | |
55 | 53 | // save base order info |
56 | - $order->Order_ID = (int) $transaction->id; |
|
54 | + $order->Order_ID = (int)$transaction->id; |
|
57 | 55 | $order->Response = urlencode($encrypted); |
58 | 56 | $order->write(); |
59 | 57 | |
@@ -73,17 +71,17 @@ discard block |
||
73 | 71 | // get current member if logged in. If not, create a 'fake' user with Customer_ID = 0 |
74 | 72 | // fake user will redirect to FC checkout, ask customer to log in |
75 | 73 | // to do: consider a login/registration form here if not logged in |
76 | - if($Member = Member::currentUser()) { |
|
74 | + if ($Member = Member::currentUser()) { |
|
77 | 75 | $Member = Member::currentUser(); |
78 | - } else { |
|
76 | + }else { |
|
79 | 77 | $Member = new Member(); |
80 | 78 | $Member->Customer_ID = 0; |
81 | 79 | } |
82 | 80 | |
83 | - $auth_token = sha1($Member->Customer_ID . '|' . $timestampNew . '|' . FoxyCart::getStoreKey()); |
|
81 | + $auth_token = sha1($Member->Customer_ID.'|'.$timestampNew.'|'.FoxyCart::getStoreKey()); |
|
84 | 82 | |
85 | - $redirect_complete = 'https://' . FoxyCart::getFoxyCartStoreName() . '.foxycart.com/checkout?fc_auth_token=' . $auth_token . |
|
86 | - '&fcsid=' . $fcsid . '&fc_customer_id=' . $Member->Customer_ID . '×tamp=' . $timestampNew; |
|
83 | + $redirect_complete = 'https://'.FoxyCart::getFoxyCartStoreName().'.foxycart.com/checkout?fc_auth_token='.$auth_token. |
|
84 | + '&fcsid='.$fcsid.'&fc_customer_id='.$Member->Customer_ID.'×tamp='.$timestampNew; |
|
87 | 85 | |
88 | 86 | $this->redirect($redirect_complete); |
89 | 87 |