diff --git a/bin/backend/controls/products/fields/ShippingTimePeriod.js b/bin/backend/controls/products/fields/ShippingTimePeriod.js index 928ee1b9db2f4ada907f610774aa7eec7932166f..cbae74decf7004b76723403cd9eb18cbf635b5d9 100644 --- a/bin/backend/controls/products/fields/ShippingTimePeriod.js +++ b/bin/backend/controls/products/fields/ShippingTimePeriod.js @@ -31,7 +31,9 @@ define('package/quiqqer/shipping/bin/backend/controls/products/fields/ShippingTi selectOptions: [ 'timeperiod', 'unavailable', 'immediately_available', 'on_request', 'available_soon', 'custom_text' - ] + ], + + show_default_option: true }, initialize: function (options) { @@ -72,6 +74,10 @@ define('package/quiqqer/shipping/bin/backend/controls/products/fields/ShippingTi var options = this.getAttribute('selectOptions'), lgPrefix = 'controls.products.fields.ShippingTimePeriod.'; + if (this.getAttribute('show_default_option')) { + options.unshift('use_default'); + } + for (var i = 0, len = options.length; i < len; i++) { var option = options[i]; diff --git a/locale.xml b/locale.xml index 2acb92831f383547283f706ff748e50edeb356d1..4934587a856247dcbdf7cc2751ca074208114f0e 100644 --- a/locale.xml +++ b/locale.xml @@ -763,6 +763,14 @@ <de><![CDATA[Individueller Text]]></de> <en><![CDATA[Custom text]]></en> </locale> + <locale name="controls.products.fields.ShippingTimePeriod.option.custom_text"> + <de><![CDATA[Individueller Text]]></de> + <en><![CDATA[Custom text]]></en> + </locale> + <locale name="controls.products.fields.ShippingTimePeriod.option.use_default"> + <de><![CDATA[Standard-Einstellung benutzen]]></de> + <en><![CDATA[Use default setting]]></en> + </locale> <locale name="control.search.ShippingWindow.title"> <de><![CDATA[Versandarten durchsuchen]]></de> diff --git a/settings.xml b/settings.xml index 859c0e4d257a6e5f492d21b0a338fb227d4a141a..a2c3edfdeb20c5198a9c421beb253d72f775ebdc 100644 --- a/settings.xml +++ b/settings.xml @@ -85,6 +85,7 @@ <input type="hidden" conf="shipping.deliveryTimeDefault" data-qui="package/quiqqer/shipping/bin/backend/controls/products/fields/ShippingTimePeriod" + data-qui-options-show_default_option="0" > <text> <locale group="quiqqer/shipping" var="shipping.settings.deliveryTimeDefault"/> diff --git a/src/QUI/ERP/Shipping/Products/Fields/ShippingTimeFrontendView.php b/src/QUI/ERP/Shipping/Products/Fields/ShippingTimeFrontendView.php index d8ccd6a7603c139973d9e088fe792ba49e672e7f..face904cab555fcbdfa3f61d823f36f3947048fc 100644 --- a/src/QUI/ERP/Shipping/Products/Fields/ShippingTimeFrontendView.php +++ b/src/QUI/ERP/Shipping/Products/Fields/ShippingTimeFrontendView.php @@ -105,4 +105,29 @@ public function create() return $Engine->fetch(\dirname(__FILE__).'/ShippingTimePeriodFrontendView.html'); } + + /** + * Return the current value + * + * @return string|array + */ + public function getValue() + { + if (!empty($this->value['option']) && $this->value['option'] === ShippingTimePeriod::OPTION_USE_DEFAULT) { + try { + $Conf = QUI::getPackage('quiqqer/shipping')->getConfig(); + } catch (\Exception $Exception) { + QUI\System\Log::writeException($Exception); + return null; + } + + $defaultValue = $Conf->get('shipping', 'deliveryTimeDefault'); + + if (!empty($defaultValue)) { + return \json_decode($defaultValue, true); + } + } + + return parent::getValue(); + } } diff --git a/src/QUI/ERP/Shipping/Products/Fields/ShippingTimePeriod.php b/src/QUI/ERP/Shipping/Products/Fields/ShippingTimePeriod.php index c9bfbea3241dcd74c3b9797563762c2cf3b6af5d..2a29ec02a41215b0773b8fda1f112fdd822956ee 100644 --- a/src/QUI/ERP/Shipping/Products/Fields/ShippingTimePeriod.php +++ b/src/QUI/ERP/Shipping/Products/Fields/ShippingTimePeriod.php @@ -18,6 +18,7 @@ class ShippingTimePeriod extends TimePeriod const OPTION_ON_REQUEST = 'on_request'; const OPTION_AVAILABLE_SOON = 'available_soon'; const OPTION_CUSTOM_TEXT = 'custom_text'; + const OPTION_USE_DEFAULT = 'use_default'; /** * Check the value @@ -92,6 +93,7 @@ public function cleanup($value) case self::OPTION_IMMEDIATELY_AVAILABLE: case self::OPTION_ON_REQUEST: case self::OPTION_AVAILABLE_SOON: + case self::OPTION_USE_DEFAULT: break; case self::OPTION_CUSTOM_TEXT: