Completed
Pull Request — master (#287)
by Nic
07:56
created
tests/FoxyStripeProductTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,14 +53,14 @@
 block discarded – undo
53 53
         $product2->doPublish();
54 54
         $this->assertTrue($product2->isPublished());
55 55
 
56
-        $versions = DB::query('Select * FROM "ShippableProduct_versions" WHERE "RecordID" = ' . $productID);
56
+        $versions = DB::query('Select * FROM "ShippableProduct_versions" WHERE "RecordID" = '.$productID);
57 57
         $versionsPostPublish = array();
58 58
         foreach ($versions as $versionRow) $versionsPostPublish[] = $versionRow;
59 59
 
60 60
         $product2->delete();
61 61
         $this->assertTrue(!$product2->isPublished());
62 62
 
63
-        $versions = DB::query('Select * FROM "ShippableProduct_versions" WHERE "RecordID" = ' . $productID);
63
+        $versions = DB::query('Select * FROM "ShippableProduct_versions" WHERE "RecordID" = '.$productID);
64 64
         $versionsPostDelete = array();
65 65
         foreach ($versions as $versionRow) $versionsPostDelete[] = $versionRow;
66 66
 
Please login to merge, or discard this patch.
code/model/FoxyCart.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -19,14 +19,14 @@  discard block
 block discarded – undo
19 19
      */
20 20
     public static function setStoreKey($length = 54, $count = 0)
21 21
     {
22
-        $charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' . strtotime('now');
22
+        $charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.strtotime('now');
23 23
         $strLength = strlen($charset);
24 24
         $str = '';
25 25
         while ($count < $length) {
26 26
             $str .= $charset[mt_rand(0, $strLength - 1)];
27 27
             $count++;
28 28
         }
29
-        return static::get_key_prefix() . substr(base64_encode($str), 0, $length);
29
+        return static::get_key_prefix().substr(base64_encode($str), 0, $length);
30 30
     }
31 31
 
32 32
     /**
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
     private static function getAPIRequest($foxyData = array())
83 83
     {
84 84
 
85
-        $foxy_domain = static::get_foxy_cart_store_name() . '.foxycart.com';
85
+        $foxy_domain = static::get_foxy_cart_store_name().'.foxycart.com';
86 86
         $foxyData["api_token"] = FoxyCart::get_store_key();
87 87
 
88 88
         $ch = curl_init();
89
-        curl_setopt($ch, CURLOPT_URL, "https://" . $foxy_domain . "/api");
89
+        curl_setopt($ch, CURLOPT_URL, "https://".$foxy_domain."/api");
90 90
         curl_setopt($ch, CURLOPT_POSTFIELDS, $foxyData);
91 91
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
92 92
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 
96 96
         // The following if block will print any CURL errors you might have
97 97
         if ($response == false) {
98
-            SS_Log::log("Could not connect to FoxyCart API: " . $response, SS_Log::ERR);
98
+            SS_Log::log("Could not connect to FoxyCart API: ".$response, SS_Log::ERR);
99 99
         }
100 100
         curl_close($ch);
101 101
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
     public static function putCustomer(Member $Member = null)
131 131
     {
132 132
         // throw error if no $Member Object
133
-        if (!isset($Member)) ;//trigger_error('No Member set', E_USER_ERROR);
133
+        if (!isset($Member)); //trigger_error('No Member set', E_USER_ERROR);
134 134
 
135 135
         // send updated customer record from API
136 136
         $foxyData = array();
Please login to merge, or discard this patch.
code/controllers/FoxyStripe_Controller.php 1 patch
Spacing   +13 added lines, -15 removed lines patch added patch discarded remove patch
@@ -17,9 +17,8 @@  discard block
 block discarded – undo
17 17
 	    // handle POST from FoxyCart API transaction
18 18
 		if ((isset($_POST["FoxyData"]) OR isset($_POST['FoxySubscriptionData']))) {
19 19
 			$FoxyData_encrypted = (isset($_POST["FoxyData"])) ?
20
-                urldecode($_POST["FoxyData"]) :
21
-                urldecode($_POST["FoxySubscriptionData"]);
22
-			$FoxyData_decrypted = rc4crypt::decrypt(FoxyCart::get_store_key(),$FoxyData_encrypted);
20
+                urldecode($_POST["FoxyData"]) : urldecode($_POST["FoxySubscriptionData"]);
21
+			$FoxyData_decrypted = rc4crypt::decrypt(FoxyCart::get_store_key(), $FoxyData_encrypted);
23 22
 			self::handleDataFeed($FoxyData_encrypted, $FoxyData_decrypted);
24 23
 			
25 24
 			// extend to allow for additional integrations with Datafeed
@@ -27,14 +26,14 @@  discard block
 block discarded – undo
27 26
 			
28 27
 			return 'foxy';
29 28
 			
30
-		} else {
29
+		}else {
31 30
 			
32 31
 			return "No FoxyData or FoxySubscriptionData received.";
33 32
 			
34 33
 		}
35 34
 	}
36 35
 
37
-    public function handleDataFeed($encrypted, $decrypted){
36
+    public function handleDataFeed($encrypted, $decrypted) {
38 37
         //handle encrypted & decrypted data
39 38
         $orders = new SimpleXMLElement($decrypted);
40 39
 
@@ -43,12 +42,11 @@  discard block
 block discarded – undo
43 42
 
44 43
             if (isset($order->id)) {
45 44
                 ($transaction = Order::get()->filter('Order_ID', $order->id)->First()) ?
46
-                    $transaction :
47
-                    $transaction = Order::create();
45
+                    $transaction : $transaction = Order::create();
48 46
             }
49 47
 
50 48
             // save base order info
51
-            $transaction->Order_ID = (int) $order->id;
49
+            $transaction->Order_ID = (int)$order->id;
52 50
             $transaction->Response = $decrypted;
53 51
 
54 52
             // record transaction as order
@@ -103,11 +101,11 @@  discard block
 block discarded – undo
103 101
             if (isset($order->customer_email) && $order->is_anonymous == 0) {
104 102
 
105 103
                 // if Customer is existing member, associate with current order
106
-                if(Member::get()->filter('Email', $order->customer_email)->First()) {
104
+                if (Member::get()->filter('Email', $order->customer_email)->First()) {
107 105
 
108 106
                     $customer = Member::get()->filter('Email', $order->customer_email)->First();
109 107
 
110
-                } else {
108
+                }else {
111 109
 
112 110
                     // set PasswordEncryption to 'none' so imported, encrypted password is not encrypted again
113 111
                     Config::inst()->update('Security', 'password_encryption_algorithm', 'none');
@@ -213,17 +211,17 @@  discard block
 block discarded – undo
213 211
         // get current member if logged in. If not, create a 'fake' user with Customer_ID = 0
214 212
         // fake user will redirect to FC checkout, ask customer to log in
215 213
         // to do: consider a login/registration form here if not logged in
216
-        if($Member = Member::currentUser()) {
214
+        if ($Member = Member::currentUser()) {
217 215
             $Member = Member::currentUser();
218
-        } else {
216
+        }else {
219 217
             $Member = new Member();
220 218
             $Member->Customer_ID = 0;
221 219
         }
222 220
 
223
-        $auth_token = sha1($Member->Customer_ID . '|' . $timestampNew . '|' . FoxyCart::get_store_key());
221
+        $auth_token = sha1($Member->Customer_ID.'|'.$timestampNew.'|'.FoxyCart::get_store_key());
224 222
 
225
-        $redirect_complete = 'https://' . FoxyCart::get_foxy_cart_store_name() . '.foxycart.com/checkout?fc_auth_token=' . $auth_token .
226
-            '&fcsid=' . $fcsid . '&fc_customer_id=' . $Member->Customer_ID . '&timestamp=' . $timestampNew;
223
+        $redirect_complete = 'https://'.FoxyCart::get_foxy_cart_store_name().'.foxycart.com/checkout?fc_auth_token='.$auth_token.
224
+            '&fcsid='.$fcsid.'&fc_customer_id='.$Member->Customer_ID.'&timestamp='.$timestampNew;
227 225
 	
228 226
 	    $this->redirect($redirect_complete);
229 227
 
Please login to merge, or discard this patch.
code/objects/products/FoxyStripeProduct.php 1 patch
Spacing   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
         $previewDescription = ($this->stat('customPreviewDescription')) ? $this->stat('customPreviewDescription') : _t('ProductPage.PreviewImageDescription', 'Image used throughout site to represent this product');
123 123
 
124 124
         // Cateogry Dropdown field w/ add new
125
-        $source = function () {
125
+        $source = function() {
126 126
             return FoxyCartProductCategory::get()->map()->toArray();
127 127
         };
128 128
         $catField = DropdownField::create('CategoryID', _t('ProductPage.Category', 'FoxyCart Category'), $source())
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
         if (class_exists('GridFieldSortableRows')) {
160 160
             $config->addComponent(new GridFieldSortableRows('SortOrder'));
161 161
             $products = $this->ProductOptions()->sort('SortOrder');
162
-        } else {
162
+        }else {
163 163
             $products = $this->ProductOptions();
164 164
         }
165 165
         $config->removeComponentsByType('GridFieldAddExistingAutocompleter');
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
                 ->setFolderName('Uploads/Products')
216 216
                 ->setAllowedExtensions(['jpg', 'jpeg', 'gif', 'png'])
217 217
                 ->setAllowedMaxFileNumber(1),
218
-            HeaderField::create('ProductImagesHD', _t('ProductPage.ProductImagesHD' . 'Product Image Gallery'), 2),
218
+            HeaderField::create('ProductImagesHD', _t('ProductPage.ProductImagesHD'.'Product Image Gallery'), 2),
219 219
             $prodImagesField
220 220
                 ->setDescription(_t(
221 221
                     'ProductPage.ProductImagesDescription',
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
             $product = ProductPage::get()->byID($this->ID);
274 274
             if (isset($product->ParentID)) {
275 275
                 $origParent = $product->ParentID;
276
-            } else {
276
+            }else {
277 277
                 $origParent = null;
278 278
             }
279 279
             $currentParent = $this->ParentID;
@@ -348,8 +348,7 @@  discard block
 block discarded – undo
348 348
     {
349 349
         $optionName = ($optionName !== null) ? preg_replace('/\s/', '_', $optionName) : $optionName;
350 350
         return (SiteConfig::current_site_config()->CartValidation)
351
-            ? FoxyCart_Helper::fc_hash_value($productCode, $optionName, $optionValue, $method, $output, $urlEncode) :
352
-            $optionValue;
351
+            ? FoxyCart_Helper::fc_hash_value($productCode, $optionName, $optionValue, $method, $output, $urlEncode) : $optionValue;
353 352
     }
354 353
 
355 354
     /**
Please login to merge, or discard this patch.
code/objects/OptionItem.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
         $parentCode = $product->Code;
73 73
 
74 74
         // ProductOptionGroup Dropdown field w/ add new
75
-        $groups = function () {
75
+        $groups = function() {
76 76
             return OptionGroup::get()->map()->toArray();
77 77
         };
78 78
         $groupFields = singleton('OptionGroup')->getCMSFields();
@@ -198,17 +198,17 @@  discard block
 block discarded – undo
198 198
 
199 199
     public function getWeightModifierWithSymbol()
200 200
     {
201
-        return self::getOptionModifierActionSymbol($this->WeightModifierAction) . $this->WeightModifier;
201
+        return self::getOptionModifierActionSymbol($this->WeightModifierAction).$this->WeightModifier;
202 202
     }
203 203
 
204 204
     public function getPriceModifierWithSymbol()
205 205
     {
206
-        return self::getOptionModifierActionSymbol($this->PriceModifierAction) . $this->PriceModifier;
206
+        return self::getOptionModifierActionSymbol($this->PriceModifierAction).$this->PriceModifier;
207 207
     }
208 208
 
209 209
     public function getCodeModifierWithSymbol()
210 210
     {
211
-        return self::getOptionModifierActionSymbol($this->CodeModifierAction) . $this->CodeModifier;
211
+        return self::getOptionModifierActionSymbol($this->CodeModifierAction).$this->CodeModifier;
212 212
     }
213 213
 
214 214
     public function getProductOptionGroupTitle()
@@ -219,18 +219,18 @@  discard block
 block discarded – undo
219 219
     public function getGeneratedValue()
220 220
     {
221 221
         $modPrice = ($this->PriceModifier) ? (string)$this->PriceModifier : '0';
222
-        $modPriceWithSymbol = OptionItem::getOptionModifierActionSymbol($this->PriceModifierAction) . $modPrice;
222
+        $modPriceWithSymbol = OptionItem::getOptionModifierActionSymbol($this->PriceModifierAction).$modPrice;
223 223
         $modWeight = ($this->WeightModifier) ? (string)$this->WeightModifier : '0';
224
-        $modWeight = OptionItem::getOptionModifierActionSymbol($this->WeightModifierAction) . $modWeight;
225
-        $modCode = OptionItem::getOptionModifierActionSymbol($this->CodeModifierAction) . $this->CodeModifier;
226
-        return $this->Title . '{p' . $modPriceWithSymbol . '|w' . $modWeight . '|c' . $modCode . '}';
224
+        $modWeight = OptionItem::getOptionModifierActionSymbol($this->WeightModifierAction).$modWeight;
225
+        $modCode = OptionItem::getOptionModifierActionSymbol($this->CodeModifierAction).$this->CodeModifier;
226
+        return $this->Title.'{p'.$modPriceWithSymbol.'|w'.$modWeight.'|c'.$modCode.'}';
227 227
     }
228 228
 
229 229
     public function getGeneratedTitle()
230 230
     {
231 231
         $modPrice = ($this->PriceModifier) ? (string)$this->PriceModifier : '0';
232 232
         $title = $this->Title;
233
-        $title .= ($this->PriceModifier != 0) ? ': (' . OptionItem::getOptionModifierActionSymbol($this->PriceModifierAction, $returnWithOnlyPlusMinus = true) . '$' . $modPrice . ')' : '';
233
+        $title .= ($this->PriceModifier != 0) ? ': ('.OptionItem::getOptionModifierActionSymbol($this->PriceModifierAction, $returnWithOnlyPlusMinus = true).'$'.$modPrice.')' : '';
234 234
         return $title;
235 235
     }
236 236
 
Please login to merge, or discard this patch.