/**
  * standard SS method
  * @return FieldList
  */
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $self = $this;
     $this->beforeUpdateCMSFields(function ($fields) use($self) {
         foreach ($this->customFieldLabels() as $name => $label) {
             $fields->removeByName($name);
         }
         //new section
         $fieldDescriptions = $this->customDescriptionsForFields();
         $fieldLabels = $this->fieldLabels();
         $productImage = new Product_Image();
         $versionInfo = EcommerceConfigDefinitions::create();
         $fields->addFieldToTab("Root.Main", new TextField("Title", $fieldLabels["Title"]));
         $fields->addFieldsToTab("Root", array(new Tab('Pricing', new CheckboxField("ShopPricesAreTaxExclusive", $fieldLabels["ShopPricesAreTaxExclusive"]), new CheckboxField('AllowFreeProductPurchase', $fieldLabels['AllowFreeProductPurchase']), $htmlEditorField1 = new HTMLEditorField("CurrenciesExplanation", $fieldLabels["CurrenciesExplanation"])), new Tab('Products', new NumericField("NumberOfProductsPerPage", $fieldLabels["NumberOfProductsPerPage"]), new CheckboxField("ProductsAlsoInOtherGroups", $fieldLabels["ProductsAlsoInOtherGroups"]), new CheckboxField("OnlyShowProductsThatCanBePurchased", $fieldLabels["OnlyShowProductsThatCanBePurchased"]), $htmlEditorField2 = new HTMLEditorField("NotForSaleMessage", $fieldLabels["NotForSaleMessage"]), new CheckboxField("ProductsHaveWeight", $fieldLabels["ProductsHaveWeight"]), new CheckboxField("ProductsHaveModelNames", $fieldLabels["ProductsHaveModelNames"]), new CheckboxField("ProductsHaveQuantifiers", $fieldLabels["ProductsHaveQuantifiers"])), new Tab('ProductImages', new Product_ProductImageUploadField("DefaultProductImage", $fieldLabels["DefaultProductImage"], null, null, null, "default-product-image"), new ReadonlyField("DefaultThumbnailImageSize", $fieldLabels["DefaultThumbnailImageSize"], $productImage->ThumbWidth() . "px x " . $productImage->ThumbHeight() . "px "), new ReadonlyField("DefaultSmallImageSize", $fieldLabels["DefaultSmallImageSize"], $productImage->SmallWidth() . "px x " . $productImage->SmallHeight() . "px "), new ReadonlyField("DefaultContentImageSize", $fieldLabels["DefaultContentImageSize"], $productImage->ContentWidth() . "px wide"), new ReadonlyField("DefaultLargeImageSize", $fieldLabels["DefaultLargeImageSize"], $productImage->LargeWidth() . "px wide")), new Tab('AddressAndDelivery', new TextField("PostalCodeURL", $fieldLabels["PostalCodeURL"]), new TextField("PostalCodeLabel", $fieldLabels["PostalCodeLabel"]), $htmlEditorField3 = new HTMLEditorField("ShopPhysicalAddress", $fieldLabels["ShopPhysicalAddress"]), new TextField("PackingSlipTitle", $fieldLabels["PackingSlipTitle"]), $htmlEditorField4 = new HTMLEditorField("PackingSlipNote", $fieldLabels["PackingSlipNote"])), new Tab('Emails', new TextField("ReceiptEmail", $fieldLabels["ReceiptEmail"]), new UploadField("EmailLogo", $fieldLabels["EmailLogo"], null, null, null, "logos"), new TextField("InvoiceTitle", $fieldLabels["InvoiceTitle"])), new Tab('Process', $this->getOrderStepsField()), new Tab('Advanced', new HeaderField("EcommerceVersionHeading", "Version"), new LiteralField("EcommerceVersion", "<p><strong>E-commerce</strong>: " . $versionInfo->Version() . "</p>"), new LiteralField("SVNVersion", "<p><strong>SVN</strong>: " . $versionInfo->SvnVersion() . "</p>"), new LiteralField("GITVersion", "<p><strong>GIT</strong>: not available yet.</p>"), new HeaderField("ReviewHardcodedSettingsHeading", "Hard-coded settings"), new LiteralField("ReviewHardcodedSettings", "<p>\n\t\t\t\t\t\t\tYour developer has pre-set some configurations for you.  You can\n\t\t\t\t\t\t\t<a href=\"/dev/ecommerce/ecommercetaskcheckconfiguration\" data-popup=\"true\">review these settings</a>\n\t\t\t\t\t\t\tbut you will need to ask your developer to change them if they are not right.\n\t\t\t\t\t\t\tThe reason they can not be set is that changing them can potentially break your application.\n\t\t\t\t\t\t</p>"))));
         $mappingArray = Config::inst()->get("BillingAddress", "fields_to_google_geocode_conversion");
         if (is_array($mappingArray) && count($mappingArray)) {
             $mappingArray = Config::inst()->get("ShippingAddress", "fields_to_google_geocode_conversion");
             if (is_array($mappingArray) && count($mappingArray)) {
                 $fields->removeByName("PostalCodeURL");
                 $fields->removeByName("PostalCodeLabel");
             }
         }
         $htmlEditorField1->setRows(3);
         $htmlEditorField2->setRows(3);
         $htmlEditorField3->setRows(3);
         $htmlEditorField4->setRows(3);
         $fields->addFieldsToTab("Root.Main", array(new CheckboxField("UseThisOne", $fieldLabels["UseThisOne"]), new CheckboxField("ShopClosed", $fieldLabels["ShopClosed"])));
         //set cols
         if ($f = $fields->dataFieldByName("CurrenciesExplanation")) {
             $f->setRows(2);
         }
         if ($f = $fields->dataFieldByName("NotForSaleMessage")) {
             $f->setRows(2);
         }
         if ($f = $fields->dataFieldByName("ShopPhysicalAddress")) {
             $f->setRows(2);
         }
         foreach ($fields->dataFields() as $field) {
             if (isset($fieldDescriptions[$field->getName()])) {
                 if ($field instanceof CheckboxField) {
                     $field->setDescription($fieldDescriptions[$field->Name]);
                 } else {
                     $field->setRightTitle($fieldDescriptions[$field->Name]);
                 }
             }
         }
         Requirements::block('ecommerce/javascript/EcomPrintAndMail.js');
     });
     return parent::getCMSFields();
 }
 private function getAjaxDefinitions()
 {
     $definitionsObject = new EcommerceConfigDefinitions();
     $methodArray = $definitionsObject->getAjaxMethods();
     $requestor = new ArrayData(array("ID" => "[ID]", "ClassName" => "[CLASSNAME]"));
     $obj = EcommerceConfigAjax::get_one($requestor);
     foreach ($methodArray as $method => $description) {
         if ($method != "setRequestor") {
             if (strpos($method, "lassName")) {
                 $selector = "classname";
             } else {
                 $selector = "id";
             }
             $note = "\r\n\t\t\t\t\tThis variable can be used like this: <pre>&lt;div {$selector}=\"\$AJAXDefinitions." . $method . "\"&gt;&lt;/div&gt;</pre>\r\n\t\t\t\t\t<a href=\"/shoppingcart/test/\">AJAX</a> will then use this selector to put the following content: ";
             $this->definitions["Templates"]["AJAXDefinitions_{$method}"] = $note . "<br />" . $description;
             $this->configs["Templates"]["AJAXDefinitions_{$method}"] = $obj->{$method}();
             $this->defaults["Templates"]["AJAXDefinitions_{$method}"] = "";
         }
     }
 }
 /**
  * standard SS method
  * @return FieldSet
  */
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     foreach ($this->fieldLabels() as $name => $label) {
         $fields->removeByName($name);
     }
     //new section
     $fieldLabels = $this->fieldLabels();
     $versionInfo = new EcommerceConfigDefinitions();
     $fields->addFieldsToTab("Root", array(new Tab('Pricing', new CheckboxField("ShopPricesAreTaxExclusive", $fieldLabels["ShopPricesAreTaxExclusive"]), new HTMLEditorField("CurrenciesExplanation", $fieldLabels["CurrenciesExplanation"], 2, 2)), new Tab('ProductDisplay', new NumericField("NumberOfProductsPerPage", $fieldLabels["NumberOfProductsPerPage"]), new CheckboxField("OnlyShowProductsThatCanBePurchased", $fieldLabels["OnlyShowProductsThatCanBePurchased"]), new HTMLEditorField("NotForSaleMessage", $fieldLabels["NotForSaleMessage"], 2, 2), new CheckboxField("ProductsHaveWeight", $fieldLabels["ProductsHaveWeight"]), new CheckboxField("ProductsHaveModelNames", $fieldLabels["ProductsHaveModelNames"]), new CheckboxField("ProductsHaveQuantifiers", $fieldLabels["ProductsHaveQuantifiers"]), new CheckboxField("ProductsAlsoInOtherGroups", $fieldLabels["ProductsAlsoInOtherGroups"]), new CheckboxField("ProductsHaveVariations", $fieldLabels["ProductsHaveVariations"]), new ImageField("DefaultProductImage", $fieldLabels["DefaultProductImage"], null, null, null, "default-product-image")), new Tab('Checkout', new TextField("PostalCodeURL", $fieldLabels["PostalCodeURL"]), new TextField("PostalCodeLabel", $fieldLabels["PostalCodeLabel"])), new Tab('Emails', new TextField("ReceiptEmail", $fieldLabels["ReceiptEmail"]), new ImageField("EmailLogo", $fieldLabels["EmailLogo"], null, null, null, "logos")), new Tab('Invoice', new TextField("InvoiceTitle", $fieldLabels["InvoiceTitle"]), new HTMLEditorField("ShopPhysicalAddress", $fieldLabels["ShopPhysicalAddress"], 5, 5)), new Tab('Process', new ComplexTableField($this, "OrderSteps", "OrderStep")), new Tab('Advanced', new HeaderField("EcommerceVersionHeading", "Version"), new LiteralField("EcommerceVersion", "<p><strong>E-commerce</strong>: " . $versionInfo->Version() . "</p>"), new LiteralField("SVNVersion", "<p><strong>SVN</strong>: " . $versionInfo->SvnVersion() . "</p>"), new LiteralField("GITVersion", "<p><strong>GIT</strong>: not available yet.</p>"), new HeaderField("ReviewHardcodedSettingsHeading", "Hard-coded settings"), new LiteralField("ReviewHardcodedSettings", "<p>\n\t\t\t\t\t\tYour developer has pre-set some configurations for you.  You can\n\t\t\t\t\t\t<a href=\"/dev/ecommerce/ecommercecheckconfiguration\" target=\"_blank\">review these settings</a>\n\t\t\t\t\t\tbut you will need to ask your developer to change them if they are not right.\n\t\t\t\t\t\tThe reason they can not be set is that changing them can potentially break your application.\n\t\t\t\t\t</p>"))));
     $fields->addFieldsToTab("Root.Main", array(new CheckboxField("UseThisOne", $fieldLabels["UseThisOne"]), new CheckboxField("ShopClosed", $fieldLabels["ShopClosed"])));
     return $fields;
 }