public function updateCMSFields(FieldList $fields)
 {
     // set TabSet names to avoid spaces from camel case
     $fields->addFieldToTab('Root', new TabSet('FoxyStripe', 'FoxyStripe'));
     // settings tab
     $fields->addFieldsToTab('Root.FoxyStripe.Settings', array(HeaderField::create('StoreDetails', _t('FoxyStripeSiteConfig.StoreDetails', 'Store Settings'), 3), LiteralField::create('DetailsIntro', _t('FoxyStripeSiteConfig.DetailsIntro', '<p>Maps to data in your <a href="https://admin.foxycart.com/admin.php?ThisAction=EditStore" target="_blank">FoxyCart store settings</a>.')), TextField::create('StoreName')->setTitle(_t('FoxyStripeSiteConfig.StoreName', 'Store Sub Domain'))->setDescription(_t('FoxyStripeSiteConfig.StoreNameDescription', 'the sub domain for your FoxyCart store')), HeaderField::create('AdvanceHeader', _t('FoxyStripeSiteConfig.AdvancedHeader', 'Advanced Settings'), 3), LiteralField::create('AdvancedIntro', _t('FoxyStripeSiteConfig.AdvancedIntro', '<p>Maps to data in your <a href="https://admin.foxycart.com/admin.php?ThisAction=EditAdvancedFeatures" target="_blank">FoxyCart advanced store settings</a>.</p>')), ReadonlyField::create('DataFeedLink', _t('FoxyStripeSiteConfig.DataFeedLink', 'FoxyCart DataFeed URL'), self::getDataFeedLink())->setDescription(_t('FoxyStripeSiteConfig.DataFeedLinkDescription', 'copy/paste to FoxyCart')), CheckboxField::create('CartValidation')->setTitle(_t('FoxyStripeSiteConfig.CartValidation', 'Enable Cart Validation'))->setDescription(_t('FoxyStripeSiteConfig.CartValidationDescription', '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.')), ReadonlyField::create('StoreKey')->setTitle(_t('FoxyStripeSiteConfig.StoreKey', 'FoxyCart API Key'))->setDescription(_t('FoxyStripeSiteConfig.StoreKeyDescription', 'copy/paste to FoxyCart')), ReadonlyField::create('SSOLink', _t('FoxyStripeSiteConfig.SSOLink', 'Single Sign On URL'), self::getSSOLink())->setDescription(_t('FoxyStripeSiteConfig.SSOLinkDescription', 'copy/paste to FoxyCart'))));
     // configuration warning
     if (FoxyCart::store_name_warning() !== null) {
         $fields->insertBefore(LiteralField::create("StoreSubDomainHeaderWarning", _t('FoxyStripeSiteConfig.StoreSubDomainHeadingWarning', "<p class=\"message error\">Store sub-domain must be entered in the <a href=\"/admin/settings/\">site settings</a></p>")), 'StoreDetails');
     }
     // products tab
     $fields->addFieldsToTab('Root.FoxyStripe.Products', array(HeaderField::create('ProductHeader', _t('FoxyStripeSiteConfig.ProductHeader', 'Products'), 3), CheckboxField::create('MultiGroup')->setTitle(_t('FoxyStripeSiteConfig.MultiGroup', 'Multiple Groups'))->setDescription(_t('FoxyStripeSiteConfig.MultiGroupDescription', 'Allows products to be shown in multiple Product Groups')), HeaderField::create('ProductGroupHD', _t('FoxyStripeSiteConfig.ProductGroupHD', 'Product Groups'), 3), NumericField::create('ProductLimit')->setTitle(_t('FoxyStripeSiteConfig.ProductLimit', 'Products per Page'))->setDescription(_t('FoxyStripeSiteConfig.ProductLimitDescription', 'Number of Products to show per page on a Product Group')), HeaderField::create('ProductQuantityHD', _t('FoxyStripeSiteConfig.ProductQuantityHD', 'Product Form Max Quantity'), 3), NumericField::create('MaxQuantity')->setTitle(_t('FoxyStripeSiteConfig.MaxQuantity', 'Max Quantity'))->setDescription(_t('FoxyStripeSiteConfig.MaxQuantityDescription', 'Sets max quantity for product form dropdown (add to cart form - default 10)'))));
     // categories tab
     $fields->addFieldsToTab('Root.FoxyStripe.Categories', array(HeaderField::create('CategoryHD', _t('FoxyStripeSiteConfig.CategoryHD', 'FoxyStripe Categories'), 3), LiteralField::create('CategoryDescrip', _t('FoxyStripeSiteConfig.CategoryDescrip', '<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>')), GridField::create('ProductCategory', _t('FoxyStripeSiteConfig.ProductCategory', 'FoxyCart Categories'), ProductCategory::get(), GridFieldConfig_RecordEditor::create())));
     // option groups tab
     $fields->addFieldsToTab('Root.FoxyStripe.Groups', array(HeaderField::create('OptionGroupsHead', _t('FoxyStripeSiteConfig', 'Product Option Groups'), 3), LiteralField::create('OptionGroupsDescrip', _t('FoxyStripeSiteConfig.OptionGroupsDescrip', '<p>Product Option Groups allow you to name a set of product options.</p>')), GridField::create('OptionGroup', _t('FoxyStripeSiteConfig.OptionGroup', 'Product Option Groups'), OptionGroup::get(), GridFieldConfig_RecordEditor::create())));
 }
Exemplo n.º 2
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     // allow extensions of ProductPage to override the PreviewImage field description
     $previewDescription = $this->stat('customPreviewDescription') ? $this->stat('customPreviewDescription') : _t('ProductPage.PreviewImageDescription', 'Image used throughout site to represent this product');
     // Cateogry Dropdown field w/ add new
     $source = function () {
         return ProductCategory::get()->map()->toArray();
     };
     $catField = DropdownField::create('CategoryID', _t('ProductPage.Category', 'FoxyCart Category'), $source())->setEmptyString('')->setDescription(_t('ProductPage.CategoryDescription', 'Required, must also exist in
                 <a href="https://admin.foxycart.com/admin.php?ThisAction=ManageProductCategories" target="_blank">
                     FoxyCart Categories
                 </a>.
                 Used to set category specific options like shipping and taxes. Managed in
                     <a href="admin/settings">
                         Settings > FoxyStripe > Categories
                     </a>'));
     if (class_exists('QuickAddNewExtension')) {
         $catField->useAddNew('ProductCategory', $source);
     }
     // Product Images gridfield
     $config = GridFieldConfig_RelationEditor::create();
     if (class_exists('GridFieldSortableRows')) {
         $config->addComponent(new GridFieldSortableRows('SortOrder'));
     }
     if (class_exists('GridFieldBulkImageUpload')) {
         $config->addComponent(new GridFieldBulkUpload());
         $config->getComponentByType('GridFieldBulkUpload')->setUfConfig('folderName', 'Uploads/ProductImages');
     }
     $prodImagesField = GridField::create('ProductImages', _t('ProductPage.ProductImages', 'Images'), $this->ProductImages(), $config);
     // Product Options field
     $config = GridFieldConfig_RelationEditor::create();
     if (class_exists('GridFieldBulkManager')) {
         $config->addComponent(new GridFieldBulkManager());
     }
     if (class_exists('GridFieldSortableRows')) {
         $config->addComponent(new GridFieldSortableRows('SortOrder'));
         $products = $this->ProductOptions()->sort('SortOrder');
     } else {
         $products = $this->ProductOptions();
     }
     $config->removeComponentsByType('GridFieldAddExistingAutocompleter');
     $prodOptField = GridField::create('ProductOptions', _t('ProductPage.ProductOptions', 'Options'), $products, $config);
     // Details tab
     $fields->addFieldsToTab('Root.Details', array(HeaderField::create('DetailHD', 'Product Details', 2), CheckboxField::create('Available')->setTitle(_t('ProductPage.Available', 'Available for purchase'))->setDescription(_t('ProductPage.AvailableDescription', 'If unchecked, will remove "Add to Cart" form and instead display "Currently unavailable"')), TextField::create('Code')->setTitle(_t('ProductPage.Code', 'Product Code'))->setDescription(_t('ProductPage.CodeDescription', 'Required, must be unique. Product identifier used by FoxyCart in transactions')), $catField, CurrencyField::create('Price')->setTitle(_t('ProductPage.Price', 'Price'))->setDescription(_t('ProductPage.PriceDescription', 'Base price for this product. Can be modified using Product Options')), NumericField::create('Weight')->setTitle(_t('ProductPage.Weight', 'Weight'))->setDescription(_t('ProductPage.WeightDescription', 'Base weight for this product in lbs. Can be modified using Product Options')), CheckboxField::create('Featured')->setTitle(_t('ProductPage.Featured', 'Featured Product')), TextField::create('ReceiptTitle')->setTitle(_t('ProductPage.ReceiptTitle', 'Product Title for Receipt'))->setDescription(_t('ProductPage.ReceiptTitleDescription', 'Optional'))));
     // Images tab
     $fields->addFieldsToTab('Root.Images', array(HeaderField::create('MainImageHD', _t('ProductPage.MainImageHD', 'Product Image'), 2), UploadField::create('PreviewImage', '')->setDescription($previewDescription)->setFolderName('Uploads/Products')->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'))->setAllowedMaxFileNumber(1), HeaderField::create('ProductImagesHD', _t('ProductPage.ProductImagesHD' . 'Product Image Gallery'), 2), $prodImagesField->setDescription(_t('ProductPage.ProductImagesDescription', 'Additional Product Images, shown in gallery on Product page'))));
     // Options Tab
     $fields->addFieldsToTab('Root.Options', array(HeaderField::create('OptionsHD', _t('ProductPage.OptionsHD', 'Product Options'), 2), LiteralField::create('OptionsDescrip', _t('Page.OptionsDescrip', '<p>Product Options allow products to be customized by attributes such as size or color.
                 Options can also modify the product\'s price, weight or code.</p>')), $prodOptField));
     if (!$this->DiscountTitle && $this->ProductDiscountTiers()->exists()) {
         $fields->addFieldTotab('Root.Discounts', new LiteralField("ProductDiscountHeaderWarning", "<p class=\"message warning\">A discount title is required for FoxyCart to properly parse the value. The discounts will not be applied until a title is entered.</p>"));
     }
     $fields->addFieldToTab('Root.Discounts', TextField::create('DiscountTitle')->setTitle(_t('Product.DiscountTitle', 'Discount Title')));
     $discountsConfig = GridFieldConfig_RelationEditor::create();
     $discountsConfig->removeComponentsByType('GridFieldAddExistingAutocompleter');
     $discountsConfig->removeComponentsByType('GridFieldDeleteAction');
     $discountsConfig->addComponent(new GridFieldDeleteAction(false));
     $discountGrid = GridField::create('ProductDiscountTiers', 'Product Discounts', $this->ProductDiscountTiers(), $discountsConfig);
     $fields->addFieldToTab('Root.Discounts', $discountGrid);
     if (FoxyCart::store_name_warning() !== null) {
         $fields->addFieldToTab('Root.Main', LiteralField::create("StoreSubDomainHeaderWarning", _t('ProductPage.StoreSubDomainHeaderWarning', "<p class=\"message error\">Store sub-domain must be entered in the <a href=\"/admin/settings/\">site settings</a></p>")), 'Title');
     }
     // allows CMS fields to be extended
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }