diff --git a/bin/backend/load.js b/bin/backend/load.js index c9bdba66e7bf2cfc559489fa5a7087e13f540760..73e908f21236790df8bd829330e1f0d655bffbf9 100644 --- a/bin/backend/load.js +++ b/bin/backend/load.js @@ -1,5 +1,3 @@ -console.log('load shipping'); - require(['qui/QUI'], function (QUI) { "use strict"; @@ -39,7 +37,7 @@ require(['qui/QUI'], function (QUI) { events: { onSubmit: function (Instance, value) { PriceFactorWindow.Loader.show(); - + const currency = ArticleList.getAttribute('currency'); const vat = 19; let shippingData; diff --git a/locale.xml b/locale.xml index 29fcb90f9f9417ef902f4adeda0aab99a92b5a03..0287a871d484f07b1ebf5922b9a723b45a182689 100644 --- a/locale.xml +++ b/locale.xml @@ -293,6 +293,35 @@ <p class="content-message-information">Please note: The delivery times only allow an estimated time of arrival after shipping!</p>]]> </en> </locale> + + <locale name="shipping.defaultShipping.settings.title"> + <de><![CDATA[Standard Versand]]></de> + <en><![CDATA[Default shipping]]></en> + </locale> + <locale name="shipping.defaultShipping.settings.defaultShipping"> + <de><![CDATA[Standard Versand]]></de> + <en><![CDATA[Default shipping]]></en> + </locale> + <locale name="shipping.defaultShipping.settings.defaultShipping.desc"> + <de><![CDATA[Lege fest welcher Versand als Standard Versand verwendet werden soll.]]></de> + <en><![CDATA[Specify which shipping should be used as default shipping.]]></en> + </locale> + <locale name="shipping.defaultShipping.settings.addDefaultShipping"> + <de><![CDATA[Standard Versand automatisch hinzufügen]]></de> + <en><![CDATA[Add standard shipping automatically]]></en> + </locale> + <locale name="shipping.defaultShipping.settings.addDefaultShipping.desc"> + <de><![CDATA[ + Der Standard Versand wird einer Bestellung hinzugefügt falls diese Bestellung noch keinen Versand hat. + Diese Einstellung hat nur Auswirkung im Backend und nicht auf Frontend Aktionen. + Wenn ein Nutzer eine Bestellung ausführt, wird dieser Versand nicht beachtet. + ]]></de> + <en><![CDATA[ + The default shipping will be added to an order if this order has no shipping yet. + This setting has effect only in backend and not on frontend actions. + When a user executes an order, this shipping is ignored. + ]]></en> + </locale> </groups> <groups name="quiqqer/shipping" datatype="php"> diff --git a/settings.xml b/settings.xml index e52baba9ab4a90392fb00e87df102450b4a4ae43..aa87a05c6908a2c0ea58bb8670c547319db8b138 100644 --- a/settings.xml +++ b/settings.xml @@ -24,6 +24,14 @@ <type><![CDATA[bool]]></type> <defaultvalue>0</defaultvalue> </conf> + + <conf name="defaultShipping"> + <type><![CDATA[integer]]></type> + </conf> + <conf name="addDefaultShipping"> + <type><![CDATA[bool]]></type> + <defaultvalue>0</defaultvalue> + </conf> </section> <section name="no_rules"> @@ -103,10 +111,12 @@ <input type="checkbox" conf="shipping.showShippingInfoAfterPrice"> <text> - <locale group="quiqqer/shipping" var="shipping.settings.showShippingInfoAfterPrice.enable"/> + <locale group="quiqqer/shipping" + var="shipping.settings.showShippingInfoAfterPrice.enable"/> </text> <description> - <locale group="quiqqer/shipping" var="shipping.settings.showShippingInfoAfterPrice.enable.description"/> + <locale group="quiqqer/shipping" + var="shipping.settings.showShippingInfoAfterPrice.enable.description"/> </description> </input> @@ -142,6 +152,39 @@ </input> </settings> + <settings title="defaultShipping" name="defaultShipping"> + <title> + <locale group="quiqqer/shipping" var="shipping.defaultShipping.settings.title"/> + </title> + + <input conf="shipping.defaultShipping" + data-qui="package/quiqqer/shipping/bin/backend/controls/ShippingSelect" + data-qui-options-multiple="0" + data-qui-options-max="1" + > + <text> + <locale group="quiqqer/shipping" + var="shipping.defaultShipping.settings.defaultShipping"/> + </text> + <description> + <locale group="quiqqer/shipping" + var="shipping.defaultShipping.settings.defaultShipping.desc"/> + </description> + </input> + + <input conf="shipping.addDefaultShipping" type="checkbox"> + <text> + <locale group="quiqqer/shipping" + var="shipping.defaultShipping.settings.addDefaultShipping"/> + </text> + <description> + <locale group="quiqqer/shipping" + var="shipping.defaultShipping.settings.addDefaultShipping.desc"/> + </description> + </input> + </settings> + + <settings title="mail" name="mail"> <title> <locale group="quiqqer/shipping" var="shipping.mail.settings.title"/> diff --git a/src/QUI/ERP/Shipping/EventHandler.php b/src/QUI/ERP/Shipping/EventHandler.php index f97654ef8acb897dbde9c50764c72a61c77a2e5b..fd0a3d252b25ae7ab8052d088ea17a5700c7970b 100644 --- a/src/QUI/ERP/Shipping/EventHandler.php +++ b/src/QUI/ERP/Shipping/EventHandler.php @@ -500,4 +500,31 @@ public static function onQuiqqerProductsPriceEnd(Collector $Collector, QUI\ERP\P $Collector->append($html); } + + /** + * @param \QUI\ERP\Order\AbstractOrder $Order + * @return void + * + * @throws \QUI\Exception + */ + public static function onQuiqqerOrderShippingOnEmpty(QUI\ERP\Order\AbstractOrder $Order) + { + if (!QUI::isBackend()) { + return; + } + + $Config = QUI::getPackage('quiqqer/shipping')->getConfig(); + $default = $Config->getValue('shipping', 'defaultShipping'); + $add = $Config->getValue('shipping', 'addDefaultShipping'); + + if (empty($add)) { + return; + } + + try { + $Shipping = Shipping::getInstance()->getShippingEntry($default); + $Order->setShipping($Shipping); + } catch (QUI\Exception $Exception) { + } + } }