/** * @magentoDataFixture Mage/Adminhtml/controllers/Sales/_files/address.php */ public function testAddressActionNoVAT() { $address = new Mage_Sales_Model_Order_Address(); $address->load('a_unique_firstname', 'firstname'); $this->getRequest()->setParam('address_id', $address->getId()); $this->dispatch('admin/sales_order/address'); $html = $this->getResponse()->getBody(); $prohibitedStrings = array('validate-vat', 'validateVat', 'Validate VAT'); foreach ($prohibitedStrings as $string) { $this->assertNotContains($string, $html, 'VAT button must not be shown while editing address', true); } }
/** * * @param Mage_Sales_Model_Order_Address $address * * @return boolean */ protected function _communicateAddresUpdateToDpd(Mage_Sales_Model_Order_Address $address) { $shipsCollectionForOrder = Mage::getResourceModel('zitec_dpd/dpd_ship_collection'); /* @var $shipsCollectionForOrder Zitec_Dpd_Model_Mysql4_Dpd_Ship_Collection */ $shipsCollectionForOrder->setOrderFilter($address->getParentId()); if (!$shipsCollectionForOrder->count()) { return false; } foreach ($shipsCollectionForOrder as $ship) { /* @var $ship Zitec_Dpd_Model_Dpd_Ship */ $dpdShipment = unserialize($ship->getSaveShipmentCall()); /* @var $dpdShipmnent Zitec_Dpd_Api_Shipment_Save */ try { $response = $dpdShipment->setReceiverAddress($address)->execute(); /* @var $response Zitec_Dpd_Api_Shipment_Save_Response */ } catch (Exception $e) { Mage::throwException(sprintf($this->__('An error occurred updating the shipping address details with DPD: <br /> "%s"', $e->getMessage()))); } if ($response->hasError()) { Mage::throwException(sprintf($this->__('DPD could not update the shipment address. The following error was returned: <br /> "%s: %s"'), $response->getErrorCode(), $response->getErrorText())); } try { $labelPdfStr = $this->_getWsHelper()->getNewPdfShipmentLabelsStr($response->getDpdShipmentId(), $response->getDpdShipmentReferenceNumber()); } catch (Exception $e) { Mage::throwException(sprintf($this->__('An error occurred retrieving the updated shipping labels from DPD. <br />"s%"'), $e->getMessage())); } $ship->setSaveShipmentCall(serialize($dpdShipment))->setSaveShipmentResponse(serialize($response))->setShippingLabels(base64_encode($labelPdfStr))->save(); Mage::getModel('sales/order_shipment')->load($ship->getShipmentId())->setShippingLabel($labelPdfStr)->save(); } return true; }
/** * Set correct values on subscription address based on given subscription and order address * * @param Adyen_Subscription_Model_Subscription $subscription * @param Mage_Sales_Model_Order_Address|Mage_Sales_Model_Quote_Address $address * @return $this */ public function initAddress(Adyen_Subscription_Model_Subscription $subscription, $address) { $this->setSubscriptionId($subscription->getId()); // Reset (possible) original values $this->setOrderAddressId(null)->setCustomerAddressId(null)->setQuoteAddressId(null); if ($address->getAddressType() == Mage_Sales_Model_Order_Address::TYPE_BILLING) { $this->setType(self::ADDRESS_TYPE_BILLING); } else { $this->setType(self::ADDRESS_TYPE_SHIPPING); } // Note: Only use customer address if 'save_in_address_book' or 'same_as_billing' // is also checked at the address, because it's not enough to rely solely on the // customer address ID, because an address can be changed when creating an order // in the backend, but this ID still remains when a quote is converted to an order if ($address->getCustomerAddressId() && $address->getData('save_in_address_book')) { // Create customer address $this->setSource(self::ADDRESS_SOURCE_CUSTOMER)->setCustomerAddressId($address->getCustomerAddressId()); } elseif ($address instanceof Mage_Sales_Model_Quote_Address) { // Create quote address $this->setSource(self::ADDRESS_SOURCE_QUOTE)->setQuoteAddressId($address->getId()); } else { // Create order address $this->setSource(self::ADDRESS_SOURCE_ORDER)->setOrderAddressId($address->getId()); } return $this; }
/** * Set correct values on subscription address based on given subscription and order address * * @param Adyen_Subscription_Model_Subscription $subscription * @param Mage_Sales_Model_Order_Address|Mage_Sales_Model_Quote_Address $address * @return $this */ public function initAddress(Adyen_Subscription_Model_Subscription $subscription, $address) { $this->setSubscriptionId($subscription->getId()); // Reset (possible) original values $this->setOrderAddressId(null)->setCustomerAddressId(null)->setQuoteAddressId(null); if ($address->getAddressType() == Mage_Sales_Model_Order_Address::TYPE_BILLING) { $this->setType(self::ADDRESS_TYPE_BILLING); } else { $this->setType(self::ADDRESS_TYPE_SHIPPING); } if ($address instanceof Mage_Sales_Model_Quote_Address) { // Create quote address $this->setSource(self::ADDRESS_SOURCE_QUOTE)->setQuoteAddressId($address->getId()); } else { // Create order address $this->setSource(self::ADDRESS_SOURCE_ORDER)->setOrderAddressId($address->getId()); } return $this; }
/** * Get all tax records for this address that should were applied to * address level gifting prices. * * @return EbayEnterprise_Tax_Model_Record[] */ protected function _getAddressGiftTaxRecords() { $addressId = $this->_address->getQuoteAddressId(); // Filter down the list of tax records to only those with a matching // quote address id, with a source indicating they apply to address level // gifting, and do not indicate a calculation error for the record. return array_filter($this->_taxCollector->getTaxRecords(), function ($record) use($addressId) { return $record->getAddressId() === $addressId && $record->getTaxSource() === EbayEnterprise_Tax_Model_Record::SOURCE_ADDRESS_GIFTING; }); }
/** * After saving the order, collect the rates * @return TinyBrick_OrderEdit_Model_Order_Address */ protected function _afterSave() { parent::_afterSave(); if (null !== $this->_items) { $this->getItemsCollection()->save(); } if (null !== $this->_rates) { $this->getShippingRatesCollection()->save(); } return $this; }
public function setUp() { $this->_taxCollector = $this->getModelMock('ebayenterprise_tax/collector', ['getTaxRecords']); $this->_payloadHelper = $this->getHelperMock('ebayenterprise_tax/payload', ['taxRecordToTaxPayload']); $this->_address = $this->getModelMock('sales/order_address', ['getQuoteAddressId']); $this->_address->expects($this->any())->method('getQuoteAddressId')->will($this->returnValue($this->_quoteAddressId)); // SDK Payloads that are expected to be filled out. $this->_shipGroup = $this->getMockForAbstractClass('eBayEnterprise\\RetailOrderManagement\\Payload\\Order\\IGifting', ['getGiftPricing', 'getEmptyGiftingPriceGroup', 'setGiftPricing']); $this->_taxContainer = $this->getMockForAbstractClass('eBayEnterprise\\RetailOrderManagement\\Payload\\Order\\IPriceGroup', ['getTaxes', 'setTaxes']); $this->_taxIterable = $this->getMockForAbstractClass('eBayEnterprise\\RetailOrderManagement\\Payload\\Order\\ITaxIterable', ['offsetSet', 'getEmptyTax']); $this->_taxPayload = $this->getMockForAbstractClass('eBayEnterprise\\RetailOrderManagement\\Payload\\Order\\ITax'); // Create this as the expected tax payload to be added to the // tax iterable - assume this to be a tax payload with all data // from a tax record set to it. $this->_completeTaxPayload = $this->getMockForAbstractClass('eBayEnterprise\\RetailOrderManagement\\Payload\\Order\\ITax'); // The tax container will always return a tax iterable. $this->_taxContainer->expects($this->any())->method('getTaxes')->will($this->returnValue($this->_taxIterable)); $this->_addressGiftTax = $this->_mockTaxRecord(EbayEnterprise_Tax_Model_Record::SOURCE_ADDRESS_GIFTING, $this->_quoteAddressId); $this->_itemGiftTax = $this->_mockTaxRecord(EbayEnterprise_Tax_Model_Record::SOURCE_ITEM_GIFTING, $this->_quoteAddressId); $this->_merchGiftTax = $this->_mockTaxRecord(EbayEnterprise_Tax_Model_Record::SOURCE_MERCHANDISE, $this->_quoteAddressId); $this->_shipGroupHandler = Mage::getModel('ebayenterprise_tax/order_create_shipgroup', ['address' => $this->_address, 'ship_group' => $this->_shipGroup, 'tax_collector' => $this->_taxCollector, 'payload_helper' => $this->_payloadHelper]); }
* * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magentocommerce.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento * @package Mage_Sales * @subpackage integration_tests * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ $addressData = (include __DIR__ . '/address_data.php'); $billingAddress = new Mage_Sales_Model_Order_Address($addressData); $billingAddress->setAddressType('billing'); $shippingAddress = clone $billingAddress; $shippingAddress->setId(null)->setAddressType('shipping'); $payment = new Mage_Sales_Model_Order_Payment(); $payment->setMethod('verisign')->setCcExpMonth('5')->setCcLast4('0005')->setCcType('AE')->setCcExpYear('2016'); $order = new Mage_Sales_Model_Order(); $order->setIncrementId('100000001')->setSubtotal(100)->setBaseSubtotal(100)->setCustomerIsGuest(true)->setBillingAddress($billingAddress)->setShippingAddress($shippingAddress)->setStoreId(Mage::app()->getStore()->getId())->setPayment($payment); $order->save();
/** * @param Mage_Sales_Model_Order_Address $source * @param string $type * * @return WirecardCEE_Stdlib_ConsumerData_Address */ protected function _getAddress($source, $type = 'billing') { switch ($type) { case 'shipping': $address = new WirecardCEE_Stdlib_ConsumerData_Address(WirecardCEE_Stdlib_ConsumerData_Address::TYPE_SHIPPING); break; default: $address = new WirecardCEE_Stdlib_ConsumerData_Address(WirecardCEE_Stdlib_ConsumerData_Address::TYPE_BILLING); break; } $address->setFirstname($source->getFirstname()); $address->setLastname($source->getLastname()); $address->setAddress1($source->getStreet1()); $address->setAddress2($source->getStreet2()); $address->setZipCode($source->getPostcode()); $address->setCity($source->getCity()); $address->setCountry($source->getCountry()); $address->setState($source->getRegionCode()); $address->setPhone($source->getTelephone()); $address->setFax($source->getFax()); return $address; }
/** * Create address request data * * @param Mage_Sales_Model_Order_Address $address * @return array */ protected function _getAddressInfo($address) { $result = array(); foreach ($this->_addressFileds as $addressField) { if ($address->hasData($addressField)) { $result[$addressField] = $address->getData($addressField); } } //Streets must be transfered separately $streets = $address->getStreet(); $result['street'] = array_shift($streets); if ($street2 = array_shift($streets)) { $result['street2'] = $street2; } //Region code lookup $region = Mage::getModel('directory/region')->load($address->getData('region_id')); if ($region && $region->getId()) { $result['region'] = $region->getCode(); } else { $result['region'] = $address->getRegion(); } return $result; }
/** * @param Mage_Sales_Model_Order_Address $address * @return array */ protected function _getShopgateAddressFromOrderAddress($address) { $shopgateAddress = new ShopgateAddress(); $shopgateAddress->setFirstName($address->getFirstname()); $shopgateAddress->setLastName($address->getLastname()); $shopgateAddress->setGender($this->_getCustomerHelper()->getShopgateCustomerGender($address)); $shopgateAddress->setCompany($address->getCompany()); $shopgateAddress->setPhone($address->getTelephone()); $shopgateAddress->setStreet1($address->getStreet1()); $shopgateAddress->setStreet2($address->getStreet2()); $shopgateAddress->setCity($address->getCity()); $shopgateAddress->setZipcode($address->getPostcode()); $shopgateAddress->setCountry($address->getCountry()); $shopgateAddress->setState($this->_getHelper()->getIsoStateByMagentoRegion($address)); return $shopgateAddress->toArray(); }
public function addAddress(Mage_Sales_Model_Order_Address $address) { $address->setOrder($this)->setParentId($this->getId()); if (!$address->getId()) { $this->getAddressesCollection()->addItem($address); } return $this; }
/** * Check if the address is a billing address. * * @param Mage_Sales_Model_Order_Address * @return bool */ protected function _isAddressBillingAddress(Mage_Sales_Model_Order_Address $address) { return $address->getAddressType() === Mage_Sales_Model_Order_Address::TYPE_BILLING; }
/** * Import address data from order address * * @param Mage_Sales_Model_Order_Address $address * @return Mage_Sales_Model_Quote_Address */ public function importOrderAddress(Mage_Sales_Model_Order_Address $address) { $this->setAddressType($address->getAddressType())->setCustomerId($address->getCustomerId())->setCustomerAddressId($address->getCustomerAddressId())->setEmail($address->getEmail()); Mage::helper('Mage_Core_Helper_Data')->copyFieldset('sales_convert_order_address', 'to_quote_address', $address, $this); return $this; }
/** * Convert order address to quote address * * @param Mage_Sales_Model_Order_Address $address * @return Mage_Sales_Model_Quote_Address */ public function addressToQuoteAddress(Mage_Sales_Model_Order_Address $address) { $quoteAddress = AO::getModel('sales/quote_address')->setStoreId($address->getStoreId())->setAddressType($address->getAddressType())->setCustomerId($address->getCustomerId())->setCustomerAddressId($address->getCustomerAddressId()); AO::helper('core')->copyFieldset('sales_convert_order_address', 'to_quote_address', $address, $quoteAddress); // ->setPrefix($address->getPrefix()) // ->setFirstname($address->getFirstname()) // ->setMiddlename($address->getMiddlename()) // ->setLastname($address->getLastname()) // ->setSuffix($address->setSuffix()) // ->setCompany($address->getCompany()) // ->setStreet($address->getStreet(-1)) // ->setCity($address->getCity()) // ->setRegion($address->getRegion()) // ->setRegionId($address->getRegionId()) // ->setPostcode($address->getPostcode()) // ->setCountryId($address->getCountryId()) // ->setTelephone($address->getTelephone()) // ->setFax($address->getFax()); return $quoteAddress; }
/** * Generate the entire global address at two address fields * * @param Mage_Sales_Model_Order_Address $address * * @return string */ protected function _getInternationalFullStreet($address) { if (!$address->getStreet2()) { return preg_replace("/[\n\r]/", " ", $address->getStreetFull()); } $numberBeforeStreetCountry = array('CN', 'FR', 'GR', 'IE', 'IL', 'JP', 'LU', 'MY', 'MA', 'NZ', 'SG', 'GB'); if (in_array($address->getCountry(), $numberBeforeStreetCountry)) { return $address->getStreet2() . ' ' . $address->getStreet1(); } else { return preg_replace("/[\n\r]/", " ", $address->getStreetFull()); } }
<?php /** * Magento * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magentocommerce.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento * @package Mage_Adminhtml * @subpackage integration_tests * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ $address = new Mage_Sales_Model_Order_Address(); $address->setRegion('CA')->setPostcode('90210')->setFirstname('a_unique_firstname')->setLastname('lastname')->setStreet('street')->setCity('Beverly Hills')->setEmail('*****@*****.**')->setTelephone('1111111111')->setCountryId('US')->setAddressType('shipping')->save();
* to license@magentocommerce.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento * @package Mage_Sales * @subpackage integration_tests * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ $addressData = array('region' => 'CA', 'postcode' => '11111', 'street' => 'street', 'city' => 'Los Angeles', 'telephone' => '11111111', 'country_id' => 'US'); $billingAddress = new Mage_Sales_Model_Order_Address($addressData); $shippingAddress = clone $billingAddress; $item = new Mage_Sales_Model_Order_Item(); $item->setOriginalPrice(100)->setPrice(100)->setQtyOrdered(1)->setRowTotal(100)->setSubtotal(100); $payment = new Mage_Sales_Model_Order_Payment(); $payment->setMethod('checkmo'); $order = new Mage_Sales_Model_Order(); $order->setBaseSubtotal(100)->setSubtotal(100)->setBaseGrandTotal(100)->setGrandTotal(100)->setTotalPaid(100)->setCustomerIsGuest(true)->setState(Mage_Sales_Model_Order::STATE_NEW, true)->setStoreId(Mage::app()->getStore()->getId()); for ($i = 1; $i <= 100000; $i++) { $billingAddress->setId(null)->setFirstname("Name {$i}")->setLastname("Lastname {$i}")->setEmail("customer{$i}@example.com"); $shippingAddress->setId(null)->setFirstname("Name {$i}")->setLastname("Lastname {$i}")->setEmail("customer{$i}@example.com"); $item->setId(null)->setSku("item{$i}"); $payment->setId(null); $order->setId(null); $order->getItemsCollection()->removeAllItems(); $order->getAddressesCollection()->removeAllItems();
* NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magentocommerce.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento * @package Mage_Downlodable * @subpackage integration_tests * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ $billingAddress = new Mage_Sales_Model_Order_Address(array('firstname' => 'guest', 'lastname' => 'guest', 'email' => '*****@*****.**', 'street' => 'street', 'city' => 'Los Angeles', 'region' => 'CA', 'postcode' => '1', 'country_id' => 'US', 'telephone' => '1')); $billingAddress->setAddressType('billing'); $payment = new Mage_Sales_Model_Order_Payment(); $payment->setMethod('checkmo'); $orderItem = new Mage_Sales_Model_Order_Item(); $orderItem->setProductId(1)->setProductType(Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE)->setBasePrice(100)->setQtyOrdered(1); $order = new Mage_Sales_Model_Order(); $order->addItem($orderItem)->setIncrementId('100000001')->setCustomerIsGuest(true)->setStoreId(1)->setEmailSent(1)->setBillingAddress($billingAddress)->setPayment($payment); $order->save();
/** * fillout the shipping price group payload for the order item * @param Mage_Sales_Model_Order_Address * @param IOrderItem * @return self */ protected function prepareShippingPriceGroup(Mage_Sales_Model_Order_Address $address, IOrderItem $payload) { $shippingPriceGroup = $payload->getEmptyPriceGroup(); $shippingPriceGroup->setAmount((double) $address->getShippingAmount()); $this->discountHelper->transferDiscounts($address, $shippingPriceGroup); $payload->setShippingPricing($shippingPriceGroup); return $this; }
/** * Import address data from order address * * @param Mage_Sales_Model_Order_Address $address * @return Mage_Sales_Model_Quote_Address */ public function importOrderAddress(Mage_Sales_Model_Order_Address $address) { $this->setAddressType($address->getAddressType())->setCustomerId($address->getCustomerId())->setCustomerAddressId($address->getCustomerAddressId())->setEmail($address->getEmail())->setFirstname($address->getFirstname())->setLastname($address->getLastname())->setCompany($address->getCompany())->setStreet($address->getStreet())->setCity($address->getCity())->setRegion($address->getRegion())->setRegionId($address->getRegionId())->setPostcode($address->getPostcode())->setCountryId($address->getCountryId())->setTelephone($address->getTelephone())->setFax($address->getFax()); return $this; }
/** * Get the shipping description to use for an item. Takes into account if * the item is a physical or virtual item. * * @param Mage_Sales_Model_Order_Item * @param Mage_Sales_Model_Order_Address * @return string */ protected function getItemShippingDescription(Mage_Sales_Model_Order_Item $item, Mage_Sales_Model_Order_Address $address) { return $item->getIsVirtual() ? $this->shippingHelper->getVirtualMethodDescription() : $address->getShippingDescription(); }
protected function _setReceiverCommunication(Mage_Sales_Model_Order_Address $address, array &$receiver) { $receiver['Communication']['phone'] = $address->getTelephone(); // @desc Removed email field // @see DHLIS-563 unset($receiver['Communication']['email']); }
/** * Save billng/shipping address * * @param Mage_Sales_Model_Quote_Address $quoteAddress * @param Mage_Sales_Model_Order_Address $orderAddress * @return $this * @throws Exception */ public function saveAddress(Mage_Sales_Model_Quote_Address $quoteAddress, Mage_Sales_Model_Order_Address $orderAddress) { $quote = $quoteAddress->getQuote(); $order = $orderAddress->getOrder(); $this->getConvertor()->addressToOrderAddress($quoteAddress, $orderAddress); if ($quote->getIsVirtual() && $orderAddress->getAddressType() == 'billing' || !$quote->getIsVirtual() && $orderAddress->getAddressType() == 'shipping') { Mage::helper('core')->copyFieldset('sales_convert_quote_address', 'to_order', $quoteAddress, $order); } $orderAddress->save(); $quoteAddress->save(); return $this; }
/** * Get link to edit order address page * * @param Mage_Sales_Model_Order_Address $address * @param string $label * @return string */ public function getAddressEditLink($address, $label = '') { if (empty($label)) { $label = $this->__('Edit'); } $url = $this->getUrl('*/sales_order/address', array('address_id' => $address->getId())); return '<a href="' . $url . '">' . $label . '</a>'; }
/** * Convert order address to quote address * * @param Mage_Sales_Model_Order_Address $address * @return Mage_Sales_Model_Quote_Address */ public function addressToQuoteAddress(Mage_Sales_Model_Order_Address $address) { $quoteAddress = Mage::getModel('sales/quote_address')->setStoreId($address->getStoreId())->setAddressType($address->getAddressType())->setCustomerId($address->getCustomerId())->setCustomerAddressId($address->getCustomerAddressId())->setFirstname($address->getFirstname())->setLastname($address->getLastname())->setCompany($address->getCompany())->setStreet($address->getStreet(-1))->setCity($address->getCity())->setRegion($address->getRegion())->setRegionId($address->getRegionId())->setPostcode($address->getPostcode())->setCountryId($address->getCountryId())->setTelephone($address->getTelephone())->setFax($address->getFax()); return $quoteAddress; }
/** * Convert order address to quote address * * @param Mage_Sales_Model_Order_Address $address * @return Mage_Sales_Model_Quote_Address */ public function addressToQuoteAddress(Mage_Sales_Model_Order_Address $address) { $quoteAddress = Mage::getModel('sales/quote_address')->setStoreId($address->getStoreId())->setAddressType($address->getAddressType())->setCustomerId($address->getCustomerId())->setCustomerAddressId($address->getCustomerAddressId()); Mage::helper('core')->copyFieldset('sales_convert_order_address', 'to_quote_address', $address, $quoteAddress); return $quoteAddress; }
/** * @param string $code * @param Mage_Sales_Model_Order_Address $address * * @return null|string */ protected function _getStreetLine($code, Mage_Sales_Model_Order_Address $address) { if (strpos($code, 'street_') !== false) { $split = explode('_', $code); if (isset($split[1])) { return $address->getStreet((int) $split[1]); } } return null; }
/** * Build a Magento address model into a Braintree array * * @param Mage_Sales_Model_Order_Address|Mage_Sales_Model_Quote_Address|Mage_Customer_Model_Address $address * * @return array */ private function buildAddress($address) { // Build up the initial array $return = array('firstName' => $address->getFirstname(), 'lastName' => $address->getLastname(), 'streetAddress' => $address->getStreet1(), 'locality' => $address->getCity(), 'postalCode' => $address->getPostcode(), 'countryCodeAlpha2' => $address->getCountry()); // Any extended address? if ($address->getStreet2()) { $return['extendedAddress'] = $address->getStreet2(); } // Region if ($address->getRegion()) { $return['region'] = $address->getRegionCode(); } // Check to see if we have a company if ($address->getCompany()) { $return['company'] = $address->getCompany(); } return $return; }
* * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magentocommerce.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento * @package Mage_Paypal * @subpackage integration_tests * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ $addressData = (include __DIR__ . '/address_data.php'); $billingAddress = new Mage_Sales_Model_Order_Address($addressData); $billingAddress->setAddressType('billing'); $shippingAddress = clone $billingAddress; $shippingAddress->setId(null)->setAddressType('shipping'); $payment = new Mage_Sales_Model_Order_Payment(); $payment->setMethod(Mage_Paypal_Model_Config::METHOD_WPS); $order = new Mage_Sales_Model_Order(); $order->setIncrementId('100000001')->setSubtotal(100)->setBaseSubtotal(100)->setBaseGrandTotal(100)->setBaseCurrencyCode('USD')->setCustomerIsGuest(true)->setStoreId(1)->setEmailSent(1)->setBillingAddress($billingAddress)->setShippingAddress($shippingAddress)->setPayment($payment); $order->save();