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

Merge branch 'next-1.x' into '1.x'

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

See merge request !39
Übergeordnete b5b09c3d a7ba3020
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. 16815 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