本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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());
}
示例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;
}
示例14: getFormattedBillingAddress
/**
* @param Order $order
* @return string|null
*/
protected function getFormattedBillingAddress($order)
{
return $this->addressRenderer->format($order->getBillingAddress(), 'html');
}
示例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);
}