/** * Export the customer */ protected function exportCustomer() { $Customer = $this->Order->getCustomer(); $Billing = $this->Order->getBilling(); $Shipping = $this->Order->getShipping(); // try { $PlentymarketsExportEntityOrderCustomer = new PlentymarketsExportEntityCustomer($Customer, $Billing, $Shipping); $PlentymarketsExportEntityOrderCustomer->export(); } catch (PlentymarketsExportEntityException $E) { // Save the error $this->setError(self::CODE_ERROR_CUSTOMER); // Throw another exception throw new PlentymarketsExportEntityException('The order with the number »' . $this->Order->getNumber() . '« could not be exported (' . $E->getMessage() . ')', 4100); } // $this->PLENTY_customerID = $PlentymarketsExportEntityOrderCustomer->getPlentyCustomerID(); $this->PLENTY_addressDispatchID = $PlentymarketsExportEntityOrderCustomer->getPlentyAddressDispatchID(); }
/** * @param \Shopware\Models\Order\Order $orderModel * @return array */ private function prepareOrderConfirmationMailData($orderModel) { $billingAddress = Shopware()->Db()->fetchRow('SELECT *, userID AS customerBillingId FROM s_order_billingaddress WHERE orderID = ?', [$orderModel->getId()]); $billingAddressAttributes = Shopware()->Db()->fetchRow('SELECT * FROM s_order_billingaddress_attributes WHERE billingID = ?', [$billingAddress['id']]); if (!empty($billingAddressAttributes)) { $billingAddress = array_merge($billingAddress, $billingAddressAttributes); } /** @var \Shopware_Components_CreateBackendOrder $createBackendOrder */ $createBackendOrder = Shopware()->CreateBackendOrder(); if ($createBackendOrder->getEqualBillingAddress()) { $shippingAddress = $billingAddress; } else { $shippingAddress = Shopware()->Db()->fetchRow('SELECT *, userID AS customerBillingId FROM s_order_shippingaddress WHERE orderID = ?', [$orderModel->getId()]); $shippingAddressAttributes = Shopware()->Db()->fetchRow('SELECT * FROM s_order_shippingaddress_attributes WHERE shippingID = ?', [$shippingAddress['id']]); if (!empty($shippingAddressAttributes)) { $shippingAddress = array_merge($shippingAddress, $shippingAddressAttributes); } } $context['billingaddress'] = $billingAddress; $context['shippingaddress'] = $shippingAddress; $context['sOrderNumber'] = $orderModel->getNumber(); $currency = $orderModel->getCurrency(); $context['sCurrency'] = $currency; $context['sAmount'] = $orderModel->getInvoiceAmount() . ' ' . $currency; $context['sAmountNet'] = $orderModel->getInvoiceAmountNet() . ' ' . $currency; $context['sShippingCosts'] = $orderModel->getInvoiceShipping() . ' ' . $currency; $orderTime = $orderModel->getOrderTime(); $context['sOrderDay'] = $orderTime->format('d.m.Y'); $context['sOrderTime'] = $orderTime->format('H:i'); $context['sComment'] = ''; $context['sLanguage'] = $orderModel->getLanguageSubShop()->getId(); $context['sSubShop'] = $orderModel->getShop()->getId(); $orderAttributes = Shopware()->Db()->fetchRow('SELECT * FROM s_order_attributes WHERE orderID = ?', [$orderModel->getId()]); $context['attributes'] = $orderAttributes; $dispatch = Shopware()->Db()->fetchRow('SELECT * FROM s_premium_dispatch WHERE id = ?', [$orderModel->getDispatch()->getId()]); $dispatch = $this->translateDispatch($dispatch, $orderModel->getLanguageSubShop()->getId()); $context['sDispatch'] = $dispatch; $user = Shopware()->Db()->fetchRow('SELECT * FROM s_user WHERE id = ?', [$orderModel->getCustomer()->getId()]); $context['additional']['user'] = $user; $country = Shopware()->Db()->fetchRow('SELECT * FROM s_core_countries WHERE id = ?', [$orderModel->getBilling()->getCountry()->getId()]); $context['additional']['country'] = $country; $context['additional']['state'] = []; if ($orderModel->getBilling()->getState()) { $state = Shopware()->Db()->fetchRow('SELECT * FROM s_core_countries_states WHERE id = ?', [$orderModel->getBilling()->getState()->getId()]); $context['additional']['state'] = $state; } $country = Shopware()->Db()->fetchRow('SELECT * FROM s_core_countries WHERE id = ?', [$orderModel->getShipping()->getCountry()->getId()]); $context['additional']['countryShipping'] = $country; $context['additional']['stateShipping'] = []; if ($orderModel->getShipping()->getState()) { $state = Shopware()->Db()->fetchRow('SELECT * FROM s_core_countries_states WHERE id = ?', [$orderModel->getShipping()->getState()->getId()]); $context['additional']['stateShipping'] = $state; } $payment = Shopware()->Db()->fetchRow('SELECT * FROM s_core_paymentmeans WHERE id = ?', [$orderModel->getPayment()->getId()]); $payment = $this->translatePayment($payment, $orderModel->getLanguageSubShop()->getId()); $context['additional']['payment'] = $payment; $context['sPaymentTable'] = []; if ($context['additional']['payment']['name'] === 'debit') { $paymentTable = Shopware()->Db()->fetchRow('SELECT * FROM s_core_payment_data WHERE user_id = ?', [$orderModel->getCustomer()->getId()]); $context['sPaymentTable'] = $paymentTable; } $context['additional']['show_net'] = $orderModel->getNet(); $context['additional']['charge_var'] = 1; return $context; }