当前位置: 首页>>代码示例>>PHP>>正文


PHP Order::getBillingAddress方法代码示例

本文整理汇总了PHP中Magento\Sales\Model\Order::getBillingAddress方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::getBillingAddress方法的具体用法?PHP Order::getBillingAddress怎么用?PHP Order::getBillingAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Sales\Model\Order的用法示例。


在下文中一共展示了Order::getBillingAddress方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getBillingAddress

 /**
  * Returns billing address
  *
  * @return AddressAdapterInterface|null
  */
 public function getBillingAddress()
 {
     if ($this->order->getBillingAddress()) {
         return $this->addressAdapterFactory->create(['address' => $this->order->getBillingAddress()]);
     }
     return null;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:12,代码来源:OrderAdapter.php

示例2: send

 /**
  * Send email to customer
  *
  * @param Order $order
  * @param bool $notify
  * @param string $comment
  * @return bool
  */
 public function send(Order $order, $notify = true, $comment = '')
 {
     if ($order->getShippingAddress()) {
         $formattedShippingAddress = $this->addressRenderer->format($order->getShippingAddress(), 'html');
     } else {
         $formattedShippingAddress = '';
     }
     $formattedBillingAddress = $this->addressRenderer->format($order->getBillingAddress(), 'html');
     $transport = new \Magento\Framework\Object(['template_vars' => ['order' => $order, 'comment' => $comment, 'billing' => $order->getBillingAddress(), 'store' => $order->getStore(), 'formattedShippingAddress' => $formattedShippingAddress, 'formattedBillingAddress' => $formattedBillingAddress]]);
     $this->eventManager->dispatch('email_order_comment_set_template_vars_before', ['sender' => $this, 'transport' => $transport]);
     $this->templateContainer->setTemplateVars($transport->getTemplateVars());
     return $this->checkAndSend($order, $notify);
 }
开发者ID:opexsw,项目名称:magento2,代码行数:21,代码来源:OrderCommentSender.php

示例3: send

 /**
  * Send email to customer
  *
  * @param Order $order
  * @param bool $notify
  * @param string $comment
  * @return bool
  */
 public function send(Order $order, $notify = true, $comment = '')
 {
     $transport = ['order' => $order, 'comment' => $comment, 'billing' => $order->getBillingAddress(), 'store' => $order->getStore(), 'formattedShippingAddress' => $this->getFormattedShippingAddress($order), 'formattedBillingAddress' => $this->getFormattedBillingAddress($order)];
     $this->eventManager->dispatch('email_order_comment_set_template_vars_before', ['sender' => $this, 'transport' => $transport]);
     $this->templateContainer->setTemplateVars($transport);
     return $this->checkAndSend($order, $notify);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:OrderCommentSender.php

示例4: startTransaction

 public function startTransaction(Order $order, UrlInterface $url)
 {
     $config = new Config($this->_scopeConfig);
     $config->configureSDK();
     $total = $order->getGrandTotal();
     $items = $order->getAllVisibleItems();
     $orderId = $order->getIncrementId();
     $quoteId = $order->getQuoteId();
     $currency = $order->getOrderCurrencyCode();
     $returnUrl = $url->getUrl('paynl/checkout/finish/');
     $exchangeUrl = $url->getUrl('paynl/checkout/exchange/');
     $paymentOptionId = $this->getPaymentOptionId();
     $arrBillingAddress = $order->getBillingAddress()->toArray();
     $arrShippingAddress = $order->getShippingAddress()->toArray();
     $enduser = array('initials' => substr($arrBillingAddress['firstname'], 0, 1), 'lastName' => $arrBillingAddress['lastname'], 'phoneNumber' => $arrBillingAddress['telephone'], 'emailAddress' => $arrBillingAddress['email']);
     $address = array();
     $arrAddress = \Paynl\Helper::splitAddress($arrBillingAddress['street']);
     $address['streetName'] = $arrAddress[0];
     $address['houseNumber'] = $arrAddress[1];
     $address['zipCode'] = $arrBillingAddress['postcode'];
     $address['city'] = $arrBillingAddress['city'];
     $address['country'] = $arrBillingAddress['country_id'];
     $shippingAddress = array();
     $arrAddress2 = \Paynl\Helper::splitAddress($arrShippingAddress['street']);
     $shippingAddress['streetName'] = $arrAddress2[0];
     $shippingAddress['houseNumber'] = $arrAddress2[1];
     $shippingAddress['zipCode'] = $arrShippingAddress['postcode'];
     $shippingAddress['city'] = $arrShippingAddress['city'];
     $shippingAddress['country'] = $arrShippingAddress['country_id'];
     $data = array('amount' => $total, 'returnUrl' => $returnUrl, 'paymentMethod' => $paymentOptionId, 'description' => $orderId, 'extra1' => $orderId, 'extra2' => $quoteId, 'exchangeUrl' => $exchangeUrl, 'currency' => $currency);
     $data['address'] = $address;
     $data['shippingAddress'] = $shippingAddress;
     $data['enduser'] = $enduser;
     $arrProducts = array();
     foreach ($items as $item) {
         $arrItem = $item->toArray();
         if ($arrItem['price_incl_tax'] != null) {
             $product = array('id' => $arrItem['product_id'], 'name' => $arrItem['name'], 'price' => $arrItem['price_incl_tax'], 'qty' => $arrItem['qty_ordered'], 'tax' => $arrItem['tax_amount']);
         }
         $arrProducts[] = $product;
     }
     //shipping
     $shippingCost = $order->getShippingAddress()->getShippingInclTax();
     $shippingTax = $order->getShippingAddress()->getShippingTaxAmount();
     $shippingDescription = $order->getShippingAddress()->getShippingDescription();
     $arrProducts[] = array('id' => 'shipping', 'name' => $shippingDescription, 'price' => $shippingCost, 'qty' => 1, 'tax' => $shippingTax);
     // kortingen
     $discount = $order->getSubtotal() - $order->getSubtotalWithDiscount();
     if ($discount > 0) {
         $arrProducts[] = array('id' => 'discount', 'name' => __('Discount'), 'price' => $discount * -1, 'qty' => 1, 'tax' => 0);
     }
     $data['products'] = $arrProducts;
     if ($config->isTestMode()) {
         $data['testmode'] = 1;
     }
     $data['ipaddress'] = $order->getRemoteIp();
     $transaction = \Paynl\Transaction::start($data);
     return $transaction->getRedirectUrl();
 }
开发者ID:jstjanssens,项目名称:magento2-plugin,代码行数:59,代码来源:PaymentMethod.php

示例5: getBasicData

 /**
  * @param \Magento\Sales\Model\Order $order
  * @return array
  */
 public function getBasicData(\Magento\Sales\Model\Order $order)
 {
     $incrementId = $order->getIncrementId();
     $billingAddress = $order->getBillingAddress();
     $data = ['amount' => $order->getGrandTotal() * 100, 'desc' => __('Order # %1', [$incrementId]), 'first_name' => $billingAddress->getFirstname(), 'last_name' => $billingAddress->getLastname(), 'email' => $order->getCustomerEmail(), 'session_id' => $this->extOrderIdHelper->generate($order), 'order_id' => $incrementId];
     $paytype = $this->session->getPaytype();
     if ($paytype) {
         $data['pay_type'] = $paytype;
         $this->session->setPaytype(null);
     }
     return $data;
 }
开发者ID:tozwierz,项目名称:magento2_payupl,代码行数:16,代码来源:DataGetter.php

示例6: _getVatRequiredSalesAddress

 /**
  * Retrieve sales address (order or quote) on which tax calculation must be based
  *
  * @param \Magento\Sales\Model\Order $order
  * @param \Magento\Store\Model\Store|string|int|null $store
  * @return \Magento\Sales\Model\Order\Address|null
  */
 protected function _getVatRequiredSalesAddress($order, $store = null)
 {
     $configAddressType = $this->customerAddressHelper->getTaxCalculationAddressType($store);
     $requiredAddress = null;
     switch ($configAddressType) {
         case \Magento\Customer\Model\Address\AbstractAddress::TYPE_SHIPPING:
             $requiredAddress = $order->getShippingAddress();
             break;
         default:
             $requiredAddress = $order->getBillingAddress();
             break;
     }
     return $requiredAddress;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:21,代码来源:AddVatRequestParamsOrderComment.php

示例7: prepareTemplate

 /**
  * @param Order $order
  * @return void
  */
 protected function prepareTemplate(Order $order)
 {
     $this->templateContainer->setTemplateOptions($this->getTemplateOptions());
     if ($order->getCustomerIsGuest()) {
         $templateId = $this->identityContainer->getGuestTemplateId();
         $customerName = $order->getBillingAddress()->getName();
     } else {
         $templateId = $this->identityContainer->getTemplateId();
         $customerName = $order->getCustomerName();
     }
     $this->identityContainer->setCustomerName($customerName);
     $this->identityContainer->setCustomerEmail($order->getCustomerEmail());
     $this->templateContainer->setTemplateId($templateId);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:18,代码来源:Sender.php

示例8: setBillingAddressData

 /**
  * Set Billing Address data
  *
  * @param $formFields
  */
 protected function setBillingAddressData($formFields)
 {
     $billingAddress = $this->_order->getBillingAddress();
     if ($billingAddress) {
         $formFields['shopper.firstName'] = trim($billingAddress->getFirstname());
         $middleName = trim($billingAddress->getMiddlename());
         if ($middleName != "") {
             $formFields['shopper.infix'] = trim($middleName);
         }
         $formFields['shopper.lastName'] = trim($billingAddress->getLastname());
         $formFields['shopper.telephoneNumber'] = trim($billingAddress->getTelephone());
         $street = $this->_adyenHelper->getStreet($billingAddress);
         if (isset($street['name']) && $street['name'] != "") {
             $formFields['billingAddress.street'] = $street['name'];
         }
         if (isset($street['house_number']) && $street['house_number'] != "") {
             $formFields['billingAddress.houseNumberOrName'] = $street['house_number'];
         } else {
             $formFields['billingAddress.houseNumberOrName'] = "NA";
         }
         if (trim($billingAddress->getCity()) == "") {
             $formFields['billingAddress.city'] = "NA";
         } else {
             $formFields['billingAddress.city'] = trim($billingAddress->getCity());
         }
         if (trim($billingAddress->getPostcode()) == "") {
             $formFields['billingAddress.postalCode'] = "NA";
         } else {
             $formFields['billingAddress.postalCode'] = trim($billingAddress->getPostcode());
         }
         if (trim($billingAddress->getRegionCode()) == "") {
             $formFields['billingAddress.stateOrProvince'] = "NA";
         } else {
             $formFields['billingAddress.stateOrProvince'] = trim($billingAddress->getRegionCode());
         }
         if (trim($billingAddress->getCountryId()) == "") {
             $formFields['billingAddress.country'] = "NA";
         } else {
             $formFields['billingAddress.country'] = trim($billingAddress->getCountryId());
         }
     }
     return $formFields;
 }
开发者ID:Adyen,项目名称:adyen-magento2,代码行数:48,代码来源:Redirect.php

示例9: process

 /**
  * Process addresses saving
  *
  * @param Order $order
  * @return $this
  * @throws \Exception
  */
 public function process(Order $order)
 {
     if (null !== $order->getAddressesCollection()) {
         $order->getAddressesCollection()->save();
         $billingAddress = $order->getBillingAddress();
         $attributesForSave = [];
         if ($billingAddress && $order->getBillingAddressId() != $billingAddress->getId()) {
             $order->setBillingAddressId($billingAddress->getId());
             $attributesForSave[] = 'billing_address_id';
         }
         $shippingAddress = $order->getShippingAddress();
         if ($shippingAddress && $order->getShippigAddressId() != $shippingAddress->getId()) {
             $order->setShippingAddressId($shippingAddress->getId());
             $attributesForSave[] = 'shipping_address_id';
         }
         if (!empty($attributesForSave)) {
             $this->attribute->saveAttribute($order, $attributesForSave);
         }
     }
     return $this;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:28,代码来源:Address.php

示例10: df_order_customer_name

/**
 * 2016-03-09
 * @param O $order
 * @return string
 */
function df_order_customer_name(O $order)
{
    /** @var string $result */
    $result = df_cc_s($order->getCustomerFirstname(), $order->getCustomerMiddlename(), $order->getCustomerLastname());
    if (!$result) {
        /** @var C $customer */
        $customer = $order->getCustomer();
        if ($customer) {
            $result = $customer->getName();
        }
    }
    if (!$result) {
        /** @var OA|null $ba */
        $ba = $order->getBillingAddress();
        if ($ba) {
            $result = $ba->getName();
        }
    }
    if (!$result) {
        /** @var OA|null $ba */
        $sa = $order->getShippingAddress();
        if ($sa) {
            $result = $sa->getName();
        }
    }
    if (!$result) {
        /**
         * 2016-08-24
         * Имени в адресах может запросто не быть
         * (например, если покупатель заказывает цифровой товар и askForBillingAddress = false),
         * и вот тогда мы попадаем сюда.
         * В данном случае функция вернёт просто «Guest».
         */
        $result = $this->o()->getCustomerName();
    }
    return $result;
}
开发者ID:mage2pro,项目名称:core,代码行数:42,代码来源:order.php

示例11: prepareTemplate

 /**
  * Prepare email template with variables
  *
  * @param Order $order
  * @return void
  */
 protected function prepareTemplate(Order $order)
 {
     $transport = new \Magento\Framework\Object(['template_vars' => ['order' => $order, 'billing' => $order->getBillingAddress(), 'payment_html' => $this->getPaymentHtml($order), 'store' => $order->getStore(), 'formattedShippingAddress' => $this->addressRenderer->format($order->getShippingAddress(), 'html'), 'formattedBillingAddress' => $this->addressRenderer->format($order->getBillingAddress(), 'html')]]);
     $this->eventManager->dispatch('email_order_set_template_vars_before', ['sender' => $this, 'transport' => $transport]);
     $this->templateContainer->setTemplateVars($transport->getTemplateVars());
     parent::prepareTemplate($order);
 }
开发者ID:opexsw,项目名称:magento2,代码行数:13,代码来源:OrderSender.php

示例12: _initBillingAddressFromOrder

 /**
  * Copy billing address from order
  *
  * @param \Magento\Sales\Model\Order $order
  * @return void
  */
 protected function _initBillingAddressFromOrder(\Magento\Sales\Model\Order $order)
 {
     $this->getQuote()->getBillingAddress()->setCustomerAddressId('');
     $this->_objectCopyService->copyFieldsetToTarget('sales_copy_order_billing_address', 'to_order', $order->getBillingAddress(), $this->getQuote()->getBillingAddress());
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:11,代码来源:Create.php

示例13: _getOrderData

 /**
  * Get order request data as array
  *
  * @param \Magento\Sales\Model\Order $order
  * @return array
  */
 protected function _getOrderData(\Magento\Sales\Model\Order $order)
 {
     $request = ['invoice' => $order->getIncrementId(), 'address_override' => 'true', 'currency_code' => $order->getBaseCurrencyCode(), 'buyer_email' => $order->getCustomerEmail()];
     // append to request billing address data
     if ($billingAddress = $order->getBillingAddress()) {
         $request = array_merge($request, $this->_getBillingAddress($billingAddress));
     }
     // append to request shipping address data
     if ($shippingAddress = $order->getShippingAddress()) {
         $request = array_merge($request, $this->_getShippingAddress($shippingAddress));
     }
     return $request;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:19,代码来源:Request.php

示例14: getFormattedBillingAddress

 /**
  * @param Order $order
  * @return string|null
  */
 protected function getFormattedBillingAddress($order)
 {
     return $this->addressRenderer->format($order->getBillingAddress(), 'html');
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:8,代码来源:Sender.php

示例15: prepareTemplate

 /**
  * Prepare email template with variables
  *
  * @param Order $order
  * @return void
  */
 protected function prepareTemplate(Order $order)
 {
     $transport = ['order' => $order, 'billing' => $order->getBillingAddress(), 'payment_html' => $this->getPaymentHtml($order), 'store' => $order->getStore(), 'formattedShippingAddress' => $this->getFormattedShippingAddress($order), 'formattedBillingAddress' => $this->getFormattedBillingAddress($order)];
     $this->eventManager->dispatch('email_order_set_template_vars_before', ['sender' => $this, 'transport' => $transport]);
     $this->templateContainer->setTemplateVars($transport);
     parent::prepareTemplate($order);
 }
开发者ID:nja78,项目名称:magento2,代码行数:13,代码来源:OrderSender.php


注:本文中的Magento\Sales\Model\Order::getBillingAddress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。