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

fix: migration of all v2 fixes of the order guest module

This commit addresses two main issues in `EventHandler.php`.
Firstly, the fetching of the email from the `GuestOrder` session is moved at a different location
in the flow where it makes more sense and doesn't get overridden prematurely.

Secondly, an exhaustive condition handling has been added to address cases where there might be a
payment error or async payment error. The method fetches the current order via the URL hash which
could be an `OrderInProcess` or an already existing `Order`.

The commit also ensures that the customer UUID is set correctly if the session exists. An update is
made to the database to accommodate this change.

Minor changes have also been made to spacing and data-type declaration in `GuestOrderUser.php` to
help with readability and consistency.

Related: #11
Übergeordneter c70e550c
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
1 Merge Request!39fix: migration of all v2 fixes of the order guest module
Pipeline-Nr. 16814 mit Warnungen bestanden
......@@ -3,6 +3,7 @@
<global>
<table name="orders_process">
<field type="VARCHAR(250) NULL DEFAULT NULL">guestOrder</field>
<index>guestOrder</index>
</table>
</global>
</database>
\ No newline at end of file
......@@ -136,6 +136,8 @@ public static function onOrderProcessGetOrder($OrderProcess): ?AbstractOrder
isset($_REQUEST['step']) && $_REQUEST['step'] === 'Processing'
|| $OrderProcess->getAttribute('step') === 'Processing'
) {
$email = QUI::getSession()->get(GuestOrder::EMAIL);
$result = QUI::getDataBase()->fetch([
'from' => $Handler->table(),
'where' => [
......@@ -149,7 +151,6 @@ public static function onOrderProcessGetOrder($OrderProcess): ?AbstractOrder
if (isset($result[0])) {
$customer = $result[0]['customer'];
$customer = json_decode($customer, true);
$email = QUI::getSession()->get(GuestOrder::EMAIL);
if ($customer['email'] === $email) {
if (isset($customer['id'])) {
......@@ -158,7 +159,43 @@ public static function onOrderProcessGetOrder($OrderProcess): ?AbstractOrder
try {
return $Handler->get($result[0]['id']);
} catch (\Exception) {
} catch (\Exception $exception) {
}
}
} else {
// order is already in process status
// maybe payment error or async payment with error
// we have to get the current order via the url hash
// problem is, it could be an OrderInProcess or already an Order
if (isset($_REQUEST['orderHash'])) {
try {
$Order = $Handler->getOrderByHash($_REQUEST['orderHash']);
$Customer = $Order->getCustomer();
$Address = $Customer->getStandardAddress();
$mailList = $Address->getMailList();
$customerMail = null;
if (!empty($mailList)) {
$customerMail = $mailList[0];
}
if ($customerMail === $email) {
QUI::getSession()->set(GuestOrder::CUSTOMER_ID, $Customer->getId());
$table = $Handler->table();
if ($Order instanceof QUI\ERP\Order\OrderInProcess) {
$table = $Handler->tableOrderProcess();
}
QUI::getDataBase()->update(
$table,
['c_user' => QUI::getSession()->get(GuestOrder::CUSTOMER_ID)],
['id' => $Order->getId()]
);
return $Order;
}
} catch (\Exception $exception) {
}
}
}
......@@ -201,6 +238,17 @@ public static function onOrderProcessGetOrder($OrderProcess): ?AbstractOrder
}
try {
// maybe we have to set the customer uuid
// only if session exists
if (QUI::getSession()->get(GuestOrder::CUSTOMER_ID)) {
// cUser ändern
QUI::getDataBase()->update(
$Handler->tableOrderProcess(),
['c_user' => QUI::getSession()->get(GuestOrder::CUSTOMER_ID)],
['id' => $orderId]
);
}
return $Handler->getOrderInProcess($orderId);
} catch (\Exception $exception) {
return null;
......@@ -343,7 +391,7 @@ public static function onQuiqqerOrderCreated(AbstractOrder $Order): void
QUI::getSession()->set('guest-order-id', $Order->getId());
}
} catch (\Exception) {
} catch (\Exception $exception) {
}
}
......
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