/** * Retrieve name data * * @param Mage_Sales_Model_Order $order * @return array */ public function getNameData(Mage_Sales_Model_Order $order) { $dob = ''; if (!is_null($order->getCustomerDob())) { $dob = new Zend_Date($order->getCustomerDob()); $dob = $dob->toString("yyyy-MM-dd"); } $data = array('first_name' => $order->getBillingAddress()->getFirstname(), 'last_name' => $order->getBillingAddress()->getLastname(), 'sex' => $this->getGender($order), 'dob' => $dob, 'company' => $order->getBillingAddress()->getCompany(), 'salutation' => $this->getPrefix($order)); return $data; }
/** * @return array */ protected function _prepareCustomerData() { $customer_id = null; $customer = null; $customer_log = null; $billing_address = $this->_order->getBillingAddress(); $customer_verified = false; $customer_orders_count = 0; $gender = $this->_order->getCustomerGender(); if (!$this->_order->getCustomerIsGuest()) { $customer_id = $this->_order->getCustomerId(); if ($customer_id) { /** @var Mage_Customer_Model_Customer $customer */ $customer = Mage::getModel("customer/customer"); $customer->load($customer_id); /** @var Mage_Log_Model_Customer $customer_log */ $customer_log = Mage::getModel('log/customer')->load($customer_id); } $customer_verified = $this->getCustomerIsConfirmedStatus($customer); $orders = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('customer_id', $customer_id); /** @noinspection PhpUndefinedMethodInspection */ $customer_orders_count = $orders->count(); } $data = array_filter(array('customer_id' => $customer_id, 'customer_is_guest' => $this->_order->getCustomerIsGuest(), 'verified' => $customer_verified, 'language_code' => $this->_language_code, 'last_login_on' => $customer_log ? $customer_log->getLoginAt() : null, 'created_on' => $customer ? $customer->getData('created_at') : null, 'updated_on' => $customer ? $customer->getData('updated_at') : null, 'birthdate' => $this->_order->getCustomerDob(), 'email' => $this->_order->getCustomerEmail(), 'title' => '', 'prefix' => $this->_order->getCustomerPrefix(), 'suffix' => $this->_order->getCustomerSuffix(), 'first_name' => $this->_order->getCustomerFirstname(), 'middle_name' => $this->_order->getCustomerMiddlename(), 'last_name' => $this->_order->getCustomerLastname(), 'company_name' => $billing_address ? $billing_address->getCompany() : null, 'gender' => $gender == 1 ? 'male' : ($gender == 2 ? 'female' : null), 'telephone1' => $billing_address ? $billing_address->getTelephone() : null, 'telephone2' => '', 'telephone3' => '', 'fax' => $billing_address ? $billing_address->getFax() : null, 'vat_number' => $this->_order->getCustomerTaxvat(), 'reg_ip_address' => '', 'customer_orders_count' => $customer_orders_count)); return $data; }
/** * Gets the Day of Birth from the Quote or Order if guest, else from the customer * * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $quote * @return String */ public function getDob($quote) { return $quote->getCustomerDob(); }
function CreateMagentoShopRequestOrder(Mage_Sales_Model_Order $order, $paymentmethod) { $request = new Byjuno_Cdp_Helper_Api_Classes_ByjunoRequest(); $request->setClientId(Mage::getStoreConfig('payment/cdp/clientid', Mage::app()->getStore())); $request->setUserID(Mage::getStoreConfig('payment/cdp/userid', Mage::app()->getStore())); $request->setPassword(Mage::getStoreConfig('payment/cdp/password', Mage::app()->getStore())); $request->setVersion("1.00"); try { $request->setRequestEmail(Mage::getStoreConfig('payment/cdp/mail', Mage::app()->getStore())); } catch (Exception $e) { } $b = $order->getCustomerDob(); if (!empty($b)) { $request->setDateOfBirth(Mage::getModel('core/date')->date('Y-m-d', strtotime($b))); } $g = $order->getCustomerGender(); if (!empty($g)) { if ($g == '1') { $request->setGender('1'); } else { if ($g == '2') { $request->setGender('2'); } } } $requestId = uniqid((string) $order->getBillingAddress()->getId() . "_"); $request->setRequestId($requestId); $reference = $order->getCustomerId(); if (empty($reference)) { $request->setCustomerReference("guest_" . $order->getBillingAddress()->getId()); } else { $request->setCustomerReference($order->getCustomerId()); } $request->setFirstName((string) $order->getBillingAddress()->getFirstname()); $request->setLastName((string) $order->getBillingAddress()->getLastname()); $request->setFirstLine(trim((string) $order->getBillingAddress()->getStreetFull())); $request->setCountryCode(strtoupper((string) $order->getBillingAddress()->getCountry())); $request->setPostCode((string) $order->getBillingAddress()->getPostcode()); $request->setTown((string) $order->getBillingAddress()->getCity()); $request->setFax((string) trim($order->getBillingAddress()->getFax(), '-')); $request->setLanguage((string) substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2)); if ($order->getBillingAddress()->getCompany()) { $request->setCompanyName1($order->getBillingAddress()->getCompany()); } $request->setTelephonePrivate((string) trim($order->getBillingAddress()->getTelephone(), '-')); $request->setEmail((string) $order->getBillingAddress()->getEmail()); $extraInfo["Name"] = 'ORDERCLOSED'; $extraInfo["Value"] = 'NO'; $request->setExtraInfo($extraInfo); $extraInfo["Name"] = 'ORDERAMOUNT'; $extraInfo["Value"] = number_format($order->getGrandTotal(), 2, '.', ''); $request->setExtraInfo($extraInfo); $extraInfo["Name"] = 'ORDERCURRENCY'; $extraInfo["Value"] = $order->getBaseCurrencyCode(); $request->setExtraInfo($extraInfo); /* shipping information */ if ($order->canShip()) { $extraInfo["Name"] = 'DELIVERY_FIRSTNAME'; $extraInfo["Value"] = $order->getShippingAddress()->getFirstname(); $request->setExtraInfo($extraInfo); $extraInfo["Name"] = 'DELIVERY_LASTNAME'; $extraInfo["Value"] = $order->getShippingAddress()->getLastname(); $request->setExtraInfo($extraInfo); $extraInfo["Name"] = 'DELIVERY_FIRSTLINE'; $extraInfo["Value"] = trim($order->getShippingAddress()->getStreetFull()); $request->setExtraInfo($extraInfo); $extraInfo["Name"] = 'DELIVERY_HOUSENUMBER'; $extraInfo["Value"] = ''; $request->setExtraInfo($extraInfo); $extraInfo["Name"] = 'DELIVERY_COUNTRYCODE'; $extraInfo["Value"] = strtoupper($order->getShippingAddress()->getCountry()); $request->setExtraInfo($extraInfo); $extraInfo["Name"] = 'DELIVERY_POSTCODE'; $extraInfo["Value"] = $order->getShippingAddress()->getPostcode(); $request->setExtraInfo($extraInfo); $extraInfo["Name"] = 'DELIVERY_TOWN'; $extraInfo["Value"] = $order->getShippingAddress()->getCity(); $request->setExtraInfo($extraInfo); if ($order->getShippingAddress()->getCompany() != '' && Mage::getStoreConfig('payment/api/businesstobusiness', Mage::app()->getStore()) == 'enable') { $extraInfo["Name"] = 'DELIVERY_COMPANYNAME'; $extraInfo["Value"] = $order->getShippingAddress()->getCompany(); $request->setExtraInfo($extraInfo); } } $extraInfo["Name"] = 'PP_TRANSACTION_NUMBER'; $extraInfo["Value"] = $requestId; $request->setExtraInfo($extraInfo); $extraInfo["Name"] = 'ORDERID'; $extraInfo["Value"] = $order->getIncrementId(); $request->setExtraInfo($extraInfo); $extraInfo["Name"] = 'PAYMENTMETHOD'; $extraInfo["Value"] = 'BYJUNO-INVOICE'; $request->setExtraInfo($extraInfo); $extraInfo["Name"] = 'CONNECTIVTY_MODULE'; $extraInfo["Value"] = 'Byjuno Magento module 1.0.0'; $request->setExtraInfo($extraInfo); return $request; }
/** * Gets all needed Informations for customer Block of the Request * * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $quoteOrOrder * @return array */ public function getRequestCustomer($quoteOrOrder) { $customer = array(); $contacts = array(); $billing = array(); $shipping = array(); $dob = new Zend_Date($quoteOrOrder->getCustomerDob()); $customer['dob'] = $dob->toString("yyyy-MM-dd"); $customer['gender'] = $this->getHelper()->getGenderCode($quoteOrOrder); $customer['firstName'] = $quoteOrOrder->getBillingAddress()->getFirstname(); $customer['lastName'] = $quoteOrOrder->getBillingAddress()->getLastname(); $customer['ip'] = Mage::helper('core/http')->getRemoteAddr(false); $customer['nationality'] = $quoteOrOrder->getBillingAddress()->getCountryId(); $customer['company'] = $quoteOrOrder->getBillingAddress()->getCompany(); $customer['vatId'] = $quoteOrOrder->getCustomerTaxvat(); $contacts['email'] = $quoteOrOrder->getCustomerEmail(); $contacts['phone'] = $quoteOrOrder->getBillingAddress()->getTelephone(); if ($quoteOrOrder->getBillingAddress()->getFax() != '') { $contacts['fax'] = $quoteOrOrder->getBillingAddress()->getFax(); } // Different handling of street fields in case of NL orders $billingStreetFull = $quoteOrOrder->getBillingAddress()->getStreetFull(); $billingStreet1 = $quoteOrOrder->getBillingAddress()->getStreet1(); $billingStreet2 = $quoteOrOrder->getBillingAddress()->getStreet2(); if ($quoteOrOrder->getBillingAddress()->getCountryId() == "NL" && !empty($billingStreet2)) { $billing['street'] = $billingStreet1; $billing['streetAdditional'] = $billingStreet2; } else { $billing['street'] = preg_replace('~[\\r\\n]+~', ' ', $billingStreetFull); } $billing['zipCode'] = $quoteOrOrder->getBillingAddress()->getPostcode(); $billing['city'] = $quoteOrOrder->getBillingAddress()->getCity(); $billing['countryId'] = $quoteOrOrder->getBillingAddress()->getCountryId(); $shipping['firstName'] = $quoteOrOrder->getShippingAddress()->getFirstname(); $shipping['lastName'] = $quoteOrOrder->getShippingAddress()->getLastname(); // Different handling of street fields in case of NL orders $shippingStreetFull = $quoteOrOrder->getShippingAddress()->getStreetFull(); $shippingStreet1 = $quoteOrOrder->getShippingAddress()->getStreet1(); $shippingStreet2 = $quoteOrOrder->getShippingAddress()->getStreet2(); if ($quoteOrOrder->getShippingAddress()->getCountryId() == "NL" && !empty($shippingStreet2)) { $shipping['street'] = $shippingStreet1; $shipping['streetAdditional'] = $shippingStreet2; } else { $shipping['street'] = preg_replace('~[\\r\\n]+~', ' ', $shippingStreetFull); } $shipping['zipCode'] = $quoteOrOrder->getShippingAddress()->getPostcode(); $shipping['city'] = $quoteOrOrder->getShippingAddress()->getCity(); $shipping['countryId'] = $quoteOrOrder->getShippingAddress()->getCountryId(); if ($quoteOrOrder->getShippingAddress()->getCompany()) { $shipping['company'] = $quoteOrOrder->getShippingAddress()->getCompany(); } $customer['contacts'] = $contacts; $customer['billing'] = $billing; $customer['shipping'] = $shipping; return $customer; }