diff --git a/src/Model/OptionItem.php b/src/Model/OptionItem.php
index 9e708ed..60c2855 100755
--- a/src/Model/OptionItem.php
+++ b/src/Model/OptionItem.php
@@ -40,6 +40,16 @@
*/
class OptionItem extends DataObject
{
+ /**
+ * @var string
+ */
+ private static $singular_name = 'Product Option';
+
+ /**
+ * @var string
+ */
+ private static $plural_name = 'Product Options';
+
/**
* @var array
*/
@@ -145,8 +155,8 @@ public function getCMSFields()
->setEmptyString('')
->setDescription(_t(
'OptionItem.GroupDescription',
- 'Name of this group of options. Managed in
- Settings > FoxyStripe > Option Groups
+ 'Name of this group of options. Managed in
+ FoxyStripe > Option Groups
'
));
if (class_exists('QuickAddNewExtension')) {
diff --git a/src/Page/ProductPage.php b/src/Page/ProductPage.php
index 15b25e9..79d89cf 100644
--- a/src/Page/ProductPage.php
+++ b/src/Page/ProductPage.php
@@ -147,15 +147,6 @@ class ProductPage extends \Page implements PermissionProvider
],
];
- /**
- * @var array
- */
- private static $defaults = [
- 'ShowInMenus' => false,
- 'Available' => true,
- 'Weight' => '0.0',
- ];
-
/**
* @var array
*/
@@ -182,6 +173,27 @@ class ProductPage extends \Page implements PermissionProvider
*/
private static $table_name = 'ProductPage';
+ /**
+ * @var array
+ */
+ private static $defaults = [
+ 'ShowInMenus' => false,
+ 'Available' => true,
+ 'Weight' => '0.0',
+ ];
+
+ /**
+ * @return \SilverStripe\ORM\DataObject|void
+ */
+ public function populateDefaults()
+ {
+ if ($cat = ProductCategory::get()->filter('Code', 'DEFAULT')->first()) {
+ $this->CategoryID = $cat->ID;
+ }
+
+ parent::populateDefaults();
+ }
+
/**
* Construct a new ProductPage.
*
@@ -211,7 +223,7 @@ public function fieldLabels($includerelations = true)
{
$labels = parent::fieldLabels();
- $labels['Title'] = _t('ProductPage.TitleLabel', 'Name');
+ $labels['Title'] = _t('ProductPage.TitleLabel', 'Product Name');
$labels['Code'] = _t('ProductPage.CodeLabel', 'Code');
$labels['Price.Nice'] = _t('ProductPage.PriceLabel', 'Price');
$labels['Available.Nice'] = _t('ProductPage.AvailableLabel', 'Available');
@@ -228,27 +240,6 @@ public function fieldLabels($includerelations = true)
public function getCMSFields()
{
$this->beforeUpdateCMSFields(function (FieldList $fields) {
- // 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
-
- FoxyCart Categories
- .
- Used to set category specific options like shipping and taxes. Managed in
-
- Settings > FoxyStripe > Categories
- '
- ));
- if (class_exists('QuickAddNewExtension')) {
- $catField->useAddNew('ProductCategory', $source);
- }
-
$fields->addFieldsToTab(
'Root.Main',
[
@@ -271,7 +262,22 @@ public function getCMSFields()
'Base weight for this product in lbs. Can be modified using Product Options'
))
->setScale(2),
- $catField,
+ DropdownField::create(
+ 'CategoryID',
+ _t('ProductPage.Category', 'Product Category'),
+ ProductCategory::get()->map()->toArray()
+ )
+ ->setDescription(_t(
+ 'ProductPage.CategoryDescription',
+ 'Required, must also exist in
+
+ FoxyCart Categories
+ .
+ Used to set category specific options like shipping and taxes. Managed in
+
+ FoxyStripe > Categories
+ '
+ )),
],
'Content'
);
@@ -334,7 +340,11 @@ public function getCMSFields()
}
});
- return parent::getCMSFields();
+ $fields = parent::getCMSFields();
+
+ $fields->dataFieldByName('Content')->setTitle('Description');
+
+ return $fields;
}
/**
@@ -342,7 +352,7 @@ public function getCMSFields()
*/
public function getCMSValidator()
{
- return new RequiredFields(['CategoryID', 'Price', 'Weight', 'Code']);
+ return new RequiredFields(['CategoryID', 'Price', 'Code']);
}
/**