@@ -10,39 +10,39 @@ |
||
| 10 | 10 | /** |
| 11 | 11 | * @var bool |
| 12 | 12 | */ |
| 13 | - protected static $use_draft_site = true; |
|
| 13 | + protected static $use_draft_site = true; |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * @throws \SilverStripe\ORM\ValidationException |
| 17 | 17 | */ |
| 18 | - function setUp(){ |
|
| 19 | - parent::setUp(); |
|
| 18 | + function setUp(){ |
|
| 19 | + parent::setUp(); |
|
| 20 | 20 | |
| 21 | - $siteConf = SiteConfig::current_site_config(); |
|
| 22 | - $siteConf->StoreName = 'foxystripe'; |
|
| 21 | + $siteConf = SiteConfig::current_site_config(); |
|
| 22 | + $siteConf->StoreName = 'foxystripe'; |
|
| 23 | 23 | $siteConf->requireDefaultRecords(); |
| 24 | - $siteConf->write(); |
|
| 25 | - } |
|
| 24 | + $siteConf->write(); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * |
| 29 | 29 | */ |
| 30 | - function testStoreKey(){ |
|
| 31 | - $pref = FoxyCart::getKeyPrefix(); |
|
| 32 | - $siteConf = SiteConfig::current_site_config(); |
|
| 30 | + function testStoreKey(){ |
|
| 31 | + $pref = FoxyCart::getKeyPrefix(); |
|
| 32 | + $siteConf = SiteConfig::current_site_config(); |
|
| 33 | 33 | |
| 34 | - $this->assertTrue(ctype_alnum($siteConf->StoreKey)); |
|
| 34 | + $this->assertTrue(ctype_alnum($siteConf->StoreKey)); |
|
| 35 | 35 | $this->assertEquals(strlen($siteConf->StoreKey), 60); |
| 36 | 36 | $this->assertEquals(substr($siteConf->StoreKey, 0, 6), $pref); |
| 37 | - } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * |
| 41 | 41 | */ |
| 42 | - function testStoreName(){ |
|
| 43 | - $siteConf = SiteConfig::current_site_config(); |
|
| 42 | + function testStoreName(){ |
|
| 43 | + $siteConf = SiteConfig::current_site_config(); |
|
| 44 | 44 | |
| 45 | 45 | $this->assertEquals($siteConf->StoreName, 'foxystripe'); |
| 46 | - } |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | 48 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * @throws \SilverStripe\ORM\ValidationException |
| 17 | 17 | */ |
| 18 | - function setUp(){ |
|
| 18 | + function setUp() { |
|
| 19 | 19 | parent::setUp(); |
| 20 | 20 | |
| 21 | 21 | $siteConf = SiteConfig::current_site_config(); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | /** |
| 28 | 28 | * |
| 29 | 29 | */ |
| 30 | - function testStoreKey(){ |
|
| 30 | + function testStoreKey() { |
|
| 31 | 31 | $pref = FoxyCart::getKeyPrefix(); |
| 32 | 32 | $siteConf = SiteConfig::current_site_config(); |
| 33 | 33 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | /** |
| 40 | 40 | * |
| 41 | 41 | */ |
| 42 | - function testStoreName(){ |
|
| 42 | + function testStoreName() { |
|
| 43 | 43 | $siteConf = SiteConfig::current_site_config(); |
| 44 | 44 | |
| 45 | 45 | $this->assertEquals($siteConf->StoreName, 'foxystripe'); |
@@ -32,11 +32,11 @@ |
||
| 32 | 32 | { |
| 33 | 33 | $object = $this->objFromFixture(OptionGroup::class, 'size'); |
| 34 | 34 | $orig = $object->Title; |
| 35 | - $object->Title = '2' . $orig; |
|
| 35 | + $object->Title = '2'.$orig; |
|
| 36 | 36 | $this->expectException(ValidationException::class); |
| 37 | 37 | $object->write(); |
| 38 | 38 | |
| 39 | - $object->Title = $orig . '&'; |
|
| 39 | + $object->Title = $orig.'&'; |
|
| 40 | 40 | $this->expectException(ValidationException::class); |
| 41 | 41 | $object->write(); |
| 42 | 42 | } |
@@ -13,251 +13,251 @@ |
||
| 13 | 13 | class ProductPageTest extends FS_Test |
| 14 | 14 | { |
| 15 | 15 | |
| 16 | - protected static $use_draft_site = true; |
|
| 16 | + protected static $use_draft_site = true; |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * @throws \SilverStripe\ORM\ValidationException |
| 20 | 20 | */ |
| 21 | - function setUp(){ |
|
| 22 | - parent::setUp(); |
|
| 21 | + function setUp(){ |
|
| 22 | + parent::setUp(); |
|
| 23 | 23 | |
| 24 | - $groupForItem = OptionGroup::create(); |
|
| 25 | - $groupForItem->Title = 'Sample-Group'; |
|
| 26 | - $groupForItem->write(); |
|
| 24 | + $groupForItem = OptionGroup::create(); |
|
| 25 | + $groupForItem->Title = 'Sample-Group'; |
|
| 26 | + $groupForItem->write(); |
|
| 27 | 27 | |
| 28 | - /*$productHolder = ProductHolder::create(); |
|
| 28 | + /*$productHolder = ProductHolder::create(); |
|
| 29 | 29 | $productHolder->Title = 'Product Holder'; |
| 30 | 30 | $productHolder->write();*/ |
| 31 | - } |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - function testProductCreation(){ |
|
| 33 | + function testProductCreation(){ |
|
| 34 | 34 | |
| 35 | - $this->logInWithPermission('Product_CANCRUD'); |
|
| 36 | - $default = $this->objFromFixture(ProductCategory::class, 'default'); |
|
| 37 | - $holder = $this->objFromFixture(ProductHolder::class, 'default'); |
|
| 38 | - $product1 = $this->objFromFixture(ProductPage::class, 'product1'); |
|
| 35 | + $this->logInWithPermission('Product_CANCRUD'); |
|
| 36 | + $default = $this->objFromFixture(ProductCategory::class, 'default'); |
|
| 37 | + $holder = $this->objFromFixture(ProductHolder::class, 'default'); |
|
| 38 | + $product1 = $this->objFromFixture(ProductPage::class, 'product1'); |
|
| 39 | 39 | |
| 40 | - $product1->doPublish(); |
|
| 41 | - $this->assertTrue($product1->isPublished()); |
|
| 40 | + $product1->doPublish(); |
|
| 41 | + $this->assertTrue($product1->isPublished()); |
|
| 42 | 42 | |
| 43 | - } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - function testProductDeletion(){ |
|
| 45 | + function testProductDeletion(){ |
|
| 46 | 46 | |
| 47 | - $this->logInWithPermission('Product_CANCRUD'); |
|
| 48 | - $holder = $this->objFromFixture(ProductHolder::class, 'default'); |
|
| 49 | - $holder->write(); |
|
| 50 | - $product2 = $this->objFromFixture(ProductPage::class, 'product2'); |
|
| 51 | - $productID = $product2->ID; |
|
| 47 | + $this->logInWithPermission('Product_CANCRUD'); |
|
| 48 | + $holder = $this->objFromFixture(ProductHolder::class, 'default'); |
|
| 49 | + $holder->write(); |
|
| 50 | + $product2 = $this->objFromFixture(ProductPage::class, 'product2'); |
|
| 51 | + $productID = $product2->ID; |
|
| 52 | 52 | |
| 53 | - $product2->write(); |
|
| 54 | - $this->assertTrue($product2->exists()); |
|
| 53 | + $product2->write(); |
|
| 54 | + $this->assertTrue($product2->exists()); |
|
| 55 | 55 | |
| 56 | - $versions = DB::query('Select * FROM "FS_ProductPage_versions" WHERE "RecordID" = '. $productID); |
|
| 57 | - $versionsPostPublish = array(); |
|
| 58 | - foreach($versions as $versionRow) $versionsPostPublish[] = $versionRow; |
|
| 56 | + $versions = DB::query('Select * FROM "FS_ProductPage_versions" WHERE "RecordID" = '. $productID); |
|
| 57 | + $versionsPostPublish = array(); |
|
| 58 | + foreach($versions as $versionRow) $versionsPostPublish[] = $versionRow; |
|
| 59 | 59 | |
| 60 | - $product2->delete(); |
|
| 61 | - $this->assertTrue(!$product2->exists()); |
|
| 60 | + $product2->delete(); |
|
| 61 | + $this->assertTrue(!$product2->exists()); |
|
| 62 | 62 | |
| 63 | - $versions = DB::query('Select * FROM "FS_ProductPage_versions" WHERE "RecordID" = '. $productID); |
|
| 64 | - $versionsPostDelete = array(); |
|
| 65 | - foreach($versions as $versionRow) $versionsPostDelete[] = $versionRow; |
|
| 63 | + $versions = DB::query('Select * FROM "FS_ProductPage_versions" WHERE "RecordID" = '. $productID); |
|
| 64 | + $versionsPostDelete = array(); |
|
| 65 | + foreach($versions as $versionRow) $versionsPostDelete[] = $versionRow; |
|
| 66 | 66 | |
| 67 | - $this->assertTrue($versionsPostPublish == $versionsPostDelete); |
|
| 67 | + $this->assertTrue($versionsPostPublish == $versionsPostDelete); |
|
| 68 | 68 | |
| 69 | - } |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | 72 | * @throws \SilverStripe\ORM\ValidationException |
| 73 | 73 | */ |
| 74 | - function testProductTitleLeadingWhiteSpace(){ |
|
| 74 | + function testProductTitleLeadingWhiteSpace(){ |
|
| 75 | 75 | |
| 76 | - $this->logInWithPermission('ADMIN'); |
|
| 76 | + $this->logInWithPermission('ADMIN'); |
|
| 77 | 77 | |
| 78 | - $holder = $this->objFromFixture(ProductHolder::class, 'default'); |
|
| 79 | - $holder->write(); |
|
| 78 | + $holder = $this->objFromFixture(ProductHolder::class, 'default'); |
|
| 79 | + $holder->write(); |
|
| 80 | 80 | |
| 81 | - $product = $this->objFromFixture(ProductPage::class, 'product1'); |
|
| 82 | - $product->Title = " Test with leading space"; |
|
| 83 | - $product->write(); |
|
| 81 | + $product = $this->objFromFixture(ProductPage::class, 'product1'); |
|
| 82 | + $product->Title = " Test with leading space"; |
|
| 83 | + $product->write(); |
|
| 84 | 84 | |
| 85 | - $this->assertTrue($product->Title == 'Test with leading space'); |
|
| 85 | + $this->assertTrue($product->Title == 'Test with leading space'); |
|
| 86 | 86 | |
| 87 | - } |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | 90 | * @throws \SilverStripe\ORM\ValidationException |
| 91 | 91 | */ |
| 92 | - function testProductTitleTrailingWhiteSpace(){ |
|
| 92 | + function testProductTitleTrailingWhiteSpace(){ |
|
| 93 | 93 | |
| 94 | - $this->logInWithPermission('ADMIN'); |
|
| 94 | + $this->logInWithPermission('ADMIN'); |
|
| 95 | 95 | |
| 96 | - $holder = $this->objFromFixture(ProductHolder::class, 'default'); |
|
| 97 | - $holder->write(); |
|
| 96 | + $holder = $this->objFromFixture(ProductHolder::class, 'default'); |
|
| 97 | + $holder->write(); |
|
| 98 | 98 | |
| 99 | - $product = $this->objFromFixture(ProductPage::class, 'product1'); |
|
| 100 | - $product->Title = "Test with trailing space "; |
|
| 101 | - $product->write(); |
|
| 99 | + $product = $this->objFromFixture(ProductPage::class, 'product1'); |
|
| 100 | + $product->Title = "Test with trailing space "; |
|
| 101 | + $product->write(); |
|
| 102 | 102 | |
| 103 | - $this->assertTrue($product->Title == 'Test with trailing space'); |
|
| 103 | + $this->assertTrue($product->Title == 'Test with trailing space'); |
|
| 104 | 104 | |
| 105 | - } |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - function testProductCategoryCreation(){ |
|
| 107 | + function testProductCategoryCreation(){ |
|
| 108 | 108 | |
| 109 | - $this->logInWithPermission('Product_CANCRUD'); |
|
| 110 | - $category = $this->objFromFixture(ProductCategory::class, 'apparel'); |
|
| 111 | - $category->write(); |
|
| 112 | - $categoryID = $category->ID; |
|
| 109 | + $this->logInWithPermission('Product_CANCRUD'); |
|
| 110 | + $category = $this->objFromFixture(ProductCategory::class, 'apparel'); |
|
| 111 | + $category->write(); |
|
| 112 | + $categoryID = $category->ID; |
|
| 113 | 113 | |
| 114 | - $productCategory = ProductCategory::get()->filter(array('Code'=>'APPAREL'))->first(); |
|
| 114 | + $productCategory = ProductCategory::get()->filter(array('Code'=>'APPAREL'))->first(); |
|
| 115 | 115 | |
| 116 | - $this->assertTrue($categoryID == $productCategory->ID); |
|
| 116 | + $this->assertTrue($categoryID == $productCategory->ID); |
|
| 117 | 117 | |
| 118 | - } |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - function testProductCategoryDeletion(){ |
|
| 120 | + function testProductCategoryDeletion(){ |
|
| 121 | 121 | |
| 122 | - $this->logInWithPermission('Product_CANCRUD'); |
|
| 122 | + $this->logInWithPermission('Product_CANCRUD'); |
|
| 123 | 123 | |
| 124 | - $category = $this->objFromFixture(ProductCategory::class, 'default'); |
|
| 125 | - $category->write(); |
|
| 124 | + $category = $this->objFromFixture(ProductCategory::class, 'default'); |
|
| 125 | + $category->write(); |
|
| 126 | 126 | |
| 127 | - $this->assertFalse($category->canDelete()); |
|
| 127 | + $this->assertFalse($category->canDelete()); |
|
| 128 | 128 | |
| 129 | - $category2 = $this->objFromFixture(ProductCategory::class, 'apparel'); |
|
| 130 | - $category2->write(); |
|
| 131 | - $category2ID = $category2->ID; |
|
| 129 | + $category2 = $this->objFromFixture(ProductCategory::class, 'apparel'); |
|
| 130 | + $category2->write(); |
|
| 131 | + $category2ID = $category2->ID; |
|
| 132 | 132 | |
| 133 | - $this->assertTrue($category2->canDelete()); |
|
| 133 | + $this->assertTrue($category2->canDelete()); |
|
| 134 | 134 | |
| 135 | - $this->logOut(); |
|
| 135 | + $this->logOut(); |
|
| 136 | 136 | |
| 137 | - $this->logInWithPermission('ADMIN'); |
|
| 137 | + $this->logInWithPermission('ADMIN'); |
|
| 138 | 138 | |
| 139 | - $this->assertFalse($category->canDelete()); |
|
| 140 | - $this->assertTrue($category2->canDelete()); |
|
| 139 | + $this->assertFalse($category->canDelete()); |
|
| 140 | + $this->assertTrue($category2->canDelete()); |
|
| 141 | 141 | |
| 142 | - $this->logOut(); |
|
| 143 | - $this->logInWithPermission('Product_CANCRUD'); |
|
| 142 | + $this->logOut(); |
|
| 143 | + $this->logInWithPermission('Product_CANCRUD'); |
|
| 144 | 144 | |
| 145 | - $category2->delete(); |
|
| 145 | + $category2->delete(); |
|
| 146 | 146 | |
| 147 | - $this->assertFalse(in_array($category2ID,ProductCategory::get()->column('ID'))); |
|
| 147 | + $this->assertFalse(in_array($category2ID,ProductCategory::get()->column('ID'))); |
|
| 148 | 148 | |
| 149 | - } |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - function testOptionGroupCreation(){ |
|
| 151 | + function testOptionGroupCreation(){ |
|
| 152 | 152 | |
| 153 | - $this->logInWithPermission('Product_CANCRUD'); |
|
| 153 | + $this->logInWithPermission('Product_CANCRUD'); |
|
| 154 | 154 | |
| 155 | - $group = $this->objFromFixture(OptionGroup::class, 'size'); |
|
| 156 | - $group->write(); |
|
| 155 | + $group = $this->objFromFixture(OptionGroup::class, 'size'); |
|
| 156 | + $group->write(); |
|
| 157 | 157 | |
| 158 | - $this->assertNotNull(OptionGroup::get()->first()); |
|
| 158 | + $this->assertNotNull(OptionGroup::get()->first()); |
|
| 159 | 159 | |
| 160 | - } |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - function testOptionGroupDeletion(){ |
|
| 162 | + function testOptionGroupDeletion(){ |
|
| 163 | 163 | |
| 164 | - $this->logInWithPermission('ADMIN'); |
|
| 165 | - $group = $this->objFromFixture(OptionGroup::class, 'color'); |
|
| 166 | - $group->write(); |
|
| 167 | - $groupID = $group->ID; |
|
| 164 | + $this->logInWithPermission('ADMIN'); |
|
| 165 | + $group = $this->objFromFixture(OptionGroup::class, 'color'); |
|
| 166 | + $group->write(); |
|
| 167 | + $groupID = $group->ID; |
|
| 168 | 168 | |
| 169 | - $this->assertTrue($group->canDelete()); |
|
| 169 | + $this->assertTrue($group->canDelete()); |
|
| 170 | 170 | |
| 171 | - $this->logOut(); |
|
| 172 | - $this->logInWithPermission('Product_CANCRUD'); |
|
| 171 | + $this->logOut(); |
|
| 172 | + $this->logInWithPermission('Product_CANCRUD'); |
|
| 173 | 173 | |
| 174 | - $this->assertTrue($group->canDelete()); |
|
| 175 | - $group->delete(); |
|
| 174 | + $this->assertTrue($group->canDelete()); |
|
| 175 | + $group->delete(); |
|
| 176 | 176 | |
| 177 | - $this->assertFalse(in_array($groupID, OptionGroup::get()->column('ID'))); |
|
| 177 | + $this->assertFalse(in_array($groupID, OptionGroup::get()->column('ID'))); |
|
| 178 | 178 | |
| 179 | - } |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | - function testOptionItemCreation(){ |
|
| 181 | + function testOptionItemCreation(){ |
|
| 182 | 182 | |
| 183 | - $this->logInWithPermission('Product_CANCRUD'); |
|
| 183 | + $this->logInWithPermission('Product_CANCRUD'); |
|
| 184 | 184 | |
| 185 | - $optionGroup = OptionGroup::get()->filter(array('Title' => 'Sample-Group'))->first(); |
|
| 185 | + $optionGroup = OptionGroup::get()->filter(array('Title' => 'Sample-Group'))->first(); |
|
| 186 | 186 | |
| 187 | - $option = $this->objFromFixture(OptionItem::class, 'large'); |
|
| 188 | - $option->ProductOptionGroupID = $optionGroup->ID; |
|
| 189 | - $option->write(); |
|
| 187 | + $option = $this->objFromFixture(OptionItem::class, 'large'); |
|
| 188 | + $option->ProductOptionGroupID = $optionGroup->ID; |
|
| 189 | + $option->write(); |
|
| 190 | 190 | |
| 191 | - $optionID = $option->ID; |
|
| 191 | + $optionID = $option->ID; |
|
| 192 | 192 | |
| 193 | - $optionItem = OptionItem::get()->filter(array('ProductOptionGroupID' => $optionGroup->ID))->first(); |
|
| 193 | + $optionItem = OptionItem::get()->filter(array('ProductOptionGroupID' => $optionGroup->ID))->first(); |
|
| 194 | 194 | |
| 195 | - $this->assertEquals($optionID, $optionItem->ID); |
|
| 195 | + $this->assertEquals($optionID, $optionItem->ID); |
|
| 196 | 196 | |
| 197 | - } |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - function testOptionItemDeletion(){ |
|
| 199 | + function testOptionItemDeletion(){ |
|
| 200 | 200 | |
| 201 | - $this->logInWithPermission('ADMIN'); |
|
| 201 | + $this->logInWithPermission('ADMIN'); |
|
| 202 | 202 | |
| 203 | - $optionGroup = $this->objFromFixture(OptionGroup::class, 'size'); |
|
| 204 | - $optionGroup->write(); |
|
| 203 | + $optionGroup = $this->objFromFixture(OptionGroup::class, 'size'); |
|
| 204 | + $optionGroup->write(); |
|
| 205 | 205 | |
| 206 | - $option = $this->objFromFixture(OptionItem::class, 'small'); |
|
| 207 | - $option->write(); |
|
| 206 | + $option = $this->objFromFixture(OptionItem::class, 'small'); |
|
| 207 | + $option->write(); |
|
| 208 | 208 | |
| 209 | - $optionID = $option->ID; |
|
| 209 | + $optionID = $option->ID; |
|
| 210 | 210 | |
| 211 | - $this->assertTrue($option->canDelete()); |
|
| 211 | + $this->assertTrue($option->canDelete()); |
|
| 212 | 212 | |
| 213 | - $this->logOut(); |
|
| 214 | - $this->logInWithPermission('Product_CANCRUD'); |
|
| 213 | + $this->logOut(); |
|
| 214 | + $this->logInWithPermission('Product_CANCRUD'); |
|
| 215 | 215 | |
| 216 | - $this->assertTrue($option->canDelete()); |
|
| 217 | - $option->delete(); |
|
| 216 | + $this->assertTrue($option->canDelete()); |
|
| 217 | + $option->delete(); |
|
| 218 | 218 | |
| 219 | - $this->assertFalse(in_array($optionID, OptionItem::get()->column('ID'))); |
|
| 219 | + $this->assertFalse(in_array($optionID, OptionItem::get()->column('ID'))); |
|
| 220 | 220 | |
| 221 | - } |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | - public function testProductDraftOptionDeletion(){ |
|
| 223 | + public function testProductDraftOptionDeletion(){ |
|
| 224 | 224 | |
| 225 | - self::$use_draft_site = false;//make sure we can publish |
|
| 225 | + self::$use_draft_site = false;//make sure we can publish |
|
| 226 | 226 | |
| 227 | - $this->logInWithPermission('ADMIN'); |
|
| 227 | + $this->logInWithPermission('ADMIN'); |
|
| 228 | 228 | |
| 229 | - $holder = $this->objFromFixture(ProductHolder::class, 'default');//build holder page, ProductPage can't be on root level |
|
| 230 | - $holder->doPublish(); |
|
| 229 | + $holder = $this->objFromFixture(ProductHolder::class, 'default');//build holder page, ProductPage can't be on root level |
|
| 230 | + $holder->doPublish(); |
|
| 231 | 231 | |
| 232 | - $product = $this->objFromFixture(ProductPage::class, 'product1');//build product page |
|
| 233 | - $product->doPublish(); |
|
| 232 | + $product = $this->objFromFixture(ProductPage::class, 'product1');//build product page |
|
| 233 | + $product->doPublish(); |
|
| 234 | 234 | |
| 235 | - $productID = $product->ID; |
|
| 235 | + $productID = $product->ID; |
|
| 236 | 236 | |
| 237 | 237 | |
| 238 | - $optionGroup = $this->objFromFixture(OptionGroup::class, 'size');//build the group for the options |
|
| 239 | - $optionGroup->write(); |
|
| 240 | - $option = $this->objFromFixture(OptionItem::class, 'small');//build first option |
|
| 241 | - $option->write(); |
|
| 242 | - $option2 = $this->objFromFixture(OptionItem::class, 'large');//build second option |
|
| 243 | - $option2->write(); |
|
| 238 | + $optionGroup = $this->objFromFixture(OptionGroup::class, 'size');//build the group for the options |
|
| 239 | + $optionGroup->write(); |
|
| 240 | + $option = $this->objFromFixture(OptionItem::class, 'small');//build first option |
|
| 241 | + $option->write(); |
|
| 242 | + $option2 = $this->objFromFixture(OptionItem::class, 'large');//build second option |
|
| 243 | + $option2->write(); |
|
| 244 | 244 | |
| 245 | - $this->assertTrue($product->isPublished());//check that product is published |
|
| 245 | + $this->assertTrue($product->isPublished());//check that product is published |
|
| 246 | 246 | |
| 247 | - $product->deleteFromStage('Stage');//remove product from draft site |
|
| 247 | + $product->deleteFromStage('Stage');//remove product from draft site |
|
| 248 | 248 | |
| 249 | - $this->assertTrue($product->isPublished());//check product is still published |
|
| 249 | + $this->assertTrue($product->isPublished());//check product is still published |
|
| 250 | 250 | |
| 251 | - $testOption = $this->objFromFixture(OptionItem::class, 'large'); |
|
| 251 | + $testOption = $this->objFromFixture(OptionItem::class, 'large'); |
|
| 252 | 252 | |
| 253 | - $this->assertThat($testOption->ID, $this->logicalNot($this->equalTo(0)));//make sure the first option still exists |
|
| 253 | + $this->assertThat($testOption->ID, $this->logicalNot($this->equalTo(0)));//make sure the first option still exists |
|
| 254 | 254 | |
| 255 | - $product->doRestoreToStage();//restore page to draft site |
|
| 256 | - $product->doUnpublish();//unpublish page |
|
| 257 | - $product->deleteFromStage('Stage');//remove product from draft site |
|
| 255 | + $product->doRestoreToStage();//restore page to draft site |
|
| 256 | + $product->doUnpublish();//unpublish page |
|
| 257 | + $product->deleteFromStage('Stage');//remove product from draft site |
|
| 258 | 258 | |
| 259 | - $checkDeleted = OptionItem::get()->filter(array('Title' => 'Large', 'ProductID' => $productID))->first();//query same option as above |
|
| 259 | + $checkDeleted = OptionItem::get()->filter(array('Title' => 'Large', 'ProductID' => $productID))->first();//query same option as above |
|
| 260 | 260 | |
| 261 | - $this->assertEquals($checkDeleted->ID, 0);//check that the ID is 0 (empty object/non-existent) |
|
| 262 | - } |
|
| 261 | + $this->assertEquals($checkDeleted->ID, 0);//check that the ID is 0 (empty object/non-existent) |
|
| 262 | + } |
|
| 263 | 263 | } |
| 264 | 264 | \ No newline at end of file |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | /** |
| 19 | 19 | * @throws \SilverStripe\ORM\ValidationException |
| 20 | 20 | */ |
| 21 | - function setUp(){ |
|
| 21 | + function setUp() { |
|
| 22 | 22 | parent::setUp(); |
| 23 | 23 | |
| 24 | 24 | $groupForItem = OptionGroup::create(); |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | $productHolder->write();*/ |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - function testProductCreation(){ |
|
| 33 | + function testProductCreation() { |
|
| 34 | 34 | |
| 35 | 35 | $this->logInWithPermission('Product_CANCRUD'); |
| 36 | 36 | $default = $this->objFromFixture(ProductCategory::class, 'default'); |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - function testProductDeletion(){ |
|
| 45 | + function testProductDeletion() { |
|
| 46 | 46 | |
| 47 | 47 | $this->logInWithPermission('Product_CANCRUD'); |
| 48 | 48 | $holder = $this->objFromFixture(ProductHolder::class, 'default'); |
@@ -53,16 +53,16 @@ discard block |
||
| 53 | 53 | $product2->write(); |
| 54 | 54 | $this->assertTrue($product2->exists()); |
| 55 | 55 | |
| 56 | - $versions = DB::query('Select * FROM "FS_ProductPage_versions" WHERE "RecordID" = '. $productID); |
|
| 56 | + $versions = DB::query('Select * FROM "FS_ProductPage_versions" WHERE "RecordID" = '.$productID); |
|
| 57 | 57 | $versionsPostPublish = array(); |
| 58 | - foreach($versions as $versionRow) $versionsPostPublish[] = $versionRow; |
|
| 58 | + foreach ($versions as $versionRow) $versionsPostPublish[] = $versionRow; |
|
| 59 | 59 | |
| 60 | 60 | $product2->delete(); |
| 61 | 61 | $this->assertTrue(!$product2->exists()); |
| 62 | 62 | |
| 63 | - $versions = DB::query('Select * FROM "FS_ProductPage_versions" WHERE "RecordID" = '. $productID); |
|
| 63 | + $versions = DB::query('Select * FROM "FS_ProductPage_versions" WHERE "RecordID" = '.$productID); |
|
| 64 | 64 | $versionsPostDelete = array(); |
| 65 | - foreach($versions as $versionRow) $versionsPostDelete[] = $versionRow; |
|
| 65 | + foreach ($versions as $versionRow) $versionsPostDelete[] = $versionRow; |
|
| 66 | 66 | |
| 67 | 67 | $this->assertTrue($versionsPostPublish == $versionsPostDelete); |
| 68 | 68 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | /** |
| 72 | 72 | * @throws \SilverStripe\ORM\ValidationException |
| 73 | 73 | */ |
| 74 | - function testProductTitleLeadingWhiteSpace(){ |
|
| 74 | + function testProductTitleLeadingWhiteSpace() { |
|
| 75 | 75 | |
| 76 | 76 | $this->logInWithPermission('ADMIN'); |
| 77 | 77 | |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | /** |
| 90 | 90 | * @throws \SilverStripe\ORM\ValidationException |
| 91 | 91 | */ |
| 92 | - function testProductTitleTrailingWhiteSpace(){ |
|
| 92 | + function testProductTitleTrailingWhiteSpace() { |
|
| 93 | 93 | |
| 94 | 94 | $this->logInWithPermission('ADMIN'); |
| 95 | 95 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - function testProductCategoryCreation(){ |
|
| 107 | + function testProductCategoryCreation() { |
|
| 108 | 108 | |
| 109 | 109 | $this->logInWithPermission('Product_CANCRUD'); |
| 110 | 110 | $category = $this->objFromFixture(ProductCategory::class, 'apparel'); |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - function testProductCategoryDeletion(){ |
|
| 120 | + function testProductCategoryDeletion() { |
|
| 121 | 121 | |
| 122 | 122 | $this->logInWithPermission('Product_CANCRUD'); |
| 123 | 123 | |
@@ -144,11 +144,11 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | $category2->delete(); |
| 146 | 146 | |
| 147 | - $this->assertFalse(in_array($category2ID,ProductCategory::get()->column('ID'))); |
|
| 147 | + $this->assertFalse(in_array($category2ID, ProductCategory::get()->column('ID'))); |
|
| 148 | 148 | |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - function testOptionGroupCreation(){ |
|
| 151 | + function testOptionGroupCreation() { |
|
| 152 | 152 | |
| 153 | 153 | $this->logInWithPermission('Product_CANCRUD'); |
| 154 | 154 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - function testOptionGroupDeletion(){ |
|
| 162 | + function testOptionGroupDeletion() { |
|
| 163 | 163 | |
| 164 | 164 | $this->logInWithPermission('ADMIN'); |
| 165 | 165 | $group = $this->objFromFixture(OptionGroup::class, 'color'); |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - function testOptionItemCreation(){ |
|
| 181 | + function testOptionItemCreation() { |
|
| 182 | 182 | |
| 183 | 183 | $this->logInWithPermission('Product_CANCRUD'); |
| 184 | 184 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - function testOptionItemDeletion(){ |
|
| 199 | + function testOptionItemDeletion() { |
|
| 200 | 200 | |
| 201 | 201 | $this->logInWithPermission('ADMIN'); |
| 202 | 202 | |
@@ -220,44 +220,44 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - public function testProductDraftOptionDeletion(){ |
|
| 223 | + public function testProductDraftOptionDeletion() { |
|
| 224 | 224 | |
| 225 | - self::$use_draft_site = false;//make sure we can publish |
|
| 225 | + self::$use_draft_site = false; //make sure we can publish |
|
| 226 | 226 | |
| 227 | 227 | $this->logInWithPermission('ADMIN'); |
| 228 | 228 | |
| 229 | - $holder = $this->objFromFixture(ProductHolder::class, 'default');//build holder page, ProductPage can't be on root level |
|
| 229 | + $holder = $this->objFromFixture(ProductHolder::class, 'default'); //build holder page, ProductPage can't be on root level |
|
| 230 | 230 | $holder->doPublish(); |
| 231 | 231 | |
| 232 | - $product = $this->objFromFixture(ProductPage::class, 'product1');//build product page |
|
| 232 | + $product = $this->objFromFixture(ProductPage::class, 'product1'); //build product page |
|
| 233 | 233 | $product->doPublish(); |
| 234 | 234 | |
| 235 | 235 | $productID = $product->ID; |
| 236 | 236 | |
| 237 | 237 | |
| 238 | - $optionGroup = $this->objFromFixture(OptionGroup::class, 'size');//build the group for the options |
|
| 238 | + $optionGroup = $this->objFromFixture(OptionGroup::class, 'size'); //build the group for the options |
|
| 239 | 239 | $optionGroup->write(); |
| 240 | - $option = $this->objFromFixture(OptionItem::class, 'small');//build first option |
|
| 240 | + $option = $this->objFromFixture(OptionItem::class, 'small'); //build first option |
|
| 241 | 241 | $option->write(); |
| 242 | - $option2 = $this->objFromFixture(OptionItem::class, 'large');//build second option |
|
| 242 | + $option2 = $this->objFromFixture(OptionItem::class, 'large'); //build second option |
|
| 243 | 243 | $option2->write(); |
| 244 | 244 | |
| 245 | - $this->assertTrue($product->isPublished());//check that product is published |
|
| 245 | + $this->assertTrue($product->isPublished()); //check that product is published |
|
| 246 | 246 | |
| 247 | - $product->deleteFromStage('Stage');//remove product from draft site |
|
| 247 | + $product->deleteFromStage('Stage'); //remove product from draft site |
|
| 248 | 248 | |
| 249 | - $this->assertTrue($product->isPublished());//check product is still published |
|
| 249 | + $this->assertTrue($product->isPublished()); //check product is still published |
|
| 250 | 250 | |
| 251 | 251 | $testOption = $this->objFromFixture(OptionItem::class, 'large'); |
| 252 | 252 | |
| 253 | - $this->assertThat($testOption->ID, $this->logicalNot($this->equalTo(0)));//make sure the first option still exists |
|
| 253 | + $this->assertThat($testOption->ID, $this->logicalNot($this->equalTo(0))); //make sure the first option still exists |
|
| 254 | 254 | |
| 255 | - $product->doRestoreToStage();//restore page to draft site |
|
| 256 | - $product->doUnpublish();//unpublish page |
|
| 257 | - $product->deleteFromStage('Stage');//remove product from draft site |
|
| 255 | + $product->doRestoreToStage(); //restore page to draft site |
|
| 256 | + $product->doUnpublish(); //unpublish page |
|
| 257 | + $product->deleteFromStage('Stage'); //remove product from draft site |
|
| 258 | 258 | |
| 259 | - $checkDeleted = OptionItem::get()->filter(array('Title' => 'Large', 'ProductID' => $productID))->first();//query same option as above |
|
| 259 | + $checkDeleted = OptionItem::get()->filter(array('Title' => 'Large', 'ProductID' => $productID))->first(); //query same option as above |
|
| 260 | 260 | |
| 261 | - $this->assertEquals($checkDeleted->ID, 0);//check that the ID is 0 (empty object/non-existent) |
|
| 261 | + $this->assertEquals($checkDeleted->ID, 0); //check that the ID is 0 (empty object/non-existent) |
|
| 262 | 262 | } |
| 263 | 263 | } |
| 264 | 264 | \ No newline at end of file |
@@ -55,14 +55,18 @@ |
||
| 55 | 55 | |
| 56 | 56 | $versions = DB::query('Select * FROM "FS_ProductPage_versions" WHERE "RecordID" = '. $productID); |
| 57 | 57 | $versionsPostPublish = array(); |
| 58 | - foreach($versions as $versionRow) $versionsPostPublish[] = $versionRow; |
|
| 58 | + foreach($versions as $versionRow) { |
|
| 59 | + $versionsPostPublish[] = $versionRow; |
|
| 60 | + } |
|
| 59 | 61 | |
| 60 | 62 | $product2->delete(); |
| 61 | 63 | $this->assertTrue(!$product2->exists()); |
| 62 | 64 | |
| 63 | 65 | $versions = DB::query('Select * FROM "FS_ProductPage_versions" WHERE "RecordID" = '. $productID); |
| 64 | 66 | $versionsPostDelete = array(); |
| 65 | - foreach($versions as $versionRow) $versionsPostDelete[] = $versionRow; |
|
| 67 | + foreach($versions as $versionRow) { |
|
| 68 | + $versionsPostDelete[] = $versionRow; |
|
| 69 | + } |
|
| 66 | 70 | |
| 67 | 71 | $this->assertTrue($versionsPostPublish == $versionsPostDelete); |
| 68 | 72 | |
@@ -28,9 +28,9 @@ discard block |
||
| 28 | 28 | class FoxyStripeSiteConfig extends DataExtension |
| 29 | 29 | { |
| 30 | 30 | |
| 31 | - private static $db = array( |
|
| 32 | - 'StoreTitle' => 'Varchar(255)', |
|
| 33 | - 'StoreName' => 'Varchar(255)', |
|
| 31 | + private static $db = array( |
|
| 32 | + 'StoreTitle' => 'Varchar(255)', |
|
| 33 | + 'StoreName' => 'Varchar(255)', |
|
| 34 | 34 | 'StoreURL' => 'Varchar(255)', |
| 35 | 35 | 'ReceiptURL' => 'Varchar(255)', |
| 36 | 36 | 'StoreEmail' => 'Varchar(255)', |
@@ -48,21 +48,21 @@ discard block |
||
| 48 | 48 | 'UseSingleSignOn' => 'Boolean', |
| 49 | 49 | 'AllowMultiship' => 'Boolean', |
| 50 | 50 | 'StoreTimezone' => 'Varchar(100)', |
| 51 | - 'MultiGroup' => 'Boolean', |
|
| 52 | - 'ProductLimit' => 'Int', |
|
| 53 | - 'MaxQuantity' => 'Int', |
|
| 51 | + 'MultiGroup' => 'Boolean', |
|
| 52 | + 'ProductLimit' => 'Int', |
|
| 53 | + 'MaxQuantity' => 'Int', |
|
| 54 | 54 | 'client_id' => 'Varchar(255)', |
| 55 | 55 | 'client_secret' => 'Varchar(255)', |
| 56 | 56 | 'access_token' => 'Varchar(255)', |
| 57 | 57 | 'refresh_token' => 'Varchar(255)', |
| 58 | - ); |
|
| 58 | + ); |
|
| 59 | 59 | |
| 60 | 60 | // Set Default values |
| 61 | 61 | private static $defaults = array( |
| 62 | 62 | 'ProductLimit' => 10 |
| 63 | 63 | ); |
| 64 | 64 | |
| 65 | - public function updateCMSFields(FieldList $fields){ |
|
| 65 | + public function updateCMSFields(FieldList $fields){ |
|
| 66 | 66 | |
| 67 | 67 | // set TabSet names to avoid spaces from camel case |
| 68 | 68 | $fields->addFieldToTab('Root', new TabSet('FoxyStripe', 'FoxyStripe')); |
@@ -70,17 +70,17 @@ discard block |
||
| 70 | 70 | // settings tab |
| 71 | 71 | $fields->addFieldsToTab('Root.FoxyStripe.Settings', array( |
| 72 | 72 | // Store Details |
| 73 | - HeaderField::create('StoreDetails', _t('FoxyStripeSiteConfig.StoreDetails', 'Store Settings'), 3), |
|
| 74 | - LiteralField::create('DetailsIntro', _t( |
|
| 75 | - 'FoxyStripeSiteConfig.DetailsIntro', |
|
| 73 | + HeaderField::create('StoreDetails', _t('FoxyStripeSiteConfig.StoreDetails', 'Store Settings'), 3), |
|
| 74 | + LiteralField::create('DetailsIntro', _t( |
|
| 75 | + 'FoxyStripeSiteConfig.DetailsIntro', |
|
| 76 | 76 | '<p>Maps to data in your <a href="https://admin.foxycart.com/admin.php?ThisAction=EditStore" target="_blank">FoxyCart store settings</a>.' |
| 77 | 77 | )), |
| 78 | 78 | TextField::create('StoreTitle') |
| 79 | 79 | ->setTitle(_t('FoxyStripeSiteConfig.StoreTitle', 'Store Name')) |
| 80 | 80 | ->setDescription(_t('FoxyStripeSiteConfig.StoreTitleDescription', 'The name of your store as you\'d like it displayed to your customers')), |
| 81 | - TextField::create('StoreName') |
|
| 82 | - ->setTitle(_t('FoxyStripeSiteConfig.StoreName', 'Store Domain')) |
|
| 83 | - ->setDescription(_t('FoxyStripeSiteConfig.StoreNameDescription', 'This is a unique FoxyCart subdomain for your cart, checkout, and receipt')), |
|
| 81 | + TextField::create('StoreName') |
|
| 82 | + ->setTitle(_t('FoxyStripeSiteConfig.StoreName', 'Store Domain')) |
|
| 83 | + ->setDescription(_t('FoxyStripeSiteConfig.StoreNameDescription', 'This is a unique FoxyCart subdomain for your cart, checkout, and receipt')), |
|
| 84 | 84 | TextField::create('StoreURL') |
| 85 | 85 | ->setTitle(_t('FoxyStripeSiteConfig.StoreURL', 'Store URL')) |
| 86 | 86 | ->setDescription(_t('FoxyStripeSiteConfig.StoreURLDescription', 'The URL of your online store')), |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | TextField::create('StoreLogoURL', 'Logo URL') |
| 103 | 103 | ->setAttribute('placeholder', 'http://') |
| 104 | 104 | |
| 105 | - // Advanced Settings |
|
| 105 | + // Advanced Settings |
|
| 106 | 106 | /* |
| 107 | 107 | HeaderField::create('AdvanceHeader', _t('FoxyStripeSiteConfig.AdvancedHeader', 'Advanced Settings'), 3), |
| 108 | 108 | LiteralField::create('AdvancedIntro', _t( |
@@ -146,72 +146,72 @@ discard block |
||
| 146 | 146 | ]); |
| 147 | 147 | |
| 148 | 148 | // configuration warning |
| 149 | - if(FoxyCart::store_name_warning()!==null){ |
|
| 150 | - $fields->insertBefore(LiteralField::create( |
|
| 149 | + if(FoxyCart::store_name_warning()!==null){ |
|
| 150 | + $fields->insertBefore(LiteralField::create( |
|
| 151 | 151 | "StoreSubDomainHeaderWarning", |
| 152 | 152 | _t( |
| 153 | 153 | 'FoxyStripeSiteConfig.StoreSubDomainHeadingWarning', |
| 154 | 154 | "<p class=\"message error\">Store sub-domain must be entered in the <a href=\"/admin/settings/\">site settings</a></p>" |
| 155 | 155 | ) |
| 156 | 156 | ), 'StoreDetails'); |
| 157 | - } |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | 159 | // products tab |
| 160 | - $fields->addFieldsToTab('Root.FoxyStripe.Products', array( |
|
| 161 | - HeaderField::create('ProductHeader', _t('FoxyStripeSiteConfig.ProductHeader', 'Products'), 3), |
|
| 162 | - CheckboxField::create('MultiGroup') |
|
| 163 | - ->setTitle(_t('FoxyStripeSiteConfig.MultiGroup', 'Multiple Groups')) |
|
| 164 | - ->setDescription(_t( |
|
| 160 | + $fields->addFieldsToTab('Root.FoxyStripe.Products', array( |
|
| 161 | + HeaderField::create('ProductHeader', _t('FoxyStripeSiteConfig.ProductHeader', 'Products'), 3), |
|
| 162 | + CheckboxField::create('MultiGroup') |
|
| 163 | + ->setTitle(_t('FoxyStripeSiteConfig.MultiGroup', 'Multiple Groups')) |
|
| 164 | + ->setDescription(_t( |
|
| 165 | 165 | 'FoxyStripeSiteConfig.MultiGroupDescription', |
| 166 | 166 | 'Allows products to be shown in multiple Product Groups' |
| 167 | 167 | )), |
| 168 | - HeaderField::create('ProductGroupHD', _t('FoxyStripeSiteConfig.ProductGroupHD', 'Product Groups'), 3), |
|
| 169 | - NumericField::create('ProductLimit') |
|
| 170 | - ->setTitle(_t('FoxyStripeSiteConfig.ProductLimit', 'Products per Page')) |
|
| 171 | - ->setDescription(_t( |
|
| 168 | + HeaderField::create('ProductGroupHD', _t('FoxyStripeSiteConfig.ProductGroupHD', 'Product Groups'), 3), |
|
| 169 | + NumericField::create('ProductLimit') |
|
| 170 | + ->setTitle(_t('FoxyStripeSiteConfig.ProductLimit', 'Products per Page')) |
|
| 171 | + ->setDescription(_t( |
|
| 172 | 172 | 'FoxyStripeSiteConfig.ProductLimitDescription', |
| 173 | 173 | 'Number of Products to show per page on a Product Group' |
| 174 | 174 | )), |
| 175 | - HeaderField::create('ProductQuantityHD', _t('FoxyStripeSiteConfig.ProductQuantityHD', 'Product Form Max Quantity'), 3), |
|
| 176 | - NumericField::create('MaxQuantity') |
|
| 177 | - ->setTitle(_t('FoxyStripeSiteConfig.MaxQuantity', 'Max Quantity')) |
|
| 178 | - ->setDescription(_t( |
|
| 175 | + HeaderField::create('ProductQuantityHD', _t('FoxyStripeSiteConfig.ProductQuantityHD', 'Product Form Max Quantity'), 3), |
|
| 176 | + NumericField::create('MaxQuantity') |
|
| 177 | + ->setTitle(_t('FoxyStripeSiteConfig.MaxQuantity', 'Max Quantity')) |
|
| 178 | + ->setDescription(_t( |
|
| 179 | 179 | 'FoxyStripeSiteConfig.MaxQuantityDescription', |
| 180 | 180 | 'Sets max quantity for product form dropdown (add to cart form - default 10)' |
| 181 | 181 | )) |
| 182 | - )); |
|
| 182 | + )); |
|
| 183 | 183 | |
| 184 | 184 | // categories tab |
| 185 | - $fields->addFieldsToTab('Root.FoxyStripe.Categories', array( |
|
| 186 | - HeaderField::create('CategoryHD', _t('FoxyStripeSiteConfig.CategoryHD', 'FoxyStripe Categories'), 3), |
|
| 187 | - LiteralField::create('CategoryDescrip', _t( |
|
| 185 | + $fields->addFieldsToTab('Root.FoxyStripe.Categories', array( |
|
| 186 | + HeaderField::create('CategoryHD', _t('FoxyStripeSiteConfig.CategoryHD', 'FoxyStripe Categories'), 3), |
|
| 187 | + LiteralField::create('CategoryDescrip', _t( |
|
| 188 | 188 | 'FoxyStripeSiteConfig.CategoryDescrip', |
| 189 | 189 | '<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>' |
| 190 | 190 | )), |
| 191 | - GridField::create( |
|
| 191 | + GridField::create( |
|
| 192 | 192 | 'ProductCategory', |
| 193 | 193 | _t('FoxyStripeSiteConfig.ProductCategory', 'FoxyCart Categories'), |
| 194 | 194 | ProductCategory::get(), |
| 195 | 195 | GridFieldConfig_RecordEditor::create() |
| 196 | 196 | ) |
| 197 | - )); |
|
| 197 | + )); |
|
| 198 | 198 | |
| 199 | 199 | // option groups tab |
| 200 | - $fields->addFieldsToTab('Root.FoxyStripe.Groups', array( |
|
| 201 | - HeaderField::create('OptionGroupsHead', _t('FoxyStripeSiteConfig', 'Product Option Groups'), 3), |
|
| 202 | - LiteralField::create('OptionGroupsDescrip', _t( |
|
| 200 | + $fields->addFieldsToTab('Root.FoxyStripe.Groups', array( |
|
| 201 | + HeaderField::create('OptionGroupsHead', _t('FoxyStripeSiteConfig', 'Product Option Groups'), 3), |
|
| 202 | + LiteralField::create('OptionGroupsDescrip', _t( |
|
| 203 | 203 | 'FoxyStripeSiteConfig.OptionGroupsDescrip', |
| 204 | 204 | '<p>Product Option Groups allow you to name a set of product options.</p>' |
| 205 | 205 | )), |
| 206 | - GridField::create( |
|
| 206 | + GridField::create( |
|
| 207 | 207 | 'OptionGroup', |
| 208 | 208 | _t('FoxyStripeSiteConfig.OptionGroup', 'Product Option Groups'), |
| 209 | 209 | OptionGroup::get(), |
| 210 | 210 | GridFieldConfig_RecordEditor::create() |
| 211 | 211 | ) |
| 212 | - )); |
|
| 212 | + )); |
|
| 213 | 213 | |
| 214 | - // api tab |
|
| 214 | + // api tab |
|
| 215 | 215 | $fields->addFieldsToTab('Root.FoxyStripe.API', [ |
| 216 | 216 | HeaderField::create('APIHD', 'FoxyCart API Settings', 3), |
| 217 | 217 | TextField::create('client_id', 'FoxyCart Client ID'), |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | TextField::create('refresh_token', 'FoxyCart Refresh Token'), |
| 221 | 221 | ]); |
| 222 | 222 | |
| 223 | - } |
|
| 223 | + } |
|
| 224 | 224 | |
| 225 | 225 | /** |
| 226 | 226 | * @return string |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | 'ProductLimit' => 10 |
| 63 | 63 | ); |
| 64 | 64 | |
| 65 | - public function updateCMSFields(FieldList $fields){ |
|
| 65 | + public function updateCMSFields(FieldList $fields) { |
|
| 66 | 66 | |
| 67 | 67 | // set TabSet names to avoid spaces from camel case |
| 68 | 68 | $fields->addFieldToTab('Root', new TabSet('FoxyStripe', 'FoxyStripe')); |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | ]); |
| 147 | 147 | |
| 148 | 148 | // configuration warning |
| 149 | - if(FoxyCart::store_name_warning()!==null){ |
|
| 149 | + if (FoxyCart::store_name_warning() !== null) { |
|
| 150 | 150 | $fields->insertBefore(LiteralField::create( |
| 151 | 151 | "StoreSubDomainHeaderWarning", |
| 152 | 152 | _t( |
@@ -247,14 +247,14 @@ discard block |
||
| 247 | 247 | |
| 248 | 248 | $siteConfig = SiteConfig::current_site_config(); |
| 249 | 249 | |
| 250 | - if(!$siteConfig->StoreKey) { |
|
| 250 | + if (!$siteConfig->StoreKey) { |
|
| 251 | 251 | $key = FoxyCart::setStoreKey(); |
| 252 | - while(!ctype_alnum($key)){ |
|
| 252 | + while (!ctype_alnum($key)) { |
|
| 253 | 253 | $key = FoxyCart::setStoreKey(); |
| 254 | 254 | } |
| 255 | 255 | $siteConfig->StoreKey = $key; |
| 256 | 256 | $siteConfig->write(); |
| 257 | - DB::alteration_message($siteConfig->ClassName.": created FoxyCart Store Key " . $key, 'created'); |
|
| 257 | + DB::alteration_message($siteConfig->ClassName.": created FoxyCart Store Key ".$key, 'created'); |
|
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | 260 | |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | // Grab customer_id record from FoxyCart response, store in Member |
| 47 | 47 | if ($response) { |
| 48 | 48 | $foxyResponse = new \SimpleXMLElement($response); |
| 49 | - $this->owner->Customer_ID = (int) $foxyResponse->customer_id; |
|
| 49 | + $this->owner->Customer_ID = (int)$foxyResponse->customer_id; |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | } |
@@ -326,18 +326,18 @@ |
||
| 326 | 326 | * @param bool $member |
| 327 | 327 | * @return bool|int |
| 328 | 328 | */ |
| 329 | - public function canView($member = false) { |
|
| 330 | - return Permission::check('Product_ORDERS', 'any', $member); |
|
| 331 | - } |
|
| 329 | + public function canView($member = false) { |
|
| 330 | + return Permission::check('Product_ORDERS', 'any', $member); |
|
| 331 | + } |
|
| 332 | 332 | |
| 333 | 333 | /** |
| 334 | 334 | * @param null $member |
| 335 | 335 | * @return bool |
| 336 | 336 | */ |
| 337 | - public function canEdit($member = null) { |
|
| 337 | + public function canEdit($member = null) { |
|
| 338 | 338 | return false; |
| 339 | 339 | //return Permission::check('Product_ORDERS', 'any', $member); |
| 340 | - } |
|
| 340 | + } |
|
| 341 | 341 | |
| 342 | 342 | /** |
| 343 | 343 | * @param null $member |
@@ -145,8 +145,8 @@ discard block |
||
| 145 | 145 | */ |
| 146 | 146 | public function getReceiptLink() |
| 147 | 147 | { |
| 148 | - $obj= DBHTMLVarchar::create(); |
|
| 149 | - $obj->setValue('<a href="' . $this->ReceiptURL . '" target="_blank" class="cms-panel-link action external-link">view</a>'); |
|
| 148 | + $obj = DBHTMLVarchar::create(); |
|
| 149 | + $obj->setValue('<a href="'.$this->ReceiptURL.'" target="_blank" class="cms-panel-link action external-link">view</a>'); |
|
| 150 | 150 | return $obj; |
| 151 | 151 | } |
| 152 | 152 | |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | return true; |
| 187 | 187 | |
| 188 | - } else { |
|
| 188 | + }else { |
|
| 189 | 189 | |
| 190 | 190 | return false; |
| 191 | 191 | |
@@ -200,14 +200,14 @@ discard block |
||
| 200 | 200 | foreach ($response->transactions->transaction as $transaction) { |
| 201 | 201 | |
| 202 | 202 | // Record transaction data from FoxyCart Datafeed: |
| 203 | - $this->Store_ID = (int) $transaction->store_id; |
|
| 204 | - $this->TransactionDate = (string) $transaction->transaction_date; |
|
| 205 | - $this->ProductTotal = (float) $transaction->product_total; |
|
| 206 | - $this->TaxTotal = (float) $transaction->tax_total; |
|
| 207 | - $this->ShippingTotal = (float) $transaction->shipping_total; |
|
| 208 | - $this->OrderTotal = (float) $transaction->order_total; |
|
| 209 | - $this->ReceiptURL = (string) $transaction->receipt_url; |
|
| 210 | - $this->OrderStatus = (string) $transaction->status; |
|
| 203 | + $this->Store_ID = (int)$transaction->store_id; |
|
| 204 | + $this->TransactionDate = (string)$transaction->transaction_date; |
|
| 205 | + $this->ProductTotal = (float)$transaction->product_total; |
|
| 206 | + $this->TaxTotal = (float)$transaction->tax_total; |
|
| 207 | + $this->ShippingTotal = (float)$transaction->shipping_total; |
|
| 208 | + $this->OrderTotal = (float)$transaction->order_total; |
|
| 209 | + $this->ReceiptURL = (string)$transaction->receipt_url; |
|
| 210 | + $this->OrderStatus = (string)$transaction->status; |
|
| 211 | 211 | |
| 212 | 212 | $this->extend('handleOrderInfo', $order, $response); |
| 213 | 213 | } |
@@ -224,24 +224,24 @@ discard block |
||
| 224 | 224 | if (isset($transaction->customer_email) && $transaction->is_anonymous == 0) { |
| 225 | 225 | |
| 226 | 226 | // if Customer is existing member, associate with current order |
| 227 | - if(Member::get()->filter('Email', $transaction->customer_email)->First()) { |
|
| 227 | + if (Member::get()->filter('Email', $transaction->customer_email)->First()) { |
|
| 228 | 228 | |
| 229 | 229 | $customer = Member::get()->filter('Email', $transaction->customer_email)->First(); |
| 230 | 230 | |
| 231 | 231 | // if new customer, create account with data from FoxyCart |
| 232 | - } else { |
|
| 232 | + }else { |
|
| 233 | 233 | |
| 234 | 234 | // set PasswordEncryption to 'none' so imported, encrypted password is not encrypted again |
| 235 | 235 | Config::inst()->update('Security', 'password_encryption_algorithm', 'none'); |
| 236 | 236 | |
| 237 | 237 | // create new Member, set password info from FoxyCart |
| 238 | 238 | $customer = Member::create(); |
| 239 | - $customer->Customer_ID = (int) $transaction->customer_id; |
|
| 240 | - $customer->FirstName = (string) $transaction->customer_first_name; |
|
| 241 | - $customer->Surname = (string) $transaction->customer_last_name; |
|
| 242 | - $customer->Email = (string) $transaction->customer_email; |
|
| 243 | - $customer->Password = (string) $transaction->customer_password; |
|
| 244 | - $customer->Salt = (string) $transaction->customer_password_salt; |
|
| 239 | + $customer->Customer_ID = (int)$transaction->customer_id; |
|
| 240 | + $customer->FirstName = (string)$transaction->customer_first_name; |
|
| 241 | + $customer->Surname = (string)$transaction->customer_last_name; |
|
| 242 | + $customer->Email = (string)$transaction->customer_email; |
|
| 243 | + $customer->Password = (string)$transaction->customer_password; |
|
| 244 | + $customer->Salt = (string)$transaction->customer_password_salt; |
|
| 245 | 245 | $customer->PasswordEncryption = 'none'; |
| 246 | 246 | |
| 247 | 247 | // record member record |
@@ -278,11 +278,11 @@ discard block |
||
| 278 | 278 | |
| 279 | 279 | $OrderDetail = OrderDetail::create(); |
| 280 | 280 | |
| 281 | - $OrderDetail->Quantity = (int) $detail->product_quantity; |
|
| 282 | - $OrderDetail->ProductName = (string) $detail->product_name; |
|
| 283 | - $OrderDetail->ProductCode = (string) $detail->product_code; |
|
| 284 | - $OrderDetail->ProductImage = (string) $detail->image; |
|
| 285 | - $OrderDetail->ProductCategory = (string) $detail->category_code; |
|
| 281 | + $OrderDetail->Quantity = (int)$detail->product_quantity; |
|
| 282 | + $OrderDetail->ProductName = (string)$detail->product_name; |
|
| 283 | + $OrderDetail->ProductCode = (string)$detail->product_code; |
|
| 284 | + $OrderDetail->ProductImage = (string)$detail->image; |
|
| 285 | + $OrderDetail->ProductCategory = (string)$detail->category_code; |
|
| 286 | 286 | $priceModifier = 0; |
| 287 | 287 | |
| 288 | 288 | // parse OrderOptions |
@@ -292,14 +292,14 @@ discard block |
||
| 292 | 292 | if ($option->product_option_name == 'product_id') { |
| 293 | 293 | |
| 294 | 294 | // if product is found, set relation to OrderDetail |
| 295 | - $OrderProduct = ProductPage::get()->byID((int) $option->product_option_value); |
|
| 295 | + $OrderProduct = ProductPage::get()->byID((int)$option->product_option_value); |
|
| 296 | 296 | if ($OrderProduct) $OrderDetail->ProductID = $OrderProduct->ID; |
| 297 | 297 | |
| 298 | - } else { |
|
| 298 | + }else { |
|
| 299 | 299 | |
| 300 | 300 | $OrderOption = OrderOption::create(); |
| 301 | - $OrderOption->Name = (string) $option->product_option_name; |
|
| 302 | - $OrderOption->Value = (string) $option->product_option_value; |
|
| 301 | + $OrderOption->Name = (string)$option->product_option_name; |
|
| 302 | + $OrderOption->Value = (string)$option->product_option_value; |
|
| 303 | 303 | $OrderOption->write(); |
| 304 | 304 | $OrderDetail->OrderOptions()->add($OrderOption); |
| 305 | 305 | |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | - $OrderDetail->Price = (float) $detail->product_price + (float) $priceModifier; |
|
| 311 | + $OrderDetail->Price = (float)$detail->product_price + (float)$priceModifier; |
|
| 312 | 312 | |
| 313 | 313 | // extend OrderDetail parsing, allowing for recording custom fields from FoxyCart |
| 314 | 314 | $this->extend('handleOrderItem', $order, $response, $OrderDetail); |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | $parentCode = $product->Code; |
| 111 | 111 | |
| 112 | 112 | // ProductOptionGroup Dropdown field w/ add new |
| 113 | - $groups = function () { |
|
| 113 | + $groups = function() { |
|
| 114 | 114 | return OptionGroup::get()->map()->toArray(); |
| 115 | 115 | }; |
| 116 | 116 | $groupFields = singleton(OptionGroup::class)->getCMSFields(); |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | * @param bool $returnWithOnlyPlusMinus |
| 242 | 242 | * @return string |
| 243 | 243 | */ |
| 244 | - public static function getOptionModifierActionSymbol($oma, $returnWithOnlyPlusMinus=false) |
|
| 244 | + public static function getOptionModifierActionSymbol($oma, $returnWithOnlyPlusMinus = false) |
|
| 245 | 245 | { |
| 246 | 246 | switch ($oma) { |
| 247 | 247 | case 'Subtract': |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | { |
| 309 | 309 | $modPrice = ($this->PriceModifier) ? (string)$this->PriceModifier : '0'; |
| 310 | 310 | $title = $this->Title; |
| 311 | - $title .= ($this->PriceModifier != 0) ? ': ('.OptionItem::getOptionModifierActionSymbol($this->PriceModifierAction, $returnWithOnlyPlusMinus=true).'$'.$modPrice.')' : ''; |
|
| 311 | + $title .= ($this->PriceModifier != 0) ? ': ('.OptionItem::getOptionModifierActionSymbol($this->PriceModifierAction, $returnWithOnlyPlusMinus = true).'$'.$modPrice.')' : ''; |
|
| 312 | 312 | return $title; |
| 313 | 313 | } |
| 314 | 314 | |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | */ |
| 318 | 318 | public function getAvailability() |
| 319 | 319 | { |
| 320 | - $available = ($this->Available == 1) ? true : false ; |
|
| 320 | + $available = ($this->Available == 1) ? true : false; |
|
| 321 | 321 | |
| 322 | 322 | $this->extend('updateOptionAvailability', $available); |
| 323 | 323 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | $strLength = strlen($charset); |
| 32 | 32 | $str = ''; |
| 33 | 33 | while ($count < $length) { |
| 34 | - $str .= $charset[mt_rand(0, $strLength-1)]; |
|
| 34 | + $str .= $charset[mt_rand(0, $strLength - 1)]; |
|
| 35 | 35 | $count++; |
| 36 | 36 | } |
| 37 | 37 | return self::getKeyPrefix().substr(base64_encode($str), 0, $length); |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | public static function store_name_warning() |
| 56 | 56 | { |
| 57 | 57 | $warning = null; |
| 58 | - if (self::getFoxyCartStoreName()===null) { |
|
| 58 | + if (self::getFoxyCartStoreName() === null) { |
|
| 59 | 59 | $warning = 'Must define FoxyCart Store Name in your site settings in the cms'; |
| 60 | 60 | } |
| 61 | 61 | return $warning; |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $foxyData["api_token"] = FoxyCart::getStoreKey(); |
| 98 | 98 | |
| 99 | 99 | $ch = curl_init(); |
| 100 | - curl_setopt($ch, CURLOPT_URL, "https://" . $foxy_domain . "/api"); |
|
| 100 | + curl_setopt($ch, CURLOPT_URL, "https://".$foxy_domain."/api"); |
|
| 101 | 101 | curl_setopt($ch, CURLOPT_POSTFIELDS, $foxyData); |
| 102 | 102 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
| 103 | 103 | curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | public static function putCustomer($Member = null) |
| 151 | 151 | { |
| 152 | 152 | // throw error if no $Member Object |
| 153 | - if (!isset($Member)) ;//trigger_error('No Member set', E_USER_ERROR); |
|
| 153 | + if (!isset($Member)); //trigger_error('No Member set', E_USER_ERROR); |
|
| 154 | 154 | |
| 155 | 155 | // send updated customer record from API |
| 156 | 156 | $foxyData = array(); |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | if (count($errors)) { |
| 138 | - Injector::inst()->get(LoggerInterface::class)->error('setCurrentStore errors - ' . json_encode($errors)); |
|
| 138 | + Injector::inst()->get(LoggerInterface::class)->error('setCurrentStore errors - '.json_encode($errors)); |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | |
| 153 | 153 | $errors = array_merge($errors, $client->getErrors($result)); |
| 154 | 154 | if (count($errors)) { |
| 155 | - Injector::inst()->get(LoggerInterface::class)->error('updateStore errors - ' . json_encode($errors)); |
|
| 155 | + Injector::inst()->get(LoggerInterface::class)->error('updateStore errors - '.json_encode($errors)); |
|
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | |
| 182 | 182 | $errors = array_merge($errors, $client->getErrors($result)); |
| 183 | 183 | if (count($errors)) { |
| 184 | - Injector::inst()->get(LoggerInterface::class)->error('setItemCategoriesURL errors - ' . json_encode($errors)); |
|
| 184 | + Injector::inst()->get(LoggerInterface::class)->error('setItemCategoriesURL errors - '.json_encode($errors)); |
|
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | } |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | |
| 210 | 210 | $errors = array_merge($errors, $client->getErrors($result)); |
| 211 | 211 | if (count($errors)) { |
| 212 | - Injector::inst()->get(LoggerInterface::class)->error('setItemCategories errors - ' . json_encode($errors)); |
|
| 212 | + Injector::inst()->get(LoggerInterface::class)->error('setItemCategories errors - '.json_encode($errors)); |
|
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | } |
| 235 | 235 | $errors = array_merge($errors, $client->getErrors($result)); |
| 236 | 236 | if (count($errors)) { |
| 237 | - Injector::inst()->get(LoggerInterface::class)->error('getCategory errors - ' . json_encode($errors)); |
|
| 237 | + Injector::inst()->get(LoggerInterface::class)->error('getCategory errors - '.json_encode($errors)); |
|
| 238 | 238 | } |
| 239 | 239 | } |
| 240 | 240 | } |
@@ -253,12 +253,12 @@ discard block |
||
| 253 | 253 | if ($client) { |
| 254 | 254 | if ($category = $this->getCategory($data['code'])) { |
| 255 | 255 | $result = $client->patch($category, $data); |
| 256 | - } else { |
|
| 256 | + }else { |
|
| 257 | 257 | $result = $client->post($this->getItemCategoriesURL(), $data); |
| 258 | 258 | } |
| 259 | 259 | $errors = array_merge($errors, $client->getErrors($result)); |
| 260 | 260 | if (count($errors)) { |
| 261 | - Injector::inst()->get(LoggerInterface::class)->error('putCategory errors - ' . json_encode($errors)); |
|
| 261 | + Injector::inst()->get(LoggerInterface::class)->error('putCategory errors - '.json_encode($errors)); |
|
| 262 | 262 | } |
| 263 | 263 | } |
| 264 | 264 | } |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | |
| 278 | 278 | $errors = array_merge($errors, $client->getErrors($result)); |
| 279 | 279 | if (count($errors)) { |
| 280 | - Injector::inst()->get(LoggerInterface::class)->error('deleteCategory errors - ' . json_encode($errors)); |
|
| 280 | + Injector::inst()->get(LoggerInterface::class)->error('deleteCategory errors - '.json_encode($errors)); |
|
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | 283 | } |