Skip to content
Code-Schnipsel Gruppen Projekte
Commit ac5b2d2f erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

feat: add new events for simple checkout process

This commit introduces two new events, `onQuiqqerSimpleCheckoutBodyEnd` and
`onQuiqqerSimpleCheckoutValidation`. The functions associated with these events handle the logic of
the checkout process for guests, specifically concerning the display and validation of delivery,
shipping, and billing addresses based on whether the order is anonymous and does not exceed a
certain sum. The total sum is retrieved from the configuration of the `quiqqer/order-guestorder`
package.
Übergeordneter 613577c9
Branches next-2.x
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
Pipeline-Nr. 16835 mit Warnungen bestanden
......@@ -11,6 +11,9 @@
<event on="onQuiqqerOrderProcessingStart" fire="\QUI\ERP\Order\Guest\EventHandler::onQuiqqerOrderProcessSend"/>
<event on="onQuiqqerOrderCreated" fire="\QUI\ERP\Order\Guest\EventHandler::onQuiqqerOrderCreated"/>
<event on="onQuiqqerSimpleCheckoutBodyEnd" fire="\QUI\ERP\Order\Guest\EventHandler::onQuiqqerSimpleCheckoutBodyEnd"/>
<event on="onQuiqqerSimpleCheckoutValidation" fire="\QUI\ERP\Order\Guest\EventHandler::onQuiqqerSimpleCheckoutValidation"/>
<event on="onQuiqqer::order::orderProcessCheckoutEnd" fire="\QUI\ERP\Order\Guest\EventHandler::extendCheckout"/>
<event on="onQuiqqer::order::mail::orderConfirmation::end" fire="\QUI\ERP\Order\Guest\EventHandler::extendMail"/>
</events>
\ No newline at end of file
......@@ -543,6 +543,89 @@ public static function onQuiqqerOrderProcessStepsEnd(
}
}
public static function onQuiqqerSimpleCheckoutBodyEnd(
QUI\ERP\Order\SimpleCheckout\Checkout $checkout,
bool &$showDelivery,
bool &$showShipping,
bool &$showBillingAddress
): void {
if (!GuestOrder::isActive()) {
return;
}
if (!GuestOrder::isAnonymousOrder()) {
return;
}
try {
$order = $checkout->getOrder();
} catch (QUI\Exception) {
return;
}
if (!$order) {
return;
}
$calculations = $order->getArticles()->getCalculations();
$sum = $calculations['sum'];
$maxTotal = QUI::getPackage('quiqqer/order-guestorder')->getConfig()->getValue(
'guestorder',
'anonymous_max_sum'
);
$maxTotal = floatval($maxTotal);
if (!empty($maxTotal) && $sum > $maxTotal) {
return;
}
$showDelivery = false;
$showShipping = false;
$showBillingAddress = false;
}
public static function onQuiqqerSimpleCheckoutValidation(
QUI\ERP\Order\SimpleCheckout\Checkout $checkout,
bool &$validateAddress,
bool &$validateShipping
): void {
if (!GuestOrder::isActive()) {
return;
}
if (!GuestOrder::isAnonymousOrder()) {
return;
}
try {
$order = $checkout->getOrder();
} catch (QUI\Exception) {
return;
}
if (!$order) {
return;
}
$calculations = $order->getArticles()->getCalculations();
$sum = $calculations['sum'];
$maxTotal = QUI::getPackage('quiqqer/order-guestorder')->getConfig()->getValue(
'guestorder',
'anonymous_max_sum'
);
$maxTotal = floatval($maxTotal);
if (!empty($maxTotal) && $sum > $maxTotal) {
return;
}
$validateAddress = false;
}
//endregion
//region extend templates
......
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren