From 1a6900d07e0018f5785ef0f6174a797821eb699b Mon Sep 17 00:00:00 2001 From: iesus Date: Thu, 21 Dec 2017 10:19:47 +0100 Subject: [PATCH] insert email if missing on order, and exists on sveaorder when we get authorization request --- .../community/Svea/Checkout/Model/Payment/Acknowledge.php | 6 ++++++ .../community/Svea/Checkout/Model/Payment/CreateOrder.php | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/code/community/Svea/Checkout/Model/Payment/Acknowledge.php b/app/code/community/Svea/Checkout/Model/Payment/Acknowledge.php index f9b2a02..f3f743b 100755 --- a/app/code/community/Svea/Checkout/Model/Payment/Acknowledge.php +++ b/app/code/community/Svea/Checkout/Model/Payment/Acknowledge.php @@ -83,6 +83,11 @@ public function acknowledge($quote, $mode, $sveaId) ->setState(Mage_Sales_Model_Order::STATE_NEW, $status, $message, false) ->save(); $magentoOrder->getSendConfirmation(null); + + if (empty(trim($magentoOrder->getCustomerEmail())) && !empty($sveaData->getData('EmailAddress'))) { + $magentoOrder->setCustomerEmail($sveaData->getData('EmailAddress')); + } + $magentoOrder->sendNewOrderEmail(); $orderQueueItem = Mage::getModel('sveacheckout/queue')->load($quote->getId(), 'quote_id'); @@ -116,6 +121,7 @@ public function acknowledge($quote, $mode, $sveaId) $payment->setAdditionalInformation($info)->save(); $payment->setTransactionId("{$id}-{$type}"); + $magentoOrder->save(); $adapter->commit(); $logger->writeToLog('Payment transaction was created for order ' . $magentoOrder->getId()); diff --git a/app/code/community/Svea/Checkout/Model/Payment/CreateOrder.php b/app/code/community/Svea/Checkout/Model/Payment/CreateOrder.php index 3f81fd3..480fecb 100755 --- a/app/code/community/Svea/Checkout/Model/Payment/CreateOrder.php +++ b/app/code/community/Svea/Checkout/Model/Payment/CreateOrder.php @@ -115,7 +115,11 @@ protected function _addAddressToQuote($quote, $data) $billingAddress = new Varien_Object($data->getData('BillingAddress')); $shippingAddress = new Varien_Object($data->getData('ShippingAddress')); $customer = new Varien_Object($data->getData('Customer')); - $reference = ($customer->getData('CustomerReference')) + + $reference = ($data->getData('CustomerReference')) + ? ($data->getData('CustomerReference')) + : false; + $reference = (!$reference && $customer->getData('CustomerReference')) ? ($customer->getData('CustomerReference')) : false; $billingFirstname = ($billingAddress->getData('FirstName'))