@@ -21,38 +21,38 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class SiteConfigMigration extends DataExtension |
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * @var array |
|
| 26 | - */ |
|
| 27 | - private static $db = array( |
|
| 28 | - 'StoreName' => 'Varchar(255)', |
|
| 29 | - 'StoreKey' => 'Varchar(60)', |
|
| 30 | - 'MultiGroup' => 'Boolean', |
|
| 31 | - 'ProductLimit' => 'Int', |
|
| 32 | - 'CartValidation' => 'Boolean', |
|
| 33 | - 'MaxQuantity' => 'Int', |
|
| 34 | - 'CustomSSL' => 'Boolean', |
|
| 35 | - 'RemoteDomain' => 'Varchar(255)', |
|
| 36 | - ); |
|
| 24 | + /** |
|
| 25 | + * @var array |
|
| 26 | + */ |
|
| 27 | + private static $db = array( |
|
| 28 | + 'StoreName' => 'Varchar(255)', |
|
| 29 | + 'StoreKey' => 'Varchar(60)', |
|
| 30 | + 'MultiGroup' => 'Boolean', |
|
| 31 | + 'ProductLimit' => 'Int', |
|
| 32 | + 'CartValidation' => 'Boolean', |
|
| 33 | + 'MaxQuantity' => 'Int', |
|
| 34 | + 'CustomSSL' => 'Boolean', |
|
| 35 | + 'RemoteDomain' => 'Varchar(255)', |
|
| 36 | + ); |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * |
|
| 40 | - */ |
|
| 41 | - public function onAfterWrite() |
|
| 42 | - { |
|
| 43 | - parent::onAfterWrite(); |
|
| 38 | + /** |
|
| 39 | + * |
|
| 40 | + */ |
|
| 41 | + public function onAfterWrite() |
|
| 42 | + { |
|
| 43 | + parent::onAfterWrite(); |
|
| 44 | 44 | |
| 45 | - $config = FoxyStripeSetting::current_foxystripe_setting(); |
|
| 45 | + $config = FoxyStripeSetting::current_foxystripe_setting(); |
|
| 46 | 46 | |
| 47 | - $config->StoreName = $this->owner->StoreName; |
|
| 48 | - $config->StoreKey = $this->owner->StoreKey; |
|
| 49 | - $config->MultiGroup = $this->owner->MultiGroup; |
|
| 50 | - $config->ProductLimit = $this->owner->ProductLimit; |
|
| 51 | - $config->CartValidation = $this->owner->CartValidation; |
|
| 52 | - $config->MaxQuantity = $this->owner->MaxQuantity; |
|
| 53 | - $config->CustomSSL = $this->owner->CustomSSL; |
|
| 54 | - $config->RemoteDomain = $this->owner->RemoteDomain; |
|
| 47 | + $config->StoreName = $this->owner->StoreName; |
|
| 48 | + $config->StoreKey = $this->owner->StoreKey; |
|
| 49 | + $config->MultiGroup = $this->owner->MultiGroup; |
|
| 50 | + $config->ProductLimit = $this->owner->ProductLimit; |
|
| 51 | + $config->CartValidation = $this->owner->CartValidation; |
|
| 52 | + $config->MaxQuantity = $this->owner->MaxQuantity; |
|
| 53 | + $config->CustomSSL = $this->owner->CustomSSL; |
|
| 54 | + $config->RemoteDomain = $this->owner->RemoteDomain; |
|
| 55 | 55 | |
| 56 | - $config->write(); |
|
| 57 | - } |
|
| 56 | + $config->write(); |
|
| 57 | + } |
|
| 58 | 58 | } |
@@ -54,46 +54,46 @@ |
||
| 54 | 54 | */ |
| 55 | 55 | class FoxyStripeDropdownField extends DropdownField |
| 56 | 56 | { |
| 57 | - /** |
|
| 58 | - * Mark certain elements as disabled, |
|
| 59 | - * regardless of the {@link setDisabled()} settings. |
|
| 60 | - * |
|
| 61 | - * @param array $items Collection of array keys, as defined in the $source array |
|
| 62 | - * |
|
| 63 | - * @return $this |
|
| 64 | - */ |
|
| 65 | - public function setDisabledItems($items) |
|
| 66 | - { |
|
| 67 | - $controller = Controller::curr(); |
|
| 68 | - $code = $controller->data()->Code; |
|
| 69 | - $updated = []; |
|
| 70 | - if (is_array($items) && !empty($items)) { |
|
| 71 | - foreach ($items as $item) { |
|
| 72 | - array_push($updated, ProductPage::getGeneratedValue($code, $this->getName(), $item, 'value')); |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - $this->disabledItems = $updated; |
|
| 57 | + /** |
|
| 58 | + * Mark certain elements as disabled, |
|
| 59 | + * regardless of the {@link setDisabled()} settings. |
|
| 60 | + * |
|
| 61 | + * @param array $items Collection of array keys, as defined in the $source array |
|
| 62 | + * |
|
| 63 | + * @return $this |
|
| 64 | + */ |
|
| 65 | + public function setDisabledItems($items) |
|
| 66 | + { |
|
| 67 | + $controller = Controller::curr(); |
|
| 68 | + $code = $controller->data()->Code; |
|
| 69 | + $updated = []; |
|
| 70 | + if (is_array($items) && !empty($items)) { |
|
| 71 | + foreach ($items as $item) { |
|
| 72 | + array_push($updated, ProductPage::getGeneratedValue($code, $this->getName(), $item, 'value')); |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + $this->disabledItems = $updated; |
|
| 76 | 76 | |
| 77 | - return $this; |
|
| 78 | - } |
|
| 77 | + return $this; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * @param mixed $source |
|
| 82 | - * |
|
| 83 | - * @return $this |
|
| 84 | - */ |
|
| 85 | - public function setSource($source) |
|
| 86 | - { |
|
| 87 | - $controller = Controller::curr(); |
|
| 88 | - $code = $controller->data()->Code; |
|
| 89 | - $updated = []; |
|
| 90 | - if (is_array($source) && !empty($source)) { |
|
| 91 | - foreach ($source as $key => $val) { |
|
| 92 | - $updated[ProductPage::getGeneratedValue($code, $this->getName(), $key, 'value')] = $val; |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - $this->source = $updated; |
|
| 80 | + /** |
|
| 81 | + * @param mixed $source |
|
| 82 | + * |
|
| 83 | + * @return $this |
|
| 84 | + */ |
|
| 85 | + public function setSource($source) |
|
| 86 | + { |
|
| 87 | + $controller = Controller::curr(); |
|
| 88 | + $code = $controller->data()->Code; |
|
| 89 | + $updated = []; |
|
| 90 | + if (is_array($source) && !empty($source)) { |
|
| 91 | + foreach ($source as $key => $val) { |
|
| 92 | + $updated[ProductPage::getGeneratedValue($code, $this->getName(), $key, 'value')] = $val; |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + $this->source = $updated; |
|
| 96 | 96 | |
| 97 | - return $this; |
|
| 98 | - } |
|
| 97 | + return $this; |
|
| 98 | + } |
|
| 99 | 99 | } |
@@ -15,60 +15,60 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class QuantityField extends NumericField |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * @var array |
|
| 20 | - */ |
|
| 21 | - private static $allowed_actions = [ |
|
| 22 | - 'newvalue', |
|
| 23 | - ]; |
|
| 18 | + /** |
|
| 19 | + * @var array |
|
| 20 | + */ |
|
| 21 | + private static $allowed_actions = [ |
|
| 22 | + 'newvalue', |
|
| 23 | + ]; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @param array $properties |
|
| 27 | - * @return string |
|
| 28 | - */ |
|
| 29 | - public function Field($properties = []) |
|
| 30 | - { |
|
| 31 | - //Requirements::javascript('dynamic/foxystripe: javascript/quantity.js'); |
|
| 32 | - //Requirements::css('dynamic/foxystripe: client/dist/css/quantityfield.css'); |
|
| 25 | + /** |
|
| 26 | + * @param array $properties |
|
| 27 | + * @return string |
|
| 28 | + */ |
|
| 29 | + public function Field($properties = []) |
|
| 30 | + { |
|
| 31 | + //Requirements::javascript('dynamic/foxystripe: javascript/quantity.js'); |
|
| 32 | + //Requirements::css('dynamic/foxystripe: client/dist/css/quantityfield.css'); |
|
| 33 | 33 | |
| 34 | 34 | |
| 35 | - $this->setAttribute('data-link', $this->Link('newvalue')); |
|
| 36 | - $this->setAttribute('data-code', $this->getProduct()->Code); |
|
| 37 | - $this->setAttribute('data-id', $this->getProduct()->ID); |
|
| 35 | + $this->setAttribute('data-link', $this->Link('newvalue')); |
|
| 36 | + $this->setAttribute('data-code', $this->getProduct()->Code); |
|
| 37 | + $this->setAttribute('data-id', $this->getProduct()->ID); |
|
| 38 | 38 | |
| 39 | - return parent::Field($properties); |
|
| 40 | - } |
|
| 39 | + return parent::Field($properties); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @return ProductPage |
|
| 44 | - */ |
|
| 45 | - public function getProduct() |
|
| 46 | - { |
|
| 47 | - return $this->getForm()->getProduct(); |
|
| 48 | - } |
|
| 42 | + /** |
|
| 43 | + * @return ProductPage |
|
| 44 | + */ |
|
| 45 | + public function getProduct() |
|
| 46 | + { |
|
| 47 | + return $this->getForm()->getProduct(); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @param SS_HTTPRequest $request |
|
| 52 | - * @return bool|string |
|
| 53 | - */ |
|
| 54 | - public function newvalue(HTTPRequest $request) |
|
| 55 | - { |
|
| 56 | - if (!$value = $request->getVar('value')) { |
|
| 57 | - return ''; |
|
| 58 | - } |
|
| 50 | + /** |
|
| 51 | + * @param SS_HTTPRequest $request |
|
| 52 | + * @return bool|string |
|
| 53 | + */ |
|
| 54 | + public function newvalue(HTTPRequest $request) |
|
| 55 | + { |
|
| 56 | + if (!$value = $request->getVar('value')) { |
|
| 57 | + return ''; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - if (!$code = $request->getVar('code')) { |
|
| 61 | - return ''; |
|
| 62 | - } |
|
| 60 | + if (!$code = $request->getVar('code')) { |
|
| 61 | + return ''; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - $this->extend('updateQuantity', $value); |
|
| 64 | + $this->extend('updateQuantity', $value); |
|
| 65 | 65 | |
| 66 | - $data = array( |
|
| 67 | - 'quantity' => $value, |
|
| 68 | - 'quantityGenerated' => ProductPage::getGeneratedValue($code, 'quantity', $value, 'value'), |
|
| 69 | - ); |
|
| 66 | + $data = array( |
|
| 67 | + 'quantity' => $value, |
|
| 68 | + 'quantityGenerated' => ProductPage::getGeneratedValue($code, 'quantity', $value, 'value'), |
|
| 69 | + ); |
|
| 70 | 70 | |
| 71 | - $this->extend('updateData', $data); |
|
| 72 | - return json_encode($data); |
|
| 73 | - } |
|
| 71 | + $this->extend('updateData', $data); |
|
| 72 | + return json_encode($data); |
|
| 73 | + } |
|
| 74 | 74 | } |
@@ -17,77 +17,77 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class DonationProductController extends ProductPageController |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * @var array |
|
| 22 | - */ |
|
| 23 | - private static $allowed_actions = [ |
|
| 24 | - 'PurchaseForm', |
|
| 25 | - 'updatevalue', |
|
| 26 | - ]; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * |
|
| 30 | - */ |
|
| 31 | - public function init() |
|
| 32 | - { |
|
| 33 | - parent::init(); |
|
| 34 | - //Requirements::javascript('framework/thirdparty/jquery/jquery.js'); |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * @return FoxyStripePurchaseForm |
|
| 39 | - */ |
|
| 40 | - public function PurchaseForm() |
|
| 41 | - { |
|
| 42 | - $form = parent::PurchaseForm(); |
|
| 43 | - |
|
| 44 | - $fields = $form->Fields(); |
|
| 45 | - |
|
| 46 | - $fields->dataFieldByName('price') |
|
| 47 | - ->setAttribute('id', 'price'); |
|
| 48 | - |
|
| 49 | - $fields->insertAfter('price', $currencyField = CurrencyField::create('x:visiblePrice', 'Amount')); |
|
| 50 | - |
|
| 51 | - $currencyField->setAttribute('id', 'visiblePrice'); |
|
| 52 | - |
|
| 53 | - $fields->removeByName([ |
|
| 54 | - 'x:visibleQuantity', |
|
| 55 | - ProductPage::getGeneratedValue($this->Code, 'weight', $this->Weight), |
|
| 56 | - ]); |
|
| 57 | - |
|
| 58 | - if (FoxyStripeSetting::current_foxystripe_setting()->CartValidation) { |
|
| 59 | - Requirements::javascript("silverstripe/userforms:client/dist/js/jquery-validation/jquery.validate.min.js"); |
|
| 60 | - Requirements::javascriptTemplate('_resources/vendor/dynamic/foxystripe/javascript/donationProduct.js', [ |
|
| 61 | - 'Trigger' => (string)$currencyField->getAttribute('id'), |
|
| 62 | - 'UpdateURL' => Director::absoluteURL($this->Link('updatevalue')), |
|
| 63 | - ]); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - $form->setAttribute('data-updateurl', $this->Link('updatevalue')); |
|
| 67 | - |
|
| 68 | - return $form; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * create new encrypted price value based on user input. |
|
| 73 | - * |
|
| 74 | - * @param $request |
|
| 75 | - * |
|
| 76 | - * @return string|\SilverStripe\Control\HTTPResponse |
|
| 77 | - */ |
|
| 78 | - public function updatevalue(\SilverStripe\Control\HTTPRequest $request) |
|
| 79 | - { |
|
| 80 | - if ($request->getVar('Price') && FoxyStripeSetting::current_foxystripe_setting()->CartValidation) { |
|
| 81 | - $price = $request->getVar('Price'); |
|
| 82 | - $signedPrice = \FoxyCart_Helper::fc_hash_value($this->Code, 'price', $price, 'value', false); |
|
| 83 | - $json = json_encode(['Price' => $signedPrice]); |
|
| 84 | - |
|
| 85 | - $this->response->setBody($json); |
|
| 86 | - $this->response->addHeader('Content-Type', 'application/json'); |
|
| 87 | - |
|
| 88 | - return $this->response; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - return 'false'; |
|
| 92 | - } |
|
| 20 | + /** |
|
| 21 | + * @var array |
|
| 22 | + */ |
|
| 23 | + private static $allowed_actions = [ |
|
| 24 | + 'PurchaseForm', |
|
| 25 | + 'updatevalue', |
|
| 26 | + ]; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * |
|
| 30 | + */ |
|
| 31 | + public function init() |
|
| 32 | + { |
|
| 33 | + parent::init(); |
|
| 34 | + //Requirements::javascript('framework/thirdparty/jquery/jquery.js'); |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * @return FoxyStripePurchaseForm |
|
| 39 | + */ |
|
| 40 | + public function PurchaseForm() |
|
| 41 | + { |
|
| 42 | + $form = parent::PurchaseForm(); |
|
| 43 | + |
|
| 44 | + $fields = $form->Fields(); |
|
| 45 | + |
|
| 46 | + $fields->dataFieldByName('price') |
|
| 47 | + ->setAttribute('id', 'price'); |
|
| 48 | + |
|
| 49 | + $fields->insertAfter('price', $currencyField = CurrencyField::create('x:visiblePrice', 'Amount')); |
|
| 50 | + |
|
| 51 | + $currencyField->setAttribute('id', 'visiblePrice'); |
|
| 52 | + |
|
| 53 | + $fields->removeByName([ |
|
| 54 | + 'x:visibleQuantity', |
|
| 55 | + ProductPage::getGeneratedValue($this->Code, 'weight', $this->Weight), |
|
| 56 | + ]); |
|
| 57 | + |
|
| 58 | + if (FoxyStripeSetting::current_foxystripe_setting()->CartValidation) { |
|
| 59 | + Requirements::javascript("silverstripe/userforms:client/dist/js/jquery-validation/jquery.validate.min.js"); |
|
| 60 | + Requirements::javascriptTemplate('_resources/vendor/dynamic/foxystripe/javascript/donationProduct.js', [ |
|
| 61 | + 'Trigger' => (string)$currencyField->getAttribute('id'), |
|
| 62 | + 'UpdateURL' => Director::absoluteURL($this->Link('updatevalue')), |
|
| 63 | + ]); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + $form->setAttribute('data-updateurl', $this->Link('updatevalue')); |
|
| 67 | + |
|
| 68 | + return $form; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * create new encrypted price value based on user input. |
|
| 73 | + * |
|
| 74 | + * @param $request |
|
| 75 | + * |
|
| 76 | + * @return string|\SilverStripe\Control\HTTPResponse |
|
| 77 | + */ |
|
| 78 | + public function updatevalue(\SilverStripe\Control\HTTPRequest $request) |
|
| 79 | + { |
|
| 80 | + if ($request->getVar('Price') && FoxyStripeSetting::current_foxystripe_setting()->CartValidation) { |
|
| 81 | + $price = $request->getVar('Price'); |
|
| 82 | + $signedPrice = \FoxyCart_Helper::fc_hash_value($this->Code, 'price', $price, 'value', false); |
|
| 83 | + $json = json_encode(['Price' => $signedPrice]); |
|
| 84 | + |
|
| 85 | + $this->response->setBody($json); |
|
| 86 | + $this->response->addHeader('Content-Type', 'application/json'); |
|
| 87 | + |
|
| 88 | + return $this->response; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + return 'false'; |
|
| 92 | + } |
|
| 93 | 93 | } |
@@ -13,41 +13,41 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class ProductPageController extends \PageController |
| 15 | 15 | { |
| 16 | - private static $allowed_actions = array( |
|
| 17 | - 'PurchaseForm', |
|
| 18 | - ); |
|
| 19 | - |
|
| 20 | - public function init() |
|
| 21 | - { |
|
| 22 | - parent::init(); |
|
| 23 | - Requirements::javascript('silverstripe/admin: thirdparty/jquery/jquery.js'); |
|
| 24 | - if ($this->data()->Available && $this->ProductOptions()->exists()) { |
|
| 25 | - $formName = $this->PurchaseForm()->FormName(); |
|
| 26 | - /*Requirements::javascriptTemplate( |
|
| 16 | + private static $allowed_actions = array( |
|
| 17 | + 'PurchaseForm', |
|
| 18 | + ); |
|
| 19 | + |
|
| 20 | + public function init() |
|
| 21 | + { |
|
| 22 | + parent::init(); |
|
| 23 | + Requirements::javascript('silverstripe/admin: thirdparty/jquery/jquery.js'); |
|
| 24 | + if ($this->data()->Available && $this->ProductOptions()->exists()) { |
|
| 25 | + $formName = $this->PurchaseForm()->FormName(); |
|
| 26 | + /*Requirements::javascriptTemplate( |
|
| 27 | 27 | 'dynamic/foxystripe: javascript/out_of_stock.js', |
| 28 | 28 | [ |
| 29 | 29 | 'FormName' => $formName, |
| 30 | 30 | ], |
| 31 | 31 | 'foxystripe.out_of_stock' |
| 32 | 32 | );*/ |
| 33 | - Requirements::javascript('dynamic/foxystripe: javascript/product_options.js'); |
|
| 34 | - } |
|
| 33 | + Requirements::javascript('dynamic/foxystripe: javascript/product_options.js'); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - Requirements::customScript(<<<JS |
|
| 36 | + Requirements::customScript(<<<JS |
|
| 37 | 37 | var productID = {$this->data()->ID}; |
| 38 | 38 | JS |
| 39 | - ); |
|
| 40 | - } |
|
| 39 | + ); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @return FoxyStripePurchaseForm |
|
| 44 | - */ |
|
| 45 | - public function PurchaseForm() |
|
| 46 | - { |
|
| 47 | - $form = FoxyStripePurchaseForm::create($this, __FUNCTION__, null, null, null, $this->data()); |
|
| 42 | + /** |
|
| 43 | + * @return FoxyStripePurchaseForm |
|
| 44 | + */ |
|
| 45 | + public function PurchaseForm() |
|
| 46 | + { |
|
| 47 | + $form = FoxyStripePurchaseForm::create($this, __FUNCTION__, null, null, null, $this->data()); |
|
| 48 | 48 | |
| 49 | - $this->extend('updateFoxyStripePurchaseForm', $form); |
|
| 49 | + $this->extend('updateFoxyStripePurchaseForm', $form); |
|
| 50 | 50 | |
| 51 | - return $form; |
|
| 52 | - } |
|
| 51 | + return $form; |
|
| 52 | + } |
|
| 53 | 53 | } |
@@ -10,49 +10,49 @@ |
||
| 10 | 10 | |
| 11 | 11 | class OrderAdmin extends ModelAdmin |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * @var array |
|
| 15 | - */ |
|
| 16 | - private static $managed_models = array( |
|
| 17 | - Order::class, |
|
| 18 | - ); |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * @var string |
|
| 22 | - */ |
|
| 23 | - private static $url_segment = 'orders'; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * @var string |
|
| 27 | - */ |
|
| 28 | - private static $menu_title = 'Orders'; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * @var int |
|
| 32 | - */ |
|
| 33 | - private static $menu_priority = 4; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @param null $id |
|
| 37 | - * @param null $fields |
|
| 38 | - * |
|
| 39 | - * @return \SilverStripe\Forms\Form |
|
| 40 | - */ |
|
| 41 | - public function getEditForm($id = null, $fields = null) |
|
| 42 | - { |
|
| 43 | - $form = parent::getEditForm($id, $fields); |
|
| 44 | - |
|
| 45 | - $gridFieldName = $this->sanitiseClassName($this->modelClass); |
|
| 46 | - /** @var GridField $gridField */ |
|
| 47 | - $gridField = $form->Fields()->fieldByName($gridFieldName); |
|
| 48 | - |
|
| 49 | - // GridField configuration |
|
| 50 | - /** @var GridFieldConfig $config */ |
|
| 51 | - $config = $gridField->getConfig(); |
|
| 52 | - |
|
| 53 | - // remove edit icon |
|
| 54 | - $config->removeComponentsByType(GridFieldEditButton::class); |
|
| 55 | - |
|
| 56 | - return $form; |
|
| 57 | - } |
|
| 13 | + /** |
|
| 14 | + * @var array |
|
| 15 | + */ |
|
| 16 | + private static $managed_models = array( |
|
| 17 | + Order::class, |
|
| 18 | + ); |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * @var string |
|
| 22 | + */ |
|
| 23 | + private static $url_segment = 'orders'; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * @var string |
|
| 27 | + */ |
|
| 28 | + private static $menu_title = 'Orders'; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * @var int |
|
| 32 | + */ |
|
| 33 | + private static $menu_priority = 4; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @param null $id |
|
| 37 | + * @param null $fields |
|
| 38 | + * |
|
| 39 | + * @return \SilverStripe\Forms\Form |
|
| 40 | + */ |
|
| 41 | + public function getEditForm($id = null, $fields = null) |
|
| 42 | + { |
|
| 43 | + $form = parent::getEditForm($id, $fields); |
|
| 44 | + |
|
| 45 | + $gridFieldName = $this->sanitiseClassName($this->modelClass); |
|
| 46 | + /** @var GridField $gridField */ |
|
| 47 | + $gridField = $form->Fields()->fieldByName($gridFieldName); |
|
| 48 | + |
|
| 49 | + // GridField configuration |
|
| 50 | + /** @var GridFieldConfig $config */ |
|
| 51 | + $config = $gridField->getConfig(); |
|
| 52 | + |
|
| 53 | + // remove edit icon |
|
| 54 | + $config->removeComponentsByType(GridFieldEditButton::class); |
|
| 55 | + |
|
| 56 | + return $form; |
|
| 57 | + } |
|
| 58 | 58 | } |
@@ -35,335 +35,335 @@ |
||
| 35 | 35 | */ |
| 36 | 36 | class ProductCategory extends DataObject |
| 37 | 37 | { |
| 38 | - /** |
|
| 39 | - * @var array |
|
| 40 | - */ |
|
| 41 | - private static $db = [ |
|
| 42 | - 'Title' => 'Varchar(255)', |
|
| 43 | - 'Code' => 'Varchar(50)', |
|
| 44 | - 'DeliveryType' => 'Varchar(50)', |
|
| 45 | - 'MaxDownloads' => 'Int', |
|
| 46 | - 'MaxDownloadsTime' => 'Int', |
|
| 47 | - 'DefaultWeight' => 'Float', |
|
| 48 | - 'DefaultWeightUnit' => 'Enum("LBS, KBS", "LBS")', |
|
| 49 | - 'DefaultLengthUnit' => 'Enum("in, cm", "in")', |
|
| 50 | - 'ShippingFlatRate' => 'Currency', |
|
| 51 | - 'ShippingFlatRateType' => 'Varchar(50)', |
|
| 52 | - 'HandlingFeeType' => 'Varchar(50)', |
|
| 53 | - 'HandlingFee' => 'Currency', |
|
| 54 | - 'HandlingFeePercentage' => 'Decimal', |
|
| 55 | - 'HandlingFeeMinimum' => 'Currency', |
|
| 56 | - 'DiscountType' => 'Varchar(50)', |
|
| 57 | - 'DiscountName' => 'Varchar(50)', |
|
| 58 | - 'DiscountDetails' => 'Varchar(200)', |
|
| 59 | - 'CustomsValue' => 'Currency', |
|
| 60 | - ]; |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * @var string |
|
| 64 | - */ |
|
| 65 | - private static $singular_name = 'FoxyCart Category'; |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * @var string |
|
| 69 | - */ |
|
| 70 | - private static $plural_name = 'FoxyCart Categories'; |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * @var string |
|
| 74 | - */ |
|
| 75 | - private static $description = 'Set the FoxyCart Category on a Product'; |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * @var array |
|
| 79 | - */ |
|
| 80 | - private static $summary_fields = [ |
|
| 81 | - 'Title' => 'Name', |
|
| 82 | - 'Code' => 'Code', |
|
| 83 | - ]; |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * @var array |
|
| 87 | - */ |
|
| 88 | - private static $indexes = [ |
|
| 89 | - 'Code' => [ |
|
| 90 | - 'type' => 'unique', |
|
| 91 | - 'columns' => ['Code'], |
|
| 92 | - ], |
|
| 93 | - ]; |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * @var string |
|
| 97 | - */ |
|
| 98 | - private static $table_name = 'ProductCategory'; |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * @return FieldList |
|
| 102 | - */ |
|
| 103 | - public function getCMSFields() |
|
| 104 | - { |
|
| 105 | - $fields = parent::getCMSFields(); |
|
| 106 | - |
|
| 107 | - if ($this->ID) { |
|
| 108 | - if ($this->Title == 'Default') { |
|
| 109 | - $fields->replaceField( |
|
| 110 | - 'Title', |
|
| 111 | - ReadonlyField::create('Title') |
|
| 112 | - ); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - $fields->replaceField( |
|
| 116 | - 'Code', |
|
| 117 | - ReadonlyField::create('Code') |
|
| 118 | - ); |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - $fields->insertBefore(HeaderField::create('DeliveryHD', 'Delivery Options', 3), 'DeliveryType'); |
|
| 122 | - |
|
| 123 | - $fields->replaceField( |
|
| 124 | - 'DeliveryType', |
|
| 125 | - OptionsetField::create('DeliveryType', 'Delivery Type', $this->getShippingOptions()) |
|
| 126 | - ); |
|
| 127 | - |
|
| 128 | - $fields->dataFieldByName('MaxDownloads') |
|
| 129 | - ->displayIf('DeliveryType')->isEqualTo('downloaded'); |
|
| 130 | - |
|
| 131 | - $fields->dataFieldByName('MaxDownloadsTime') |
|
| 132 | - ->displayIf('DeliveryType')->isEqualTo('downloaded'); |
|
| 133 | - |
|
| 134 | - $fields->dataFieldByName('DefaultWeight') |
|
| 135 | - ->displayIf('DeliveryType')->isEqualTo('shipped'); |
|
| 136 | - |
|
| 137 | - $fields->dataFieldByName('DefaultWeightUnit') |
|
| 138 | - ->displayIf('DeliveryType')->isEqualTo('shipped'); |
|
| 139 | - |
|
| 140 | - $fields->dataFieldByName('DefaultLengthUnit') |
|
| 141 | - ->displayIf('DeliveryType')->isEqualTo('shipped'); |
|
| 142 | - |
|
| 143 | - $fields->dataFieldByName('ShippingFlatRate') |
|
| 144 | - ->displayIf('DeliveryType')->isEqualTo('flat_rate'); |
|
| 145 | - |
|
| 146 | - $fields->replaceField( |
|
| 147 | - 'ShippingFlatRateType', |
|
| 148 | - DropdownField::create('ShippingFlatRateType', 'Flat Rate Type', $this->getShippingFlatRateTypes()) |
|
| 149 | - ->setEmptyString('') |
|
| 150 | - ->displayIf('DeliveryType')->isEqualTo('flat_rate')->end() |
|
| 151 | - ); |
|
| 152 | - |
|
| 153 | - $fields->insertBefore(HeaderField::create('HandlingHD', 'Handling Fees and Discounts', 3), 'HandlingFeeType'); |
|
| 154 | - |
|
| 155 | - $fields->replaceField( |
|
| 156 | - 'HandlingFeeType', |
|
| 157 | - DropdownField::create('HandlingFeeType', 'Handling Fee Type', $this->getHandlingFeeTypes()) |
|
| 158 | - ->setEmptyString('') |
|
| 159 | - ->setDescription('This determines what type of Handling Fee you would like to use.') |
|
| 160 | - ); |
|
| 161 | - |
|
| 162 | - $fields->dataFieldByName('HandlingFee') |
|
| 163 | - ->displayIf('HandlingFeeType')->isNotEqualTo(''); |
|
| 164 | - |
|
| 165 | - $fields->dataFieldByName('HandlingFeeMinimum') |
|
| 166 | - ->displayIf('HandlingFeeType')->isEqualTo('flat_percent_with_minimum'); |
|
| 167 | - |
|
| 168 | - $fields->dataFieldByName('HandlingFeePercentage') |
|
| 169 | - ->displayIf('HandlingFeeType')->isEqualTo('flat_percent_with_minimum') |
|
| 170 | - ->orIf('HandlingFeeType')->isEqualTo('flat_percent'); |
|
| 171 | - |
|
| 172 | - $fields->replaceField( |
|
| 173 | - 'DiscountType', |
|
| 174 | - DropdownField::create('DiscountType', 'Discount Type', $this->getDiscountTypes()) |
|
| 175 | - ->setEmptyString('') |
|
| 176 | - ->setDescription('This determines what type of per category discount you would like to use, if any.') |
|
| 177 | - ); |
|
| 178 | - |
|
| 179 | - $fields->dataFieldByName('DiscountName') |
|
| 180 | - ->displayIf('DiscountType')->isNotEqualTo(''); |
|
| 181 | - |
|
| 182 | - $fields->dataFieldByName('DiscountDetails') |
|
| 183 | - ->displayIf('DiscountType')->isNotEqualTo(''); |
|
| 184 | - |
|
| 185 | - $fields->dataFieldByName('CustomsValue') |
|
| 186 | - ->setDescription('Enter a dollar amount here for the declared customs value for international |
|
| 38 | + /** |
|
| 39 | + * @var array |
|
| 40 | + */ |
|
| 41 | + private static $db = [ |
|
| 42 | + 'Title' => 'Varchar(255)', |
|
| 43 | + 'Code' => 'Varchar(50)', |
|
| 44 | + 'DeliveryType' => 'Varchar(50)', |
|
| 45 | + 'MaxDownloads' => 'Int', |
|
| 46 | + 'MaxDownloadsTime' => 'Int', |
|
| 47 | + 'DefaultWeight' => 'Float', |
|
| 48 | + 'DefaultWeightUnit' => 'Enum("LBS, KBS", "LBS")', |
|
| 49 | + 'DefaultLengthUnit' => 'Enum("in, cm", "in")', |
|
| 50 | + 'ShippingFlatRate' => 'Currency', |
|
| 51 | + 'ShippingFlatRateType' => 'Varchar(50)', |
|
| 52 | + 'HandlingFeeType' => 'Varchar(50)', |
|
| 53 | + 'HandlingFee' => 'Currency', |
|
| 54 | + 'HandlingFeePercentage' => 'Decimal', |
|
| 55 | + 'HandlingFeeMinimum' => 'Currency', |
|
| 56 | + 'DiscountType' => 'Varchar(50)', |
|
| 57 | + 'DiscountName' => 'Varchar(50)', |
|
| 58 | + 'DiscountDetails' => 'Varchar(200)', |
|
| 59 | + 'CustomsValue' => 'Currency', |
|
| 60 | + ]; |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * @var string |
|
| 64 | + */ |
|
| 65 | + private static $singular_name = 'FoxyCart Category'; |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @var string |
|
| 69 | + */ |
|
| 70 | + private static $plural_name = 'FoxyCart Categories'; |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * @var string |
|
| 74 | + */ |
|
| 75 | + private static $description = 'Set the FoxyCart Category on a Product'; |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * @var array |
|
| 79 | + */ |
|
| 80 | + private static $summary_fields = [ |
|
| 81 | + 'Title' => 'Name', |
|
| 82 | + 'Code' => 'Code', |
|
| 83 | + ]; |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * @var array |
|
| 87 | + */ |
|
| 88 | + private static $indexes = [ |
|
| 89 | + 'Code' => [ |
|
| 90 | + 'type' => 'unique', |
|
| 91 | + 'columns' => ['Code'], |
|
| 92 | + ], |
|
| 93 | + ]; |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * @var string |
|
| 97 | + */ |
|
| 98 | + private static $table_name = 'ProductCategory'; |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * @return FieldList |
|
| 102 | + */ |
|
| 103 | + public function getCMSFields() |
|
| 104 | + { |
|
| 105 | + $fields = parent::getCMSFields(); |
|
| 106 | + |
|
| 107 | + if ($this->ID) { |
|
| 108 | + if ($this->Title == 'Default') { |
|
| 109 | + $fields->replaceField( |
|
| 110 | + 'Title', |
|
| 111 | + ReadonlyField::create('Title') |
|
| 112 | + ); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + $fields->replaceField( |
|
| 116 | + 'Code', |
|
| 117 | + ReadonlyField::create('Code') |
|
| 118 | + ); |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + $fields->insertBefore(HeaderField::create('DeliveryHD', 'Delivery Options', 3), 'DeliveryType'); |
|
| 122 | + |
|
| 123 | + $fields->replaceField( |
|
| 124 | + 'DeliveryType', |
|
| 125 | + OptionsetField::create('DeliveryType', 'Delivery Type', $this->getShippingOptions()) |
|
| 126 | + ); |
|
| 127 | + |
|
| 128 | + $fields->dataFieldByName('MaxDownloads') |
|
| 129 | + ->displayIf('DeliveryType')->isEqualTo('downloaded'); |
|
| 130 | + |
|
| 131 | + $fields->dataFieldByName('MaxDownloadsTime') |
|
| 132 | + ->displayIf('DeliveryType')->isEqualTo('downloaded'); |
|
| 133 | + |
|
| 134 | + $fields->dataFieldByName('DefaultWeight') |
|
| 135 | + ->displayIf('DeliveryType')->isEqualTo('shipped'); |
|
| 136 | + |
|
| 137 | + $fields->dataFieldByName('DefaultWeightUnit') |
|
| 138 | + ->displayIf('DeliveryType')->isEqualTo('shipped'); |
|
| 139 | + |
|
| 140 | + $fields->dataFieldByName('DefaultLengthUnit') |
|
| 141 | + ->displayIf('DeliveryType')->isEqualTo('shipped'); |
|
| 142 | + |
|
| 143 | + $fields->dataFieldByName('ShippingFlatRate') |
|
| 144 | + ->displayIf('DeliveryType')->isEqualTo('flat_rate'); |
|
| 145 | + |
|
| 146 | + $fields->replaceField( |
|
| 147 | + 'ShippingFlatRateType', |
|
| 148 | + DropdownField::create('ShippingFlatRateType', 'Flat Rate Type', $this->getShippingFlatRateTypes()) |
|
| 149 | + ->setEmptyString('') |
|
| 150 | + ->displayIf('DeliveryType')->isEqualTo('flat_rate')->end() |
|
| 151 | + ); |
|
| 152 | + |
|
| 153 | + $fields->insertBefore(HeaderField::create('HandlingHD', 'Handling Fees and Discounts', 3), 'HandlingFeeType'); |
|
| 154 | + |
|
| 155 | + $fields->replaceField( |
|
| 156 | + 'HandlingFeeType', |
|
| 157 | + DropdownField::create('HandlingFeeType', 'Handling Fee Type', $this->getHandlingFeeTypes()) |
|
| 158 | + ->setEmptyString('') |
|
| 159 | + ->setDescription('This determines what type of Handling Fee you would like to use.') |
|
| 160 | + ); |
|
| 161 | + |
|
| 162 | + $fields->dataFieldByName('HandlingFee') |
|
| 163 | + ->displayIf('HandlingFeeType')->isNotEqualTo(''); |
|
| 164 | + |
|
| 165 | + $fields->dataFieldByName('HandlingFeeMinimum') |
|
| 166 | + ->displayIf('HandlingFeeType')->isEqualTo('flat_percent_with_minimum'); |
|
| 167 | + |
|
| 168 | + $fields->dataFieldByName('HandlingFeePercentage') |
|
| 169 | + ->displayIf('HandlingFeeType')->isEqualTo('flat_percent_with_minimum') |
|
| 170 | + ->orIf('HandlingFeeType')->isEqualTo('flat_percent'); |
|
| 171 | + |
|
| 172 | + $fields->replaceField( |
|
| 173 | + 'DiscountType', |
|
| 174 | + DropdownField::create('DiscountType', 'Discount Type', $this->getDiscountTypes()) |
|
| 175 | + ->setEmptyString('') |
|
| 176 | + ->setDescription('This determines what type of per category discount you would like to use, if any.') |
|
| 177 | + ); |
|
| 178 | + |
|
| 179 | + $fields->dataFieldByName('DiscountName') |
|
| 180 | + ->displayIf('DiscountType')->isNotEqualTo(''); |
|
| 181 | + |
|
| 182 | + $fields->dataFieldByName('DiscountDetails') |
|
| 183 | + ->displayIf('DiscountType')->isNotEqualTo(''); |
|
| 184 | + |
|
| 185 | + $fields->dataFieldByName('CustomsValue') |
|
| 186 | + ->setDescription('Enter a dollar amount here for the declared customs value for international |
|
| 187 | 187 | shipments. If you leave this blank, the sale price of the item will be used.'); |
| 188 | 188 | |
| 189 | - return $fields; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - /** |
|
| 193 | - * @return \SilverStripe\ORM\ValidationResult |
|
| 194 | - */ |
|
| 195 | - public function validate() |
|
| 196 | - { |
|
| 197 | - $result = parent::validate(); |
|
| 198 | - |
|
| 199 | - if (ProductCategory::get()->filter('Code', $this->Code)->exclude('ID', $this->ID)->first()) { |
|
| 200 | - $result->addError('Code must be unique for each category.'); |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - return $result; |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * @throws \SilverStripe\ORM\ValidationException |
|
| 208 | - */ |
|
| 209 | - public function requireDefaultRecords() |
|
| 210 | - { |
|
| 211 | - parent::requireDefaultRecords(); |
|
| 212 | - $allCats = self::get(); |
|
| 213 | - if (!$allCats->count()) { |
|
| 214 | - $cat = new self(); |
|
| 215 | - $cat->Title = 'Default'; |
|
| 216 | - $cat->Code = 'DEFAULT'; |
|
| 217 | - $cat->write(); |
|
| 218 | - } |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - /** |
|
| 222 | - * @param bool $member |
|
| 223 | - * |
|
| 224 | - * @return bool |
|
| 225 | - */ |
|
| 226 | - public function canView($member = false) |
|
| 227 | - { |
|
| 228 | - return true; |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * @param null $member |
|
| 233 | - * |
|
| 234 | - * @return bool|int |
|
| 235 | - */ |
|
| 236 | - public function canEdit($member = null) |
|
| 237 | - { |
|
| 238 | - return Permission::check('Product_CANCRUD', 'any', $member); |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - /** |
|
| 242 | - * @param null $member |
|
| 243 | - * |
|
| 244 | - * @return bool|int |
|
| 245 | - */ |
|
| 246 | - public function canDelete($member = null) |
|
| 247 | - { |
|
| 248 | - |
|
| 249 | - //don't allow deletion of DEFAULT category |
|
| 250 | - return ($this->Code == 'DEFAULT') ? false : Permission::check('Product_CANCRUD', 'any', $member); |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - /** |
|
| 254 | - * @param null $member |
|
| 255 | - * |
|
| 256 | - * @param array $context |
|
| 257 | - * |
|
| 258 | - * @return bool|int |
|
| 259 | - */ |
|
| 260 | - public function canCreate($member = null, $context = []) |
|
| 261 | - { |
|
| 262 | - return Permission::check('Product_CANCRUD', 'any', $member); |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - /** |
|
| 266 | - * @return array |
|
| 267 | - */ |
|
| 268 | - public function getShippingOptions() |
|
| 269 | - { |
|
| 270 | - return [ |
|
| 271 | - 'shipped' => 'Shipped using live shipping rates', |
|
| 272 | - 'downloaded' => 'Downloaded by the customer', |
|
| 273 | - 'flat_rate' => 'Shipped using a flat rate fee', |
|
| 274 | - 'pickup' => 'Picked up by the customer', |
|
| 275 | - 'notshipped' => 'No Shipping', |
|
| 276 | - ]; |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - /** |
|
| 280 | - * @return array |
|
| 281 | - */ |
|
| 282 | - public function getShippingFlatRateTypes() |
|
| 283 | - { |
|
| 284 | - return [ |
|
| 285 | - 'per_order' => 'Charge per order', |
|
| 286 | - 'per_item' => 'Charge per item', |
|
| 287 | - ]; |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - /** |
|
| 291 | - * @return array |
|
| 292 | - */ |
|
| 293 | - public function getHandlingFeeTypes() |
|
| 294 | - { |
|
| 295 | - return [ |
|
| 296 | - 'flat_per_order' => 'Flat fee per order with products in this category', |
|
| 297 | - 'flat_per_item' => 'Flat fee per product in this category', |
|
| 298 | - 'flat_percent' => 'Flat fee per shipment + % of price for products in this category', |
|
| 299 | - 'flat_percent_with_minimum' => 'Flat fee per shipment OR % of order total with products in this category. |
|
| 189 | + return $fields; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + /** |
|
| 193 | + * @return \SilverStripe\ORM\ValidationResult |
|
| 194 | + */ |
|
| 195 | + public function validate() |
|
| 196 | + { |
|
| 197 | + $result = parent::validate(); |
|
| 198 | + |
|
| 199 | + if (ProductCategory::get()->filter('Code', $this->Code)->exclude('ID', $this->ID)->first()) { |
|
| 200 | + $result->addError('Code must be unique for each category.'); |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + return $result; |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + /** |
|
| 207 | + * @throws \SilverStripe\ORM\ValidationException |
|
| 208 | + */ |
|
| 209 | + public function requireDefaultRecords() |
|
| 210 | + { |
|
| 211 | + parent::requireDefaultRecords(); |
|
| 212 | + $allCats = self::get(); |
|
| 213 | + if (!$allCats->count()) { |
|
| 214 | + $cat = new self(); |
|
| 215 | + $cat->Title = 'Default'; |
|
| 216 | + $cat->Code = 'DEFAULT'; |
|
| 217 | + $cat->write(); |
|
| 218 | + } |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + /** |
|
| 222 | + * @param bool $member |
|
| 223 | + * |
|
| 224 | + * @return bool |
|
| 225 | + */ |
|
| 226 | + public function canView($member = false) |
|
| 227 | + { |
|
| 228 | + return true; |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * @param null $member |
|
| 233 | + * |
|
| 234 | + * @return bool|int |
|
| 235 | + */ |
|
| 236 | + public function canEdit($member = null) |
|
| 237 | + { |
|
| 238 | + return Permission::check('Product_CANCRUD', 'any', $member); |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + /** |
|
| 242 | + * @param null $member |
|
| 243 | + * |
|
| 244 | + * @return bool|int |
|
| 245 | + */ |
|
| 246 | + public function canDelete($member = null) |
|
| 247 | + { |
|
| 248 | + |
|
| 249 | + //don't allow deletion of DEFAULT category |
|
| 250 | + return ($this->Code == 'DEFAULT') ? false : Permission::check('Product_CANCRUD', 'any', $member); |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + /** |
|
| 254 | + * @param null $member |
|
| 255 | + * |
|
| 256 | + * @param array $context |
|
| 257 | + * |
|
| 258 | + * @return bool|int |
|
| 259 | + */ |
|
| 260 | + public function canCreate($member = null, $context = []) |
|
| 261 | + { |
|
| 262 | + return Permission::check('Product_CANCRUD', 'any', $member); |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + /** |
|
| 266 | + * @return array |
|
| 267 | + */ |
|
| 268 | + public function getShippingOptions() |
|
| 269 | + { |
|
| 270 | + return [ |
|
| 271 | + 'shipped' => 'Shipped using live shipping rates', |
|
| 272 | + 'downloaded' => 'Downloaded by the customer', |
|
| 273 | + 'flat_rate' => 'Shipped using a flat rate fee', |
|
| 274 | + 'pickup' => 'Picked up by the customer', |
|
| 275 | + 'notshipped' => 'No Shipping', |
|
| 276 | + ]; |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + /** |
|
| 280 | + * @return array |
|
| 281 | + */ |
|
| 282 | + public function getShippingFlatRateTypes() |
|
| 283 | + { |
|
| 284 | + return [ |
|
| 285 | + 'per_order' => 'Charge per order', |
|
| 286 | + 'per_item' => 'Charge per item', |
|
| 287 | + ]; |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + /** |
|
| 291 | + * @return array |
|
| 292 | + */ |
|
| 293 | + public function getHandlingFeeTypes() |
|
| 294 | + { |
|
| 295 | + return [ |
|
| 296 | + 'flat_per_order' => 'Flat fee per order with products in this category', |
|
| 297 | + 'flat_per_item' => 'Flat fee per product in this category', |
|
| 298 | + 'flat_percent' => 'Flat fee per shipment + % of price for products in this category', |
|
| 299 | + 'flat_percent_with_minimum' => 'Flat fee per shipment OR % of order total with products in this category. |
|
| 300 | 300 | Whichever is greater.', |
| 301 | - ]; |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - /** |
|
| 305 | - * @return array |
|
| 306 | - */ |
|
| 307 | - public function getDiscountTypes() |
|
| 308 | - { |
|
| 309 | - return [ |
|
| 310 | - 'quantity_amount' => 'Discount by an amount based on the quantity', |
|
| 311 | - 'quantity_percentage' => 'Discount by a percentage based on the quantity', |
|
| 312 | - 'price_amount' => 'Discount by an amount based on the price in this category', |
|
| 313 | - 'price_percentage' => 'Discount by a percentage based on the price in this category', |
|
| 314 | - ]; |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - /** |
|
| 318 | - * @return array |
|
| 319 | - */ |
|
| 320 | - public function getDataMap() |
|
| 321 | - { |
|
| 322 | - return [ |
|
| 323 | - 'name' => $this->Title, |
|
| 324 | - 'code' => $this->Code, |
|
| 325 | - 'item_delivery_type' => $this->DeliveryType, |
|
| 326 | - 'max_downloads_per_customer' => $this->MaxDownloads, |
|
| 327 | - 'max_downloads_time_period' => $this->MaxDownloadsTime, |
|
| 328 | - 'customs_value' => $this->CustomsValue, |
|
| 329 | - 'default_weight' => $this->DefaultWeight, |
|
| 330 | - 'default_weight_unit' => $this->DefaultWeightUnit, |
|
| 331 | - 'default_length_unit' => $this->DefautlLengthUnit, |
|
| 332 | - 'shipping_flat_rate' => $this->ShippingFlatRate, |
|
| 333 | - 'shipping_flat_rate_type' => $this->ShippingFlatRateType, |
|
| 334 | - 'handling_fee_type' => $this->HandlingFeeType, |
|
| 335 | - 'handling_fee' => $this->HandlingFee, |
|
| 336 | - 'handling_fee_minimum' => $this->HandlingFeeMinimum, |
|
| 337 | - 'handling_fee_percentage' => $this->HandlingFeePercentage, |
|
| 338 | - 'discount_type' => $this->DiscountType, |
|
| 339 | - 'discount_name' => $this->DiscountName, |
|
| 340 | - 'discount_details' => $this->DiscountDetails, |
|
| 341 | - ]; |
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - /** |
|
| 345 | - * @throws \Psr\Container\NotFoundExceptionInterface |
|
| 346 | - */ |
|
| 347 | - public function onAfterWrite() |
|
| 348 | - { |
|
| 349 | - parent::onAfterWrite(); |
|
| 350 | - |
|
| 351 | - if ($this->isChanged()) { |
|
| 352 | - if ($fc = new FoxyStripeClient()) { |
|
| 353 | - $fc->putCategory($this->getDataMap()); |
|
| 354 | - } |
|
| 355 | - } |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - /** |
|
| 359 | - * @throws \Psr\Container\NotFoundExceptionInterface |
|
| 360 | - */ |
|
| 361 | - public function onAfterDelete() |
|
| 362 | - { |
|
| 363 | - parent::onAfterDelete(); |
|
| 364 | - |
|
| 365 | - if ($fc = new FoxyStripeClient()) { |
|
| 366 | - $fc->deleteCategory($this->getDataMap()); |
|
| 367 | - } |
|
| 368 | - } |
|
| 301 | + ]; |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + /** |
|
| 305 | + * @return array |
|
| 306 | + */ |
|
| 307 | + public function getDiscountTypes() |
|
| 308 | + { |
|
| 309 | + return [ |
|
| 310 | + 'quantity_amount' => 'Discount by an amount based on the quantity', |
|
| 311 | + 'quantity_percentage' => 'Discount by a percentage based on the quantity', |
|
| 312 | + 'price_amount' => 'Discount by an amount based on the price in this category', |
|
| 313 | + 'price_percentage' => 'Discount by a percentage based on the price in this category', |
|
| 314 | + ]; |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + /** |
|
| 318 | + * @return array |
|
| 319 | + */ |
|
| 320 | + public function getDataMap() |
|
| 321 | + { |
|
| 322 | + return [ |
|
| 323 | + 'name' => $this->Title, |
|
| 324 | + 'code' => $this->Code, |
|
| 325 | + 'item_delivery_type' => $this->DeliveryType, |
|
| 326 | + 'max_downloads_per_customer' => $this->MaxDownloads, |
|
| 327 | + 'max_downloads_time_period' => $this->MaxDownloadsTime, |
|
| 328 | + 'customs_value' => $this->CustomsValue, |
|
| 329 | + 'default_weight' => $this->DefaultWeight, |
|
| 330 | + 'default_weight_unit' => $this->DefaultWeightUnit, |
|
| 331 | + 'default_length_unit' => $this->DefautlLengthUnit, |
|
| 332 | + 'shipping_flat_rate' => $this->ShippingFlatRate, |
|
| 333 | + 'shipping_flat_rate_type' => $this->ShippingFlatRateType, |
|
| 334 | + 'handling_fee_type' => $this->HandlingFeeType, |
|
| 335 | + 'handling_fee' => $this->HandlingFee, |
|
| 336 | + 'handling_fee_minimum' => $this->HandlingFeeMinimum, |
|
| 337 | + 'handling_fee_percentage' => $this->HandlingFeePercentage, |
|
| 338 | + 'discount_type' => $this->DiscountType, |
|
| 339 | + 'discount_name' => $this->DiscountName, |
|
| 340 | + 'discount_details' => $this->DiscountDetails, |
|
| 341 | + ]; |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + /** |
|
| 345 | + * @throws \Psr\Container\NotFoundExceptionInterface |
|
| 346 | + */ |
|
| 347 | + public function onAfterWrite() |
|
| 348 | + { |
|
| 349 | + parent::onAfterWrite(); |
|
| 350 | + |
|
| 351 | + if ($this->isChanged()) { |
|
| 352 | + if ($fc = new FoxyStripeClient()) { |
|
| 353 | + $fc->putCategory($this->getDataMap()); |
|
| 354 | + } |
|
| 355 | + } |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + /** |
|
| 359 | + * @throws \Psr\Container\NotFoundExceptionInterface |
|
| 360 | + */ |
|
| 361 | + public function onAfterDelete() |
|
| 362 | + { |
|
| 363 | + parent::onAfterDelete(); |
|
| 364 | + |
|
| 365 | + if ($fc = new FoxyStripeClient()) { |
|
| 366 | + $fc->deleteCategory($this->getDataMap()); |
|
| 367 | + } |
|
| 368 | + } |
|
| 369 | 369 | } |
@@ -24,97 +24,97 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | class ProductImage extends DataObject |
| 26 | 26 | { |
| 27 | - /** |
|
| 28 | - * @var array |
|
| 29 | - */ |
|
| 30 | - private static $db = array( |
|
| 31 | - 'Title' => 'Text', |
|
| 32 | - 'SortOrder' => 'Int', |
|
| 33 | - ); |
|
| 27 | + /** |
|
| 28 | + * @var array |
|
| 29 | + */ |
|
| 30 | + private static $db = array( |
|
| 31 | + 'Title' => 'Text', |
|
| 32 | + 'SortOrder' => 'Int', |
|
| 33 | + ); |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @var array |
|
| 37 | - */ |
|
| 38 | - private static $has_one = array( |
|
| 39 | - 'Image' => Image::class, |
|
| 40 | - 'Parent' => SiteTree::class, |
|
| 41 | - ); |
|
| 35 | + /** |
|
| 36 | + * @var array |
|
| 37 | + */ |
|
| 38 | + private static $has_one = array( |
|
| 39 | + 'Image' => Image::class, |
|
| 40 | + 'Parent' => SiteTree::class, |
|
| 41 | + ); |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @var string |
|
| 45 | - */ |
|
| 46 | - private static $default_sort = 'SortOrder'; |
|
| 43 | + /** |
|
| 44 | + * @var string |
|
| 45 | + */ |
|
| 46 | + private static $default_sort = 'SortOrder'; |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @var array |
|
| 50 | - */ |
|
| 51 | - private static $summary_fields = array( |
|
| 52 | - 'Image.CMSThumbnail' => 'Image', |
|
| 53 | - 'Title' => 'Caption', |
|
| 54 | - ); |
|
| 48 | + /** |
|
| 49 | + * @var array |
|
| 50 | + */ |
|
| 51 | + private static $summary_fields = array( |
|
| 52 | + 'Image.CMSThumbnail' => 'Image', |
|
| 53 | + 'Title' => 'Caption', |
|
| 54 | + ); |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @var string |
|
| 58 | - */ |
|
| 59 | - private static $table_name = 'ProductImage'; |
|
| 56 | + /** |
|
| 57 | + * @var string |
|
| 58 | + */ |
|
| 59 | + private static $table_name = 'ProductImage'; |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * @return \SilverStripe\Forms\FieldList |
|
| 63 | - */ |
|
| 64 | - public function getCMSFields() |
|
| 65 | - { |
|
| 66 | - $fields = FieldList::create( |
|
| 67 | - TextField::create('Title') |
|
| 68 | - ->setTitle(_t('ProductImage.Title', 'Product Image Title')), |
|
| 69 | - UploadField::create('Image') |
|
| 70 | - ->setTitle(_t('ProductCategory.Image', 'Product Image')) |
|
| 71 | - ->setFolderName('Uploads/Products') |
|
| 72 | - ->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png')) |
|
| 73 | - ); |
|
| 61 | + /** |
|
| 62 | + * @return \SilverStripe\Forms\FieldList |
|
| 63 | + */ |
|
| 64 | + public function getCMSFields() |
|
| 65 | + { |
|
| 66 | + $fields = FieldList::create( |
|
| 67 | + TextField::create('Title') |
|
| 68 | + ->setTitle(_t('ProductImage.Title', 'Product Image Title')), |
|
| 69 | + UploadField::create('Image') |
|
| 70 | + ->setTitle(_t('ProductCategory.Image', 'Product Image')) |
|
| 71 | + ->setFolderName('Uploads/Products') |
|
| 72 | + ->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png')) |
|
| 73 | + ); |
|
| 74 | 74 | |
| 75 | - $this->extend('updateCMSFields', $fields); |
|
| 75 | + $this->extend('updateCMSFields', $fields); |
|
| 76 | 76 | |
| 77 | - return $fields; |
|
| 78 | - } |
|
| 77 | + return $fields; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * @param bool $member |
|
| 82 | - * |
|
| 83 | - * @return bool |
|
| 84 | - */ |
|
| 85 | - public function canView($member = null) |
|
| 86 | - { |
|
| 87 | - return true; |
|
| 88 | - } |
|
| 80 | + /** |
|
| 81 | + * @param bool $member |
|
| 82 | + * |
|
| 83 | + * @return bool |
|
| 84 | + */ |
|
| 85 | + public function canView($member = null) |
|
| 86 | + { |
|
| 87 | + return true; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * @param null $member |
|
| 92 | - * |
|
| 93 | - * @return bool |
|
| 94 | - */ |
|
| 95 | - public function canEdit($member = null) |
|
| 96 | - { |
|
| 97 | - return Permission::check('Product_CANCRUD'); |
|
| 98 | - } |
|
| 90 | + /** |
|
| 91 | + * @param null $member |
|
| 92 | + * |
|
| 93 | + * @return bool |
|
| 94 | + */ |
|
| 95 | + public function canEdit($member = null) |
|
| 96 | + { |
|
| 97 | + return Permission::check('Product_CANCRUD'); |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * @param null $member |
|
| 102 | - * |
|
| 103 | - * @return bool|int |
|
| 104 | - */ |
|
| 105 | - public function canDelete($member = null) |
|
| 106 | - { |
|
| 107 | - return Permission::check('Product_CANCRUD'); |
|
| 108 | - } |
|
| 100 | + /** |
|
| 101 | + * @param null $member |
|
| 102 | + * |
|
| 103 | + * @return bool|int |
|
| 104 | + */ |
|
| 105 | + public function canDelete($member = null) |
|
| 106 | + { |
|
| 107 | + return Permission::check('Product_CANCRUD'); |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * @param null $member |
|
| 112 | - * @param array $context |
|
| 113 | - * |
|
| 114 | - * @return bool|int |
|
| 115 | - */ |
|
| 116 | - public function canCreate($member = null, $context = []) |
|
| 117 | - { |
|
| 118 | - return Permission::check('Product_CANCRUD'); |
|
| 119 | - } |
|
| 110 | + /** |
|
| 111 | + * @param null $member |
|
| 112 | + * @param array $context |
|
| 113 | + * |
|
| 114 | + * @return bool|int |
|
| 115 | + */ |
|
| 116 | + public function canCreate($member = null, $context = []) |
|
| 117 | + { |
|
| 118 | + return Permission::check('Product_CANCRUD'); |
|
| 119 | + } |
|
| 120 | 120 | } |
@@ -30,124 +30,124 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | class OrderDetail extends DataObject |
| 32 | 32 | { |
| 33 | - /** |
|
| 34 | - * @var string |
|
| 35 | - */ |
|
| 36 | - private static $singular_name = 'Order Detail'; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @var string |
|
| 40 | - */ |
|
| 41 | - private static $plural_name = 'Order Details'; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @var string |
|
| 45 | - */ |
|
| 46 | - private static $description = ''; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @var array |
|
| 50 | - */ |
|
| 51 | - private static $db = array( |
|
| 52 | - 'Quantity' => 'Int', |
|
| 53 | - 'Price' => 'Currency', |
|
| 54 | - 'ProductName' => 'Varchar(255)', |
|
| 55 | - 'ProductCode' => 'Varchar(100)', |
|
| 56 | - 'ProductImage' => 'Text', |
|
| 57 | - 'ProductCategory' => 'Varchar(100)', |
|
| 58 | - ); |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * @var array |
|
| 62 | - */ |
|
| 63 | - private static $has_one = array( |
|
| 64 | - 'Product' => ProductPage::class, |
|
| 65 | - 'Order' => Order::class, |
|
| 66 | - ); |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * @var array |
|
| 70 | - */ |
|
| 71 | - private static $has_many = array( |
|
| 72 | - 'OrderOptions' => OrderOption::class, |
|
| 73 | - ); |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * @var array |
|
| 77 | - */ |
|
| 78 | - private static $many_many = [ |
|
| 79 | - 'OptionItems' => OptionItem::class, |
|
| 80 | - ]; |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * @var array |
|
| 84 | - */ |
|
| 85 | - private static $summary_fields = array( |
|
| 86 | - 'Product.Title', |
|
| 87 | - 'Quantity', |
|
| 88 | - 'Price.Nice', |
|
| 89 | - ); |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * @var string |
|
| 93 | - */ |
|
| 94 | - private static $table_name = 'OrderDetail'; |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * @return FieldList |
|
| 98 | - */ |
|
| 99 | - public function getCMSFields() |
|
| 100 | - { |
|
| 101 | - $fields = parent::getCMSFields(); |
|
| 102 | - |
|
| 103 | - if ($this->ID) { |
|
| 104 | - $fields->addFieldsToTab('Root.Options', array( |
|
| 105 | - GridField::create( |
|
| 106 | - 'Options', |
|
| 107 | - 'Product Options', |
|
| 108 | - $this->OrderOptions(), |
|
| 109 | - GridFieldConfig_RecordViewer::create() |
|
| 110 | - ), |
|
| 111 | - )); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - return $fields; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * @param bool $member |
|
| 119 | - * |
|
| 120 | - * @return bool|int |
|
| 121 | - */ |
|
| 122 | - public function canView($member = null) |
|
| 123 | - { |
|
| 124 | - return Permission::check('Product_ORDERS', 'any', $member); |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * @param null $member |
|
| 129 | - * |
|
| 130 | - * @return bool |
|
| 131 | - */ |
|
| 132 | - public function canEdit($member = null) |
|
| 133 | - { |
|
| 134 | - return false; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - /** |
|
| 138 | - * @param null $member |
|
| 139 | - * @param array $context |
|
| 140 | - * |
|
| 141 | - * @return bool |
|
| 142 | - */ |
|
| 143 | - public function canCreate($member = null, $context = []) |
|
| 144 | - { |
|
| 145 | - return false; |
|
| 146 | - //return Permission::check('Product_ORDERS'); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - public function canDelete($member = null) |
|
| 150 | - { |
|
| 151 | - return Permission::check('Product_ORDERS', 'any', $member); |
|
| 152 | - } |
|
| 33 | + /** |
|
| 34 | + * @var string |
|
| 35 | + */ |
|
| 36 | + private static $singular_name = 'Order Detail'; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @var string |
|
| 40 | + */ |
|
| 41 | + private static $plural_name = 'Order Details'; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @var string |
|
| 45 | + */ |
|
| 46 | + private static $description = ''; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @var array |
|
| 50 | + */ |
|
| 51 | + private static $db = array( |
|
| 52 | + 'Quantity' => 'Int', |
|
| 53 | + 'Price' => 'Currency', |
|
| 54 | + 'ProductName' => 'Varchar(255)', |
|
| 55 | + 'ProductCode' => 'Varchar(100)', |
|
| 56 | + 'ProductImage' => 'Text', |
|
| 57 | + 'ProductCategory' => 'Varchar(100)', |
|
| 58 | + ); |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * @var array |
|
| 62 | + */ |
|
| 63 | + private static $has_one = array( |
|
| 64 | + 'Product' => ProductPage::class, |
|
| 65 | + 'Order' => Order::class, |
|
| 66 | + ); |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * @var array |
|
| 70 | + */ |
|
| 71 | + private static $has_many = array( |
|
| 72 | + 'OrderOptions' => OrderOption::class, |
|
| 73 | + ); |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * @var array |
|
| 77 | + */ |
|
| 78 | + private static $many_many = [ |
|
| 79 | + 'OptionItems' => OptionItem::class, |
|
| 80 | + ]; |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * @var array |
|
| 84 | + */ |
|
| 85 | + private static $summary_fields = array( |
|
| 86 | + 'Product.Title', |
|
| 87 | + 'Quantity', |
|
| 88 | + 'Price.Nice', |
|
| 89 | + ); |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * @var string |
|
| 93 | + */ |
|
| 94 | + private static $table_name = 'OrderDetail'; |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * @return FieldList |
|
| 98 | + */ |
|
| 99 | + public function getCMSFields() |
|
| 100 | + { |
|
| 101 | + $fields = parent::getCMSFields(); |
|
| 102 | + |
|
| 103 | + if ($this->ID) { |
|
| 104 | + $fields->addFieldsToTab('Root.Options', array( |
|
| 105 | + GridField::create( |
|
| 106 | + 'Options', |
|
| 107 | + 'Product Options', |
|
| 108 | + $this->OrderOptions(), |
|
| 109 | + GridFieldConfig_RecordViewer::create() |
|
| 110 | + ), |
|
| 111 | + )); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + return $fields; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * @param bool $member |
|
| 119 | + * |
|
| 120 | + * @return bool|int |
|
| 121 | + */ |
|
| 122 | + public function canView($member = null) |
|
| 123 | + { |
|
| 124 | + return Permission::check('Product_ORDERS', 'any', $member); |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * @param null $member |
|
| 129 | + * |
|
| 130 | + * @return bool |
|
| 131 | + */ |
|
| 132 | + public function canEdit($member = null) |
|
| 133 | + { |
|
| 134 | + return false; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + /** |
|
| 138 | + * @param null $member |
|
| 139 | + * @param array $context |
|
| 140 | + * |
|
| 141 | + * @return bool |
|
| 142 | + */ |
|
| 143 | + public function canCreate($member = null, $context = []) |
|
| 144 | + { |
|
| 145 | + return false; |
|
| 146 | + //return Permission::check('Product_ORDERS'); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + public function canDelete($member = null) |
|
| 150 | + { |
|
| 151 | + return Permission::check('Product_ORDERS', 'any', $member); |
|
| 152 | + } |
|
| 153 | 153 | } |