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


PHP Order::getShippingAddress方法代码示例

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


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

示例1: getShippingAddress

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

示例2: 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

示例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 = '')
 {
     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

示例4: create

 /**
  * @return ShippingInterface|null
  */
 public function create()
 {
     $shipping = null;
     if ($this->getOrderId()) {
         $this->order = $this->orderFactory->create()->load($this->getOrderId());
         if ($this->order->getEntityId()) {
             /** @var ShippingInterface $shipping */
             $shipping = $this->shippingFactory->create();
             $shippingAddress = $this->order->getShippingAddress();
             if ($shippingAddress) {
                 $shipping->setAddress($shippingAddress);
             }
             $shipping->setMethod($this->order->getShippingMethod());
             $shipping->setTotal($this->getTotal());
         }
     }
     return $shipping;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:21,代码来源:ShippingBuilder.php

示例5: _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

示例6: 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

示例7: 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

示例8: setShippingAddressData

 /**
  * Set Shipping Address data
  *
  * @param $formFields
  */
 protected function setShippingAddressData($formFields)
 {
     $shippingAddress = $this->_order->getShippingAddress();
     if ($shippingAddress) {
         $street = $this->_adyenHelper->getStreet($shippingAddress);
         if (isset($street['name']) && $street['name'] != "") {
             $formFields['deliveryAddress.street'] = $street['name'];
         }
         if (isset($street['house_number']) && $street['house_number'] != "") {
             $formFields['deliveryAddress.houseNumberOrName'] = $street['house_number'];
         } else {
             $formFields['deliveryAddress.houseNumberOrName'] = "NA";
         }
         if (trim($shippingAddress->getCity()) == "") {
             $formFields['deliveryAddress.city'] = "NA";
         } else {
             $formFields['deliveryAddress.city'] = trim($shippingAddress->getCity());
         }
         if (trim($shippingAddress->getPostcode()) == "") {
             $formFields['deliveryAddress.postalCode'] = "NA";
         } else {
             $formFields['deliveryAddress.postalCode'] = trim($shippingAddress->getPostcode());
         }
         if (trim($shippingAddress->getRegionCode()) == "") {
             $formFields['deliveryAddress.stateOrProvince'] = "NA";
         } else {
             $formFields['deliveryAddress.stateOrProvince'] = trim($shippingAddress->getRegionCode());
         }
         if (trim($shippingAddress->getCountryId()) == "") {
             $formFields['deliveryAddress.country'] = "NA";
         } else {
             $formFields['deliveryAddress.country'] = trim($shippingAddress->getCountryId());
         }
     }
     return $formFields;
 }
开发者ID:Adyen,项目名称:adyen-magento2,代码行数:41,代码来源:Redirect.php

示例9: getFormattedShippingAddress

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

示例10: _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

示例11: makeRecipient

 /**
  * @param $order Order
  * @return Recipient|null
  */
 protected function makeRecipient(Order $order)
 {
     $address = $order->getShippingAddress();
     if ($address == null) {
         return null;
     }
     $recipient = SignifydModel::Make("\\Signifyd\\Models\\Recipient");
     $recipient->deliveryAddress = $this->formatSignifydAddress($address);
     $recipient->fullName = $address->getName();
     $recipient->confirmationPhone = $address->getTelephone();
     $recipient->confirmationEmail = $address->getEmail();
     return $recipient;
 }
开发者ID:signifyd,项目名称:magento2,代码行数:17,代码来源:PurchaseHelper.php

示例12: getOrderItemValue

 /**
  * Retrieve order item value by key
  *
  * @param \Magento\Sales\Model\Order $order
  * @param string $key
  * @return string
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function getOrderItemValue(\Magento\Sales\Model\Order $order, $key)
 {
     $escape = true;
     switch ($key) {
         case 'order_increment_id':
             $value = $order->getIncrementId();
             break;
         case 'created_at':
             $value = $this->formatDate($order->getCreatedAt(), \IntlDateFormatter::SHORT, true);
             break;
         case 'shipping_address':
             $value = $order->getShippingAddress() ? $this->escapeHtml($order->getShippingAddress()->getName()) : __('N/A');
             break;
         case 'order_total':
             $value = $order->formatPrice($order->getGrandTotal());
             $escape = false;
             break;
         case 'status_label':
             $value = $order->getStatusLabel();
             break;
         case 'view_url':
             $value = $this->getUrl('sales/order/view', ['order_id' => $order->getId()]);
             break;
         default:
             $value = $order->getData($key) ? $order->getData($key) : __('N/A');
             break;
     }
     return $escape ? $this->escapeHtml($value) : $value;
 }
开发者ID:nja78,项目名称:magento2,代码行数:37,代码来源:View.php

示例13: toQuoteShippingAddress

 /**
  * Convert order to shipping address
  *
  * @param   \Magento\Sales\Model\Order $order
  * @return  \Magento\Sales\Model\Quote\Address
  */
 public function toQuoteShippingAddress(\Magento\Sales\Model\Order $order)
 {
     $address = $this->addressToQuoteAddress($order->getShippingAddress());
     $this->_objectCopyService->copyFieldsetToTarget('sales_convert_order', 'to_quote_address', $order, $address);
     return $address;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:12,代码来源:Order.php

示例14: getShippingAddress

 /**
  * Returns shipping address
  *
  * @param \Magento\Sales\Model\Order $object
  * @return OrderAddress|null
  */
 protected function getShippingAddress(\Magento\Sales\Model\Order $object)
 {
     $shippingAddress = null;
     if ($object->getShippingAddress()) {
         $shippingAddress = $this->orderAddressMapper->extractDto($object->getShippingAddress());
     }
     return $shippingAddress;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:14,代码来源:OrderMapper.php

示例15: setDataFromOrder

 /**
  * Set entity data to request
  *
  * @param \Magento\Sales\Model\Order $order
  * @param \Magento\Authorizenet\Model\Directpost $paymentMethod
  * @return $this
  */
 public function setDataFromOrder(\Magento\Sales\Model\Order $order, \Magento\Authorizenet\Model\Directpost $paymentMethod)
 {
     $payment = $order->getPayment();
     $this->setXType($payment->getAnetTransType());
     $this->setXFpSequence($order->getQuoteId());
     $this->setXInvoiceNum($order->getIncrementId());
     $this->setXAmount($payment->getBaseAmountAuthorized());
     $this->setXCurrencyCode($order->getBaseCurrencyCode());
     $this->setXTax(sprintf('%.2F', $order->getBaseTaxAmount()))->setXFreight(sprintf('%.2F', $order->getBaseShippingAmount()));
     //need to use strval() because NULL values IE6-8 decodes as "null" in JSON in JavaScript,
     //but we need "" for null values.
     $billing = $order->getBillingAddress();
     if (!empty($billing)) {
         $this->setXFirstName(strval($billing->getFirstname()))->setXLastName(strval($billing->getLastname()))->setXCompany(strval($billing->getCompany()))->setXAddress(strval($billing->getStreetLine(1)))->setXCity(strval($billing->getCity()))->setXState(strval($billing->getRegion()))->setXZip(strval($billing->getPostcode()))->setXCountry(strval($billing->getCountry()))->setXPhone(strval($billing->getTelephone()))->setXFax(strval($billing->getFax()))->setXCustId(strval($billing->getCustomerId()))->setXCustomerIp(strval($order->getRemoteIp()))->setXCustomerTaxId(strval($billing->getTaxId()))->setXEmail(strval($order->getCustomerEmail()))->setXEmailCustomer(strval($paymentMethod->getConfigData('email_customer')))->setXMerchantEmail(strval($paymentMethod->getConfigData('merchant_email')));
     }
     $shipping = $order->getShippingAddress();
     if (!empty($shipping)) {
         $this->setXShipToFirstName(strval($shipping->getFirstname()))->setXShipToLastName(strval($shipping->getLastname()))->setXShipToCompany(strval($shipping->getCompany()))->setXShipToAddress(strval($shipping->getStreetLine(1)))->setXShipToCity(strval($shipping->getCity()))->setXShipToState(strval($shipping->getRegion()))->setXShipToZip(strval($shipping->getPostcode()))->setXShipToCountry(strval($shipping->getCountry()));
     }
     $this->setXPoNum(strval($payment->getPoNumber()));
     return $this;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:29,代码来源:Request.php


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