@@ -45,8 +45,7 @@ discard block |
||
45 | 45 | // handle POST from FoxyCart API transaction |
46 | 46 | if ((isset($_POST['FoxyData']) or isset($_POST['FoxySubscriptionData']))) { |
47 | 47 | $FoxyData_encrypted = (isset($_POST['FoxyData'])) ? |
48 | - urldecode($_POST['FoxyData']) : |
|
49 | - urldecode($_POST['FoxySubscriptionData']); |
|
48 | + urldecode($_POST['FoxyData']) : urldecode($_POST['FoxySubscriptionData']); |
|
50 | 49 | $FoxyData_decrypted = \rc4crypt::decrypt(FoxyCart::getStoreKey(), $FoxyData_encrypted); |
51 | 50 | |
52 | 51 | // parse the response and save the order |
@@ -56,7 +55,7 @@ discard block |
||
56 | 55 | $this->extend('addIntegrations', $FoxyData_encrypted); |
57 | 56 | |
58 | 57 | return 'foxy'; |
59 | - } else { |
|
58 | + }else { |
|
60 | 59 | return 'No FoxyData or FoxySubscriptionData received.'; |
61 | 60 | } |
62 | 61 | } |
@@ -149,7 +148,7 @@ discard block |
||
149 | 148 | /* todo: make sure local password is updated if changed on FoxyCart |
150 | 149 | $this->updatePasswordFromData($customer, $order); |
151 | 150 | */ |
152 | - } else { |
|
151 | + }else { |
|
153 | 152 | // create new Member, set password info from FoxyCart |
154 | 153 | $customer = Member::create(); |
155 | 154 | $customer->Customer_ID = (int)$order->customer_id; |
@@ -322,22 +321,22 @@ discard block |
||
322 | 321 | // to do: consider a login/registration form here if not logged in |
323 | 322 | if ($Member = Security::getCurrentUser()) { |
324 | 323 | $Member = Security::getCurrentUser(); |
325 | - } else { |
|
324 | + }else { |
|
326 | 325 | $Member = new Member(); |
327 | 326 | $Member->Customer_ID = 0; |
328 | 327 | } |
329 | 328 | |
330 | - $auth_token = sha1($Member->Customer_ID . '|' . $timestampNew . '|' . FoxyCart::getStoreKey()); |
|
329 | + $auth_token = sha1($Member->Customer_ID.'|'.$timestampNew.'|'.FoxyCart::getStoreKey()); |
|
331 | 330 | |
332 | 331 | $config = FoxyStripeSetting::current_foxystripe_setting(); |
333 | 332 | if ($config->CustomSSL) { |
334 | 333 | $link = FoxyCart::getFoxyCartStoreName(); |
335 | - } else { |
|
336 | - $link = FoxyCart::getFoxyCartStoreName() . '.foxycart.com'; |
|
334 | + }else { |
|
335 | + $link = FoxyCart::getFoxyCartStoreName().'.foxycart.com'; |
|
337 | 336 | } |
338 | 337 | |
339 | - $redirect_complete = 'https://' . $link . '/checkout?fc_auth_token=' . $auth_token . '&fcsid=' . $fcsid . |
|
340 | - '&fc_customer_id=' . $Member->Customer_ID . '×tamp=' . $timestampNew; |
|
338 | + $redirect_complete = 'https://'.$link.'/checkout?fc_auth_token='.$auth_token.'&fcsid='.$fcsid. |
|
339 | + '&fc_customer_id='.$Member->Customer_ID.'×tamp='.$timestampNew; |
|
341 | 340 | |
342 | 341 | $this->redirect($redirect_complete); |
343 | 342 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function getCMSFields() |
71 | 71 | { |
72 | - $this->beforeUpdateCMSFields(function (FieldList $fields) { |
|
72 | + $this->beforeUpdateCMSFields(function(FieldList $fields) { |
|
73 | 73 | if (FoxyStripeSetting::current_foxystripe_setting()->MultiGroup) { |
74 | 74 | $config = GridFieldConfig_RelationEditor::create(); |
75 | 75 | $config->addComponent(new GridFieldOrderableRows('SortOrder')); |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | |
151 | 151 | if ($config->MultiGroup) { |
152 | 152 | $entries = $this->Products()->sort('SortOrder'); |
153 | - } else { |
|
154 | - $filter = '"ParentID" = ' . $this->ID; |
|
153 | + }else { |
|
154 | + $filter = '"ParentID" = '.$this->ID; |
|
155 | 155 | |
156 | 156 | // Build a list of all IDs for ProductGroups that are children |
157 | 157 | $holderIDs = $this->ProductGroupIDs(); |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | if ($filter) { |
163 | 163 | $filter .= ' OR '; |
164 | 164 | } |
165 | - $filter .= '"ParentID" IN (' . implode(',', $holderIDs) . ')'; |
|
165 | + $filter .= '"ParentID" IN ('.implode(',', $holderIDs).')'; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | $order = '"SiteTree"."Title" ASC'; |
@@ -117,12 +117,10 @@ discard block |
||
117 | 117 | $this->setSiteConfig($siteConfig); |
118 | 118 | |
119 | 119 | $fields = ($fields != null && $fields->exists()) ? |
120 | - $this->getProductFields($fields) : |
|
121 | - $this->getProductFields(FieldList::create()); |
|
120 | + $this->getProductFields($fields) : $this->getProductFields(FieldList::create()); |
|
122 | 121 | |
123 | 122 | $actions = ($actions != null && $actions->exists()) ? |
124 | - $this->getProductActions($actions) : |
|
125 | - $this->getProductActions(FieldList::create()); |
|
123 | + $this->getProductActions($actions) : $this->getProductActions(FieldList::create()); |
|
126 | 124 | $validator = (!empty($validator) || $validator != null) ? $validator : RequiredFields::create(); |
127 | 125 | |
128 | 126 | parent::__construct($controller, $name, $fields, $actions, $validator); |
@@ -131,7 +129,7 @@ discard block |
||
131 | 129 | $this->setAttribute('action', FoxyCart::FormActionURL()); |
132 | 130 | $this->disableSecurityToken(); |
133 | 131 | |
134 | - $this->setHTMLID($this->getTemplateHelper()->generateFormID($this) . "_{$product->ID}"); |
|
132 | + $this->setHTMLID($this->getTemplateHelper()->generateFormID($this)."_{$product->ID}"); |
|
135 | 133 | } |
136 | 134 | |
137 | 135 | /** |
@@ -143,8 +141,7 @@ discard block |
||
143 | 141 | { |
144 | 142 | //Requirements::javascript('dynamic/foxystripe: client/dist/javascript/scripts.min.js'); |
145 | 143 | $hiddenTitle = ($this->product->ReceiptTitle) ? |
146 | - htmlspecialchars($this->product->ReceiptTitle) : |
|
147 | - htmlspecialchars($this->product->Title); |
|
144 | + htmlspecialchars($this->product->ReceiptTitle) : htmlspecialchars($this->product->Title); |
|
148 | 145 | $code = $this->product->Code; |
149 | 146 | |
150 | 147 | if ($this->getProduct()->getIsAvailable()) { |
@@ -178,7 +175,7 @@ discard block |
||
178 | 175 | ->setValue( |
179 | 176 | ProductPage::getGeneratedValue($code, 'price', $this->product->Price, 'value') |
180 | 177 | ) |
181 | - );//can't override id |
|
178 | + ); //can't override id |
|
182 | 179 | if ($this->product->Weight > 0) { |
183 | 180 | $fields->push( |
184 | 181 | HiddenField::create('weight') |
@@ -221,7 +218,7 @@ discard block |
||
221 | 218 | ); |
222 | 219 | |
223 | 220 | $fields->push( |
224 | - HeaderField::create('submitPrice', '$' . $this->product->Price, 4) |
|
221 | + HeaderField::create('submitPrice', '$'.$this->product->Price, 4) |
|
225 | 222 | ->addExtraClass('submit-price') |
226 | 223 | ); |
227 | 224 | $fields->push( |
@@ -234,7 +231,7 @@ discard block |
||
234 | 231 | } |
235 | 232 | |
236 | 233 | $this->extend('updatePurchaseFormFields', $fields); |
237 | - } else { |
|
234 | + }else { |
|
238 | 235 | $fields->push(HeaderField::create('unavailableText', 'Currently Out of Stock', 4)); |
239 | 236 | } |
240 | 237 |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | if ($config->RemoteDomain) { |
76 | 76 | return $config->RemoteDomain; |
77 | 77 | } |
78 | - } else { |
|
78 | + }else { |
|
79 | 79 | if ($config->StoreName) { |
80 | 80 | return $config->StoreName; |
81 | 81 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $config = FoxyStripeSetting::current_foxystripe_setting(); |
94 | 94 | if ($config->CustomSSL) { |
95 | 95 | return sprintf('https://%s/cart', self::getFoxyCartStoreName()); |
96 | - } else { |
|
96 | + }else { |
|
97 | 97 | return sprintf('https://%s.foxycart.com/cart', self::getFoxyCartStoreName()); |
98 | 98 | } |
99 | 99 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $config = FoxyStripeSetting::current_foxystripe_setting(); |
114 | 114 | if ($config->CustomSSL) { |
115 | 115 | $foxy_domain = self::getFoxyCartStoreName(); |
116 | - } else { |
|
116 | + }else { |
|
117 | 117 | $foxy_domain = self::getFoxyCartStoreName().'.foxycart.com'; |
118 | 118 | } |
119 | 119 |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | $this->parseOrderDetails($response); |
212 | 212 | |
213 | 213 | return true; |
214 | - } else { |
|
214 | + }else { |
|
215 | 215 | return false; |
216 | 216 | } |
217 | 217 | } |
@@ -223,14 +223,14 @@ discard block |
||
223 | 223 | { |
224 | 224 | foreach ($response->transactions->transaction as $transaction) { |
225 | 225 | // Record transaction data from FoxyCart Datafeed: |
226 | - $this->Store_ID = (int) $transaction->store_id; |
|
227 | - $this->TransactionDate = (string) $transaction->transaction_date; |
|
228 | - $this->ProductTotal = (float) $transaction->product_total; |
|
229 | - $this->TaxTotal = (float) $transaction->tax_total; |
|
230 | - $this->ShippingTotal = (float) $transaction->shipping_total; |
|
231 | - $this->OrderTotal = (float) $transaction->order_total; |
|
232 | - $this->ReceiptURL = (string) $transaction->receipt_url; |
|
233 | - $this->OrderStatus = (string) $transaction->status; |
|
226 | + $this->Store_ID = (int)$transaction->store_id; |
|
227 | + $this->TransactionDate = (string)$transaction->transaction_date; |
|
228 | + $this->ProductTotal = (float)$transaction->product_total; |
|
229 | + $this->TaxTotal = (float)$transaction->tax_total; |
|
230 | + $this->ShippingTotal = (float)$transaction->shipping_total; |
|
231 | + $this->OrderTotal = (float)$transaction->order_total; |
|
232 | + $this->ReceiptURL = (string)$transaction->receipt_url; |
|
233 | + $this->OrderStatus = (string)$transaction->status; |
|
234 | 234 | |
235 | 235 | $this->extend('handleOrderInfo', $this, $response); |
236 | 236 | } |
@@ -249,18 +249,18 @@ discard block |
||
249 | 249 | if (Member::get()->filter('Email', $transaction->customer_email)->First()) { |
250 | 250 | $customer = Member::get()->filter('Email', $transaction->customer_email)->First(); |
251 | 251 | // if new customer, create account with data from FoxyCart |
252 | - } else { |
|
252 | + }else { |
|
253 | 253 | // set PasswordEncryption to 'none' so imported, encrypted password is not encrypted again |
254 | 254 | Config::modify()->set(Security::class, 'password_encryption_algorithm', 'none'); |
255 | 255 | |
256 | 256 | // create new Member, set password info from FoxyCart |
257 | 257 | $customer = Member::create(); |
258 | - $customer->Customer_ID = (int) $transaction->customer_id; |
|
259 | - $customer->FirstName = (string) $transaction->customer_first_name; |
|
260 | - $customer->Surname = (string) $transaction->customer_last_name; |
|
261 | - $customer->Email = (string) $transaction->customer_email; |
|
262 | - $customer->Password = (string) $transaction->customer_password; |
|
263 | - $customer->Salt = (string) $transaction->customer_password_salt; |
|
258 | + $customer->Customer_ID = (int)$transaction->customer_id; |
|
259 | + $customer->FirstName = (string)$transaction->customer_first_name; |
|
260 | + $customer->Surname = (string)$transaction->customer_last_name; |
|
261 | + $customer->Email = (string)$transaction->customer_email; |
|
262 | + $customer->Password = (string)$transaction->customer_password; |
|
263 | + $customer->Salt = (string)$transaction->customer_password_salt; |
|
264 | 264 | $customer->PasswordEncryption = 'none'; |
265 | 265 | |
266 | 266 | // record member record |
@@ -297,11 +297,11 @@ discard block |
||
297 | 297 | foreach ($transaction->transaction_details->transaction_detail as $detail) { |
298 | 298 | $OrderDetail = OrderDetail::create(); |
299 | 299 | |
300 | - $OrderDetail->Quantity = (int) $detail->product_quantity; |
|
301 | - $OrderDetail->ProductName = (string) $detail->product_name; |
|
302 | - $OrderDetail->ProductCode = (string) $detail->product_code; |
|
303 | - $OrderDetail->ProductImage = (string) $detail->image; |
|
304 | - $OrderDetail->ProductCategory = (string) $detail->category_code; |
|
300 | + $OrderDetail->Quantity = (int)$detail->product_quantity; |
|
301 | + $OrderDetail->ProductName = (string)$detail->product_name; |
|
302 | + $OrderDetail->ProductCode = (string)$detail->product_code; |
|
303 | + $OrderDetail->ProductImage = (string)$detail->image; |
|
304 | + $OrderDetail->ProductCategory = (string)$detail->category_code; |
|
305 | 305 | $priceModifier = 0; |
306 | 306 | |
307 | 307 | // parse OrderOptions |
@@ -309,14 +309,14 @@ discard block |
||
309 | 309 | // Find product via product_id custom variable |
310 | 310 | if ($option->product_option_name == 'product_id') { |
311 | 311 | // if product is found, set relation to OrderDetail |
312 | - $OrderProduct = ProductPage::get()->byID((int) $option->product_option_value); |
|
312 | + $OrderProduct = ProductPage::get()->byID((int)$option->product_option_value); |
|
313 | 313 | if ($OrderProduct) { |
314 | 314 | $OrderDetail->ProductID = $OrderProduct->ID; |
315 | 315 | } |
316 | - } else { |
|
316 | + }else { |
|
317 | 317 | $OrderOption = OrderOption::create(); |
318 | - $OrderOption->Name = (string) $option->product_option_name; |
|
319 | - $OrderOption->Value = (string) $option->product_option_value; |
|
318 | + $OrderOption->Name = (string)$option->product_option_name; |
|
319 | + $OrderOption->Value = (string)$option->product_option_value; |
|
320 | 320 | $OrderOption->write(); |
321 | 321 | $OrderDetail->OrderOptions()->add($OrderOption); |
322 | 322 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
327 | - $OrderDetail->Price = (float) $detail->product_price + (float) $priceModifier; |
|
327 | + $OrderDetail->Price = (float)$detail->product_price + (float)$priceModifier; |
|
328 | 328 | |
329 | 329 | // extend OrderDetail parsing, allowing for recording custom fields from FoxyCart |
330 | 330 | $this->extend('handleOrderItem', $this, $response, $OrderDetail); |