@@ -4,30 +4,30 @@ 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 | - 'StoreKey' => 'Varchar(60)', |
|
| 11 | + 'StoreKey' => 'Varchar(60)', |
|
| 12 | 12 | 'ReceiptURL' => 'Varchar(255)', |
| 13 | 13 | 'StoreEmail' => 'Varchar(255)', |
| 14 | 14 | 'FromEmail' => 'Varchar(255)', |
| 15 | - 'MultiGroup' => 'Boolean', |
|
| 16 | - 'ProductLimit' => 'Int', |
|
| 17 | - //'CartValidation' => 'Boolean', |
|
| 18 | - 'MaxQuantity' => 'Int', |
|
| 15 | + 'MultiGroup' => 'Boolean', |
|
| 16 | + 'ProductLimit' => 'Int', |
|
| 17 | + //'CartValidation' => 'Boolean', |
|
| 18 | + 'MaxQuantity' => 'Int', |
|
| 19 | 19 | 'client_id' => 'Varchar(255)', |
| 20 | 20 | 'client_secret' => 'Varchar(255)', |
| 21 | 21 | 'access_token' => 'Varchar(255)', |
| 22 | 22 | 'refresh_token' => 'Varchar(255)', |
| 23 | - ); |
|
| 23 | + ); |
|
| 24 | 24 | |
| 25 | 25 | // Set Default values |
| 26 | 26 | private static $defaults = array( |
| 27 | 27 | 'ProductLimit' => 10 |
| 28 | 28 | ); |
| 29 | 29 | |
| 30 | - public function updateCMSFields(FieldList $fields){ |
|
| 30 | + public function updateCMSFields(FieldList $fields){ |
|
| 31 | 31 | |
| 32 | 32 | // set TabSet names to avoid spaces from camel case |
| 33 | 33 | $fields->addFieldToTab('Root', new TabSet('FoxyStripe', 'FoxyStripe')); |
@@ -35,17 +35,17 @@ discard block |
||
| 35 | 35 | // settings tab |
| 36 | 36 | $fields->addFieldsToTab('Root.FoxyStripe.Settings', array( |
| 37 | 37 | // Store Details |
| 38 | - HeaderField::create('StoreDetails', _t('FoxyStripeSiteConfig.StoreDetails', 'Store Settings'), 3), |
|
| 39 | - LiteralField::create('DetailsIntro', _t( |
|
| 40 | - 'FoxyStripeSiteConfig.DetailsIntro', |
|
| 38 | + HeaderField::create('StoreDetails', _t('FoxyStripeSiteConfig.StoreDetails', 'Store Settings'), 3), |
|
| 39 | + LiteralField::create('DetailsIntro', _t( |
|
| 40 | + 'FoxyStripeSiteConfig.DetailsIntro', |
|
| 41 | 41 | '<p>Maps to data in your <a href="https://admin.foxycart.com/admin.php?ThisAction=EditStore" target="_blank">FoxyCart store settings</a>.' |
| 42 | 42 | )), |
| 43 | 43 | TextField::create('StoreTitle') |
| 44 | 44 | ->setTitle(_t('FoxyStripeSiteConfig.StoreTitle', 'Store Name')) |
| 45 | 45 | ->setDescription(_t('FoxyStripeSiteConfig.StoreTitleDescription', 'The name of your store as you\'d like it displayed to your customers')), |
| 46 | - TextField::create('StoreName') |
|
| 47 | - ->setTitle(_t('FoxyStripeSiteConfig.StoreName', 'Store Domain')) |
|
| 48 | - ->setDescription(_t('FoxyStripeSiteConfig.StoreNameDescription', 'This is a unique FoxyCart subdomain for your cart, checkout, and receipt')), |
|
| 46 | + TextField::create('StoreName') |
|
| 47 | + ->setTitle(_t('FoxyStripeSiteConfig.StoreName', 'Store Domain')) |
|
| 48 | + ->setDescription(_t('FoxyStripeSiteConfig.StoreNameDescription', 'This is a unique FoxyCart subdomain for your cart, checkout, and receipt')), |
|
| 49 | 49 | TextField::create('StoreURL') |
| 50 | 50 | ->setTitle(_t('FoxyStripeSiteConfig.StoreURL', 'Store URL')) |
| 51 | 51 | ->setDescription(_t('FoxyStripeSiteConfig.StoreURLDescription', 'The URL of your online store')), |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | ->setTitle(_t('FoxyStripeSiteConfig.FromEmail', 'From Email')) |
| 60 | 60 | ->setDescription(_t('FoxyStripeSiteConfig.FromEmailDescription', 'Used for when you want to specify a different from email than your store\'s email address')), |
| 61 | 61 | |
| 62 | - // Advanced Settings |
|
| 62 | + // Advanced Settings |
|
| 63 | 63 | /* |
| 64 | 64 | HeaderField::create('AdvanceHeader', _t('FoxyStripeSiteConfig.AdvancedHeader', 'Advanced Settings'), 3), |
| 65 | 65 | LiteralField::create('AdvancedIntro', _t( |
@@ -83,72 +83,72 @@ discard block |
||
| 83 | 83 | )); |
| 84 | 84 | |
| 85 | 85 | // configuration warning |
| 86 | - if(FoxyCart::store_name_warning()!==null){ |
|
| 87 | - $fields->insertBefore(LiteralField::create( |
|
| 86 | + if(FoxyCart::store_name_warning()!==null){ |
|
| 87 | + $fields->insertBefore(LiteralField::create( |
|
| 88 | 88 | "StoreSubDomainHeaderWarning", |
| 89 | 89 | _t( |
| 90 | 90 | 'FoxyStripeSiteConfig.StoreSubDomainHeadingWarning', |
| 91 | 91 | "<p class=\"message error\">Store sub-domain must be entered in the <a href=\"/admin/settings/\">site settings</a></p>" |
| 92 | 92 | ) |
| 93 | 93 | ), 'StoreDetails'); |
| 94 | - } |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | 96 | // products tab |
| 97 | - $fields->addFieldsToTab('Root.FoxyStripe.Products', array( |
|
| 98 | - HeaderField::create('ProductHeader', _t('FoxyStripeSiteConfig.ProductHeader', 'Products'), 3), |
|
| 99 | - CheckboxField::create('MultiGroup') |
|
| 100 | - ->setTitle(_t('FoxyStripeSiteConfig.MultiGroup', 'Multiple Groups')) |
|
| 101 | - ->setDescription(_t( |
|
| 97 | + $fields->addFieldsToTab('Root.FoxyStripe.Products', array( |
|
| 98 | + HeaderField::create('ProductHeader', _t('FoxyStripeSiteConfig.ProductHeader', 'Products'), 3), |
|
| 99 | + CheckboxField::create('MultiGroup') |
|
| 100 | + ->setTitle(_t('FoxyStripeSiteConfig.MultiGroup', 'Multiple Groups')) |
|
| 101 | + ->setDescription(_t( |
|
| 102 | 102 | 'FoxyStripeSiteConfig.MultiGroupDescription', |
| 103 | 103 | 'Allows products to be shown in multiple Product Groups' |
| 104 | 104 | )), |
| 105 | - HeaderField::create('ProductGroupHD', _t('FoxyStripeSiteConfig.ProductGroupHD', 'Product Groups'), 3), |
|
| 106 | - NumericField::create('ProductLimit') |
|
| 107 | - ->setTitle(_t('FoxyStripeSiteConfig.ProductLimit', 'Products per Page')) |
|
| 108 | - ->setDescription(_t( |
|
| 105 | + HeaderField::create('ProductGroupHD', _t('FoxyStripeSiteConfig.ProductGroupHD', 'Product Groups'), 3), |
|
| 106 | + NumericField::create('ProductLimit') |
|
| 107 | + ->setTitle(_t('FoxyStripeSiteConfig.ProductLimit', 'Products per Page')) |
|
| 108 | + ->setDescription(_t( |
|
| 109 | 109 | 'FoxyStripeSiteConfig.ProductLimitDescription', |
| 110 | 110 | 'Number of Products to show per page on a Product Group' |
| 111 | 111 | )), |
| 112 | - HeaderField::create('ProductQuantityHD', _t('FoxyStripeSiteConfig.ProductQuantityHD', 'Product Form Max Quantity'), 3), |
|
| 113 | - NumericField::create('MaxQuantity') |
|
| 114 | - ->setTitle(_t('FoxyStripeSiteConfig.MaxQuantity', 'Max Quantity')) |
|
| 115 | - ->setDescription(_t( |
|
| 112 | + HeaderField::create('ProductQuantityHD', _t('FoxyStripeSiteConfig.ProductQuantityHD', 'Product Form Max Quantity'), 3), |
|
| 113 | + NumericField::create('MaxQuantity') |
|
| 114 | + ->setTitle(_t('FoxyStripeSiteConfig.MaxQuantity', 'Max Quantity')) |
|
| 115 | + ->setDescription(_t( |
|
| 116 | 116 | 'FoxyStripeSiteConfig.MaxQuantityDescription', |
| 117 | 117 | 'Sets max quantity for product form dropdown (add to cart form - default 10)' |
| 118 | 118 | )) |
| 119 | - )); |
|
| 119 | + )); |
|
| 120 | 120 | |
| 121 | 121 | // categories tab |
| 122 | - $fields->addFieldsToTab('Root.FoxyStripe.Categories', array( |
|
| 123 | - HeaderField::create('CategoryHD', _t('FoxyStripeSiteConfig.CategoryHD', 'FoxyStripe Categories'), 3), |
|
| 124 | - LiteralField::create('CategoryDescrip', _t( |
|
| 122 | + $fields->addFieldsToTab('Root.FoxyStripe.Categories', array( |
|
| 123 | + HeaderField::create('CategoryHD', _t('FoxyStripeSiteConfig.CategoryHD', 'FoxyStripe Categories'), 3), |
|
| 124 | + LiteralField::create('CategoryDescrip', _t( |
|
| 125 | 125 | 'FoxyStripeSiteConfig.CategoryDescrip', |
| 126 | 126 | '<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>' |
| 127 | 127 | )), |
| 128 | - GridField::create( |
|
| 128 | + GridField::create( |
|
| 129 | 129 | 'ProductCategory', |
| 130 | 130 | _t('FoxyStripeSiteConfig.ProductCategory', 'FoxyCart Categories'), |
| 131 | 131 | ProductCategory::get(), |
| 132 | 132 | GridFieldConfig_RecordEditor::create() |
| 133 | 133 | ) |
| 134 | - )); |
|
| 134 | + )); |
|
| 135 | 135 | |
| 136 | 136 | // option groups tab |
| 137 | - $fields->addFieldsToTab('Root.FoxyStripe.Groups', array( |
|
| 138 | - HeaderField::create('OptionGroupsHead', _t('FoxyStripeSiteConfig', 'Product Option Groups'), 3), |
|
| 139 | - LiteralField::create('OptionGroupsDescrip', _t( |
|
| 137 | + $fields->addFieldsToTab('Root.FoxyStripe.Groups', array( |
|
| 138 | + HeaderField::create('OptionGroupsHead', _t('FoxyStripeSiteConfig', 'Product Option Groups'), 3), |
|
| 139 | + LiteralField::create('OptionGroupsDescrip', _t( |
|
| 140 | 140 | 'FoxyStripeSiteConfig.OptionGroupsDescrip', |
| 141 | 141 | '<p>Product Option Groups allow you to name a set of product options.</p>' |
| 142 | 142 | )), |
| 143 | - GridField::create( |
|
| 143 | + GridField::create( |
|
| 144 | 144 | 'OptionGroup', |
| 145 | 145 | _t('FoxyStripeSiteConfig.OptionGroup', 'Product Option Groups'), |
| 146 | 146 | OptionGroup::get(), |
| 147 | 147 | GridFieldConfig_RecordEditor::create() |
| 148 | 148 | ) |
| 149 | - )); |
|
| 149 | + )); |
|
| 150 | 150 | |
| 151 | - // api tab |
|
| 151 | + // api tab |
|
| 152 | 152 | $fields->addFieldsToTab('Root.FoxyStripe.API', [ |
| 153 | 153 | HeaderField::create('APIHD', 'FoxyCart API Settings', 3), |
| 154 | 154 | TextField::create('client_id', 'FoxyCart Client ID'), |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | TextField::create('refresh_token', 'FoxyCart Refresh Token'), |
| 158 | 158 | ]); |
| 159 | 159 | |
| 160 | - } |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | 162 | private static function getSSOLink() { |
| 163 | 163 | return Director::absoluteBaseURL()."foxystripe/sso/"; |
@@ -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)', |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | 'ProductLimit' => 10 |
| 28 | 28 | ); |
| 29 | 29 | |
| 30 | - public function updateCMSFields(FieldList $fields){ |
|
| 30 | + public function updateCMSFields(FieldList $fields) { |
|
| 31 | 31 | |
| 32 | 32 | // set TabSet names to avoid spaces from camel case |
| 33 | 33 | $fields->addFieldToTab('Root', new TabSet('FoxyStripe', 'FoxyStripe')); |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | )); |
| 84 | 84 | |
| 85 | 85 | // configuration warning |
| 86 | - if(FoxyCart::store_name_warning()!==null){ |
|
| 86 | + if (FoxyCart::store_name_warning() !== null) { |
|
| 87 | 87 | $fields->insertBefore(LiteralField::create( |
| 88 | 88 | "StoreSubDomainHeaderWarning", |
| 89 | 89 | _t( |
@@ -174,14 +174,14 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | $siteConfig = SiteConfig::current_site_config(); |
| 176 | 176 | |
| 177 | - if(!$siteConfig->StoreKey) { |
|
| 177 | + if (!$siteConfig->StoreKey) { |
|
| 178 | 178 | $key = FoxyCart::setStoreKey(); |
| 179 | - while(!ctype_alnum($key)){ |
|
| 179 | + while (!ctype_alnum($key)) { |
|
| 180 | 180 | $key = FoxyCart::setStoreKey(); |
| 181 | 181 | } |
| 182 | 182 | $siteConfig->StoreKey = $key; |
| 183 | 183 | $siteConfig->write(); |
| 184 | - DB::alteration_message($siteConfig->ClassName.": created FoxyCart Store Key " . $key, 'created'); |
|
| 184 | + DB::alteration_message($siteConfig->ClassName.": created FoxyCart Store Key ".$key, 'created'); |
|
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | |
| 228 | 228 | $errors = array_merge($errors, $client->getErrors($result)); |
| 229 | 229 | if (count($errors)) { |
| 230 | - \SS_Log::log('FoxyStripeSiteConfig::onBeforeWrite errors - ' . json_encode($errors), \SS_Log::WARN); |
|
| 230 | + \SS_Log::log('FoxyStripeSiteConfig::onBeforeWrite errors - '.json_encode($errors), \SS_Log::WARN); |
|
| 231 | 231 | } |
| 232 | 232 | } |
| 233 | 233 | } |
@@ -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 | } |