Skip to content
Code-Schnipsel Gruppen Projekte
Commit 638386b9 erstellt von Patrick Müller's avatar Patrick Müller
Dateien durchsuchen

fix: possible fix for #35

Übergeordneter de0ef8df
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
......@@ -12,6 +12,9 @@
<event on="onQuiqqerOrderCustomerDataSave"
fire="\QUI\ERP\Shipping\EventHandler::onQuiqqerOrderCustomerDataSave"
/>
<event on="onQuiqqerOrderOrderProcessCheckoutOutput"
fire="\QUI\ERP\Shipping\EventHandler::onQuiqqerOrderOrderProcessCheckoutOutput"
/>
<event on="onUserSaveBegin"
fire="\QUI\ERP\Shipping\EventHandler::onUserSaveBegin"
/>
......
......@@ -8,7 +8,7 @@
use QUI;
use QUI\ERP\Products\Handler\Fields as ProductFields;
use QUI\ERP\Shipping\ShippingStatus\Handler;
use QUI\ERP\Order\Controls\OrderProcess\Checkout as OrderCheckoutStepControl;
use \Quiqqer\Engine\Collector;
/**
......@@ -210,6 +210,50 @@ public static function onOrderProcessCustomerDataEnd(
$Collector->append($Control->create());
}
/**
* quiqqer/order: onQuiqqerOrderOrderProcessCheckoutOutput
*
* @param OrderCheckoutStepControl $Checkout
* @param string $text
* @return void
*/
public static function onQuiqqerOrderOrderProcessCheckoutOutput(OrderCheckoutStepControl $Checkout, string $text)
{
if (Shipping::getInstance()->shippingDisabled()) {
return;
}
$Order = $Checkout->getOrder();
if (!$Order) {
return;
}
$DeliveryAddress = $Order->getDeliveryAddress();
if ($DeliveryAddress->getId() === 0) {
$customerId = $Order->getCustomer()->getId();
$Customer = QUI::getUsers()->get($customerId);
$deliveryAddressId = $Customer->getAttribute('quiqqer.delivery.address');
if (!empty($deliveryAddressId)) {
try {
$DeliveryAddress = $Customer->getAddress($deliveryAddressId);
$ErpDeliveryAddres = new QUI\ERP\Address(
\json_decode($DeliveryAddress->toJSON(), true),
$Order->getCustomer()
);
$Order->setDeliveryAddress($ErpDeliveryAddres);
$Order->save(QUI::getUsers()->getSystemUser());
} catch (\Exception $Exception) {
QUI\System\Log::writeException($Exception);
}
}
}
}
/**
* @param QUI\ERP\Order\Controls\OrderProcess\CustomerData $CustomerData
*
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren