Completed
Push — 2 ( 3c1312...4bdd9a )
by Jason
09:11
created
code/model/FoxyCart.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -7,40 +7,40 @@  discard block
 block discarded – undo
7 7
 
8 8
 class FoxyCart extends Object {
9 9
 
10
-	private static $keyPrefix = 'dYnm1c';
11
-
12
-	public static function setStoreKey($length = 54, $count = 0){
13
-		$charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.strtotime('now');
14
-		$strLength = strlen($charset);
15
-		$str = '';
16
-		while($count < $length){
17
-			$str .= $charset[mt_rand(0, $strLength-1)];
18
-			$count++;
19
-		}
20
-		return self::getKeyPrefix().substr(base64_encode($str),0,$length);
21
-	}
22
-
23
-	public static function getStoreKey(){
24
-		$config = SiteConfig::current_site_config();
25
-		if($config->StoreKey){
26
-			return $config->StoreKey;
27
-		}
28
-		return null;
29
-	}
30
-
31
-	public static function store_name_warning(){
32
-		$warning = null;
33
-		if(self::getFoxyCartStoreName()===null){
34
-			$warning = 'Must define FoxyCart Store Name or Store Remote Domain in your site settings in the cms';
35
-		}
36
-		return $warning;
37
-	}
38
-
39
-	public static function getFoxyCartStoreName(){
40
-		$config = SiteConfig::current_site_config();
41
-		if ($config->CustomSSL) {
42
-		    if ($config->RemoteDomain) {
43
-		        return $config->RemoteDomain;
10
+    private static $keyPrefix = 'dYnm1c';
11
+
12
+    public static function setStoreKey($length = 54, $count = 0){
13
+        $charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.strtotime('now');
14
+        $strLength = strlen($charset);
15
+        $str = '';
16
+        while($count < $length){
17
+            $str .= $charset[mt_rand(0, $strLength-1)];
18
+            $count++;
19
+        }
20
+        return self::getKeyPrefix().substr(base64_encode($str),0,$length);
21
+    }
22
+
23
+    public static function getStoreKey(){
24
+        $config = SiteConfig::current_site_config();
25
+        if($config->StoreKey){
26
+            return $config->StoreKey;
27
+        }
28
+        return null;
29
+    }
30
+
31
+    public static function store_name_warning(){
32
+        $warning = null;
33
+        if(self::getFoxyCartStoreName()===null){
34
+            $warning = 'Must define FoxyCart Store Name or Store Remote Domain in your site settings in the cms';
35
+        }
36
+        return $warning;
37
+    }
38
+
39
+    public static function getFoxyCartStoreName(){
40
+        $config = SiteConfig::current_site_config();
41
+        if ($config->CustomSSL) {
42
+            if ($config->RemoteDomain) {
43
+                return $config->RemoteDomain;
44 44
             }
45 45
         } else {
46 46
             if ($config->StoreName){
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
             }
49 49
         }
50 50
 
51
-		return null;
52
-	}
51
+        return null;
52
+    }
53 53
 
54
-	public static function FormActionURL() {
54
+    public static function FormActionURL() {
55 55
         $config = SiteConfig::current_site_config();
56 56
 
57 57
         if ($config->CustomSSL) {
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         } else {
60 60
             return sprintf('https://%s.foxycart.com/cart', self::getFoxyCartStoreName());
61 61
         }
62
-	}
62
+    }
63 63
 
64 64
     /**
65 65
      * FoxyCart API v1.1 functions
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
         return self::getAPIRequest($foxyData);
126 126
     }
127 127
 
128
-	public static function getKeyPrefix(){
129
-		return self::$keyPrefix;
130
-	}
128
+    public static function getKeyPrefix(){
129
+        return self::$keyPrefix;
130
+    }
131 131
 
132 132
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -9,41 +9,41 @@  discard block
 block discarded – undo
9 9
 
10 10
 	private static $keyPrefix = 'dYnm1c';
11 11
 
12
-	public static function setStoreKey($length = 54, $count = 0){
12
+	public static function setStoreKey($length = 54, $count = 0) {
13 13
 		$charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.strtotime('now');
14 14
 		$strLength = strlen($charset);
15 15
 		$str = '';
16
-		while($count < $length){
17
-			$str .= $charset[mt_rand(0, $strLength-1)];
16
+		while ($count < $length) {
17
+			$str .= $charset[mt_rand(0, $strLength - 1)];
18 18
 			$count++;
19 19
 		}
20
-		return self::getKeyPrefix().substr(base64_encode($str),0,$length);
20
+		return self::getKeyPrefix().substr(base64_encode($str), 0, $length);
21 21
 	}
22 22
 
23
-	public static function getStoreKey(){
23
+	public static function getStoreKey() {
24 24
 		$config = SiteConfig::current_site_config();
25
-		if($config->StoreKey){
25
+		if ($config->StoreKey) {
26 26
 			return $config->StoreKey;
27 27
 		}
28 28
 		return null;
29 29
 	}
30 30
 
31
-	public static function store_name_warning(){
31
+	public static function store_name_warning() {
32 32
 		$warning = null;
33
-		if(self::getFoxyCartStoreName()===null){
33
+		if (self::getFoxyCartStoreName() === null) {
34 34
 			$warning = 'Must define FoxyCart Store Name or Store Remote Domain in your site settings in the cms';
35 35
 		}
36 36
 		return $warning;
37 37
 	}
38 38
 
39
-	public static function getFoxyCartStoreName(){
39
+	public static function getFoxyCartStoreName() {
40 40
 		$config = SiteConfig::current_site_config();
41 41
 		if ($config->CustomSSL) {
42 42
 		    if ($config->RemoteDomain) {
43 43
 		        return $config->RemoteDomain;
44 44
             }
45
-        } else {
46
-            if ($config->StoreName){
45
+        }else {
46
+            if ($config->StoreName) {
47 47
                 return $config->StoreName;
48 48
             }
49 49
         }
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
         $config = SiteConfig::current_site_config();
56 56
 
57 57
         if ($config->CustomSSL) {
58
-            return sprintf('https://%s/cart', self::getFoxyCartStoreName() );
59
-        } else {
58
+            return sprintf('https://%s/cart', self::getFoxyCartStoreName());
59
+        }else {
60 60
             return sprintf('https://%s.foxycart.com/cart', self::getFoxyCartStoreName());
61 61
         }
62 62
 	}
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
         $foxyData["api_token"] = FoxyCart::getStoreKey();
73 73
 
74 74
         $ch = curl_init();
75
-        curl_setopt($ch, CURLOPT_URL, "https://" . $foxy_domain . "/api");
75
+        curl_setopt($ch, CURLOPT_URL, "https://".$foxy_domain."/api");
76 76
         curl_setopt($ch, CURLOPT_POSTFIELDS, $foxyData);
77 77
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
78 78
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
         // The following if block will print any CURL errors you might have
85 85
         if ($response == false) {
86 86
             //trigger_error("Could not connect to FoxyCart API", E_USER_ERROR);
87
-            SS_Log::log("Could not connect to FoxyCart API: " . $response, SS_Log::ERR);
87
+            SS_Log::log("Could not connect to FoxyCart API: ".$response, SS_Log::ERR);
88 88
         }
89 89
         curl_close($ch);
90 90
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 
110 110
     public static function putCustomer($Member = null) {
111 111
         // throw error if no $Member Object
112
-        if (!isset($Member)) ;//trigger_error('No Member set', E_USER_ERROR);
112
+        if (!isset($Member)); //trigger_error('No Member set', E_USER_ERROR);
113 113
 
114 114
         // send updated customer record from API
115 115
         $foxyData = array();
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
         return self::getAPIRequest($foxyData);
126 126
     }
127 127
 
128
-	public static function getKeyPrefix(){
128
+	public static function getKeyPrefix() {
129 129
 		return self::$keyPrefix;
130 130
 	}
131 131
 
Please login to merge, or discard this patch.
code/extensions/FoxyStripeSiteConfig.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -2,23 +2,23 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FoxyStripeSiteConfig extends DataExtension{
4 4
 
5
-	private static $db = array(
6
-		'StoreName' => 'Varchar(255)',
7
-		'StoreKey' => 'Varchar(60)',
8
-		'MultiGroup' => 'Boolean',
9
-		'ProductLimit' => 'Int',
10
-		'CartValidation' => 'Boolean',
11
-		'MaxQuantity' => 'Int',
5
+    private static $db = array(
6
+        'StoreName' => 'Varchar(255)',
7
+        'StoreKey' => 'Varchar(60)',
8
+        'MultiGroup' => 'Boolean',
9
+        'ProductLimit' => 'Int',
10
+        'CartValidation' => 'Boolean',
11
+        'MaxQuantity' => 'Int',
12 12
         'CustomSSL' => 'Boolean',
13 13
         'RemoteDomain' => 'Varchar(255)',
14
-	);
14
+    );
15 15
 
16 16
     // Set Default values
17 17
     private static $defaults = array(
18 18
         'ProductLimit' => 10
19 19
     );
20 20
 
21
-	public function updateCMSFields(FieldList $fields){
21
+    public function updateCMSFields(FieldList $fields){
22 22
 
23 23
         // set TabSet names to avoid spaces from camel case
24 24
         $fields->addFieldToTab('Root', new TabSet('FoxyStripe', 'FoxyStripe'));
@@ -26,108 +26,108 @@  discard block
 block discarded – undo
26 26
         // settings tab
27 27
         $fields->addFieldsToTab('Root.FoxyStripe.Settings', array(
28 28
             // Store Details
29
-			HeaderField::create('StoreDetails', _t('FoxyStripeSiteConfig.StoreDetails', 'Store Settings'), 3),
30
-			LiteralField::create('DetailsIntro', _t(
31
-				'FoxyStripeSiteConfig.DetailsIntro',
29
+            HeaderField::create('StoreDetails', _t('FoxyStripeSiteConfig.StoreDetails', 'Store Settings'), 3),
30
+            LiteralField::create('DetailsIntro', _t(
31
+                'FoxyStripeSiteConfig.DetailsIntro',
32 32
                 '<p>Maps to data in your <a href="https://admin.foxycart.com/admin.php?ThisAction=EditStore" target="_blank">FoxyCart store settings</a>.'
33 33
             )),
34
-			CheckboxField::create('CustomSSL', 'Use custom SSL'),
34
+            CheckboxField::create('CustomSSL', 'Use custom SSL'),
35 35
             TextField::create('RemoteDomain', 'Store remote domain')
36 36
                 ->setDescription('custom subdomain for FoxyCart')
37 37
                 ->displayIf('CustomSSL')->isChecked()->end(),
38
-			TextField::create('StoreName')
39
-				->setTitle(_t('FoxyStripeSiteConfig.StoreName', 'Store Sub Domain'))
40
-				->setDescription(_t('FoxyStripeSiteConfig.StoreNameDescription', 'the sub domain for your FoxyCart store'))
38
+            TextField::create('StoreName')
39
+                ->setTitle(_t('FoxyStripeSiteConfig.StoreName', 'Store Sub Domain'))
40
+                ->setDescription(_t('FoxyStripeSiteConfig.StoreNameDescription', 'the sub domain for your FoxyCart store'))
41 41
                 ->hideIf('CustomSSL')->isChecked()->end(),
42 42
 
43
-			// Advanced Settings
44
-			HeaderField::create('AdvanceHeader', _t('FoxyStripeSiteConfig.AdvancedHeader', 'Advanced Settings'), 3),
45
-			LiteralField::create('AdvancedIntro', _t(
43
+            // Advanced Settings
44
+            HeaderField::create('AdvanceHeader', _t('FoxyStripeSiteConfig.AdvancedHeader', 'Advanced Settings'), 3),
45
+            LiteralField::create('AdvancedIntro', _t(
46 46
                 'FoxyStripeSiteConfig.AdvancedIntro',
47
-				'<p>Maps to data in your <a href="https://admin.foxycart.com/admin.php?ThisAction=EditAdvancedFeatures" target="_blank">FoxyCart advanced store settings</a>.</p>'
48
-			)),
49
-			ReadonlyField::create('DataFeedLink', _t('FoxyStripeSiteConfig.DataFeedLink', 'FoxyCart DataFeed URL'), self::getDataFeedLink())
50
-				->setDescription(_t('FoxyStripeSiteConfig.DataFeedLinkDescription', 'copy/paste to FoxyCart')),
51
-			CheckboxField::create('CartValidation')
52
-				->setTitle(_t('FoxyStripeSiteConfig.CartValidation', 'Enable Cart Validation'))
53
-				->setDescription(_t(
47
+                '<p>Maps to data in your <a href="https://admin.foxycart.com/admin.php?ThisAction=EditAdvancedFeatures" target="_blank">FoxyCart advanced store settings</a>.</p>'
48
+            )),
49
+            ReadonlyField::create('DataFeedLink', _t('FoxyStripeSiteConfig.DataFeedLink', 'FoxyCart DataFeed URL'), self::getDataFeedLink())
50
+                ->setDescription(_t('FoxyStripeSiteConfig.DataFeedLinkDescription', 'copy/paste to FoxyCart')),
51
+            CheckboxField::create('CartValidation')
52
+                ->setTitle(_t('FoxyStripeSiteConfig.CartValidation', 'Enable Cart Validation'))
53
+                ->setDescription(_t(
54 54
                     'FoxyStripeSiteConfig.CartValidationDescription',
55 55
                     'You must <a href="https://admin.foxycart.com/admin.php?ThisAction=EditAdvancedFeatures#use_cart_validation" target="_blank">enable cart validation</a> in the FoxyCart admin.'
56 56
             )),
57
-			ReadonlyField::create('StoreKey')
58
-				->setTitle(_t('FoxyStripeSiteConfig.StoreKey', 'FoxyCart API Key'))
59
-				->setDescription(_t('FoxyStripeSiteConfig.StoreKeyDescription', 'copy/paste to FoxyCart')),
60
-			ReadonlyField::create('SSOLink', _t('FoxyStripeSiteConfig.SSOLink', 'Single Sign On URL'), self::getSSOLink())
61
-				->setDescription(_t('FoxyStripeSiteConfig.SSOLinkDescription', 'copy/paste to FoxyCart'))
57
+            ReadonlyField::create('StoreKey')
58
+                ->setTitle(_t('FoxyStripeSiteConfig.StoreKey', 'FoxyCart API Key'))
59
+                ->setDescription(_t('FoxyStripeSiteConfig.StoreKeyDescription', 'copy/paste to FoxyCart')),
60
+            ReadonlyField::create('SSOLink', _t('FoxyStripeSiteConfig.SSOLink', 'Single Sign On URL'), self::getSSOLink())
61
+                ->setDescription(_t('FoxyStripeSiteConfig.SSOLinkDescription', 'copy/paste to FoxyCart'))
62 62
         ));
63 63
 
64 64
         // configuration warning
65
-		if(FoxyCart::store_name_warning()!==null){
66
-			$fields->insertBefore(LiteralField::create(
65
+        if(FoxyCart::store_name_warning()!==null){
66
+            $fields->insertBefore(LiteralField::create(
67 67
                 "StoreSubDomainHeaderWarning",
68 68
                 _t(
69 69
                     'FoxyStripeSiteConfig.StoreSubDomainHeadingWarning',
70 70
                     "<p class=\"message error\">Store sub-domain must be entered in the <a href=\"/admin/settings/\">site settings</a></p>"
71 71
                 )
72 72
             ), 'StoreDetails');
73
-		}
73
+        }
74 74
 
75 75
         // products tab
76
-		$fields->addFieldsToTab('Root.FoxyStripe.Products', array(
77
-			HeaderField::create('ProductHeader', _t('FoxyStripeSiteConfig.ProductHeader', 'Products'), 3),
78
-			CheckboxField::create('MultiGroup')
79
-				->setTitle(_t('FoxyStripeSiteConfig.MultiGroup', 'Multiple Groups'))
80
-				->setDescription(_t(
76
+        $fields->addFieldsToTab('Root.FoxyStripe.Products', array(
77
+            HeaderField::create('ProductHeader', _t('FoxyStripeSiteConfig.ProductHeader', 'Products'), 3),
78
+            CheckboxField::create('MultiGroup')
79
+                ->setTitle(_t('FoxyStripeSiteConfig.MultiGroup', 'Multiple Groups'))
80
+                ->setDescription(_t(
81 81
                     'FoxyStripeSiteConfig.MultiGroupDescription',
82 82
                     'Allows products to be shown in multiple Product Groups'
83 83
                 )),
84
-			HeaderField::create('ProductGroupHD', _t('FoxyStripeSiteConfig.ProductGroupHD', 'Product Groups'), 3),
85
-			NumericField::create('ProductLimit')
86
-				->setTitle(_t('FoxyStripeSiteConfig.ProductLimit', 'Products per Page'))
87
-				->setDescription(_t(
84
+            HeaderField::create('ProductGroupHD', _t('FoxyStripeSiteConfig.ProductGroupHD', 'Product Groups'), 3),
85
+            NumericField::create('ProductLimit')
86
+                ->setTitle(_t('FoxyStripeSiteConfig.ProductLimit', 'Products per Page'))
87
+                ->setDescription(_t(
88 88
                     'FoxyStripeSiteConfig.ProductLimitDescription',
89 89
                     'Number of Products to show per page on a Product Group'
90 90
                 )),
91
-			HeaderField::create('ProductQuantityHD', _t('FoxyStripeSiteConfig.ProductQuantityHD', 'Product Form Max Quantity'), 3),
92
-			NumericField::create('MaxQuantity')
93
-				->setTitle(_t('FoxyStripeSiteConfig.MaxQuantity', 'Max Quantity'))
94
-				->setDescription(_t(
91
+            HeaderField::create('ProductQuantityHD', _t('FoxyStripeSiteConfig.ProductQuantityHD', 'Product Form Max Quantity'), 3),
92
+            NumericField::create('MaxQuantity')
93
+                ->setTitle(_t('FoxyStripeSiteConfig.MaxQuantity', 'Max Quantity'))
94
+                ->setDescription(_t(
95 95
                     'FoxyStripeSiteConfig.MaxQuantityDescription',
96 96
                     'Sets max quantity for product form dropdown (add to cart form - default 10)'
97 97
                 ))
98
-		));
98
+        ));
99 99
 
100 100
         // categories tab
101
-		$fields->addFieldsToTab('Root.FoxyStripe.Categories', array(
102
-			HeaderField::create('CategoryHD', _t('FoxyStripeSiteConfig.CategoryHD', 'FoxyStripe Categories'), 3),
103
-			LiteralField::create('CategoryDescrip', _t(
101
+        $fields->addFieldsToTab('Root.FoxyStripe.Categories', array(
102
+            HeaderField::create('CategoryHD', _t('FoxyStripeSiteConfig.CategoryHD', 'FoxyStripe Categories'), 3),
103
+            LiteralField::create('CategoryDescrip', _t(
104 104
                 'FoxyStripeSiteConfig.CategoryDescrip',
105 105
                 '<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>'
106 106
             )),
107
-			GridField::create(
107
+            GridField::create(
108 108
                 'ProductCategory',
109 109
                 _t('FoxyStripeSiteConfig.ProductCategory', 'FoxyCart Categories'),
110 110
                 ProductCategory::get(),
111 111
                 GridFieldConfig_RecordEditor::create()
112 112
             )
113
-		));
113
+        ));
114 114
 
115 115
         // option groups tab
116
-		$fields->addFieldsToTab('Root.FoxyStripe.Groups', array(
117
-			HeaderField::create('OptionGroupsHead', _t('FoxyStripeSiteConfig', 'Product Option Groups'), 3),
118
-			LiteralField::create('OptionGroupsDescrip', _t(
116
+        $fields->addFieldsToTab('Root.FoxyStripe.Groups', array(
117
+            HeaderField::create('OptionGroupsHead', _t('FoxyStripeSiteConfig', 'Product Option Groups'), 3),
118
+            LiteralField::create('OptionGroupsDescrip', _t(
119 119
                 'FoxyStripeSiteConfig.OptionGroupsDescrip',
120 120
                 '<p>Product Option Groups allow you to name a set of product options.</p>'
121 121
             )),
122
-			GridField::create(
122
+            GridField::create(
123 123
                 'OptionGroup',
124 124
                 _t('FoxyStripeSiteConfig.OptionGroup', 'Product Option Groups'),
125 125
                 OptionGroup::get(),
126 126
                 GridFieldConfig_RecordEditor::create()
127 127
             )
128
-		));
128
+        ));
129 129
 
130
-	}
130
+    }
131 131
 
132 132
     private static function getSSOLink() {
133 133
         return Director::absoluteBaseURL()."foxystripe/sso/";
Please login to merge, or discard this patch.