Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Billing.php
Go to the documentation of this file.
1 <?php
7 
15 class Billing extends \Magento\Payment\Block\Form\Container
16 {
20  protected $_multishipping;
21 
25  protected $_checkoutSession;
26 
31 
42  public function __construct(
43  \Magento\Framework\View\Element\Template\Context $context,
44  \Magento\Payment\Helper\Data $paymentHelper,
45  \Magento\Payment\Model\Checks\SpecificationFactory $methodSpecificationFactory,
46  \Magento\Multishipping\Model\Checkout\Type\Multishipping $multishipping,
47  \Magento\Checkout\Model\Session $checkoutSession,
48  \Magento\Payment\Model\Method\SpecificationInterface $paymentSpecification,
49  array $data = [],
50  array $additionalChecks = []
51  ) {
52  $this->_multishipping = $multishipping;
53  $this->_checkoutSession = $checkoutSession;
54  $this->paymentSpecification = $paymentSpecification;
55  parent::__construct($context, $paymentHelper, $methodSpecificationFactory, $data, $additionalChecks);
56  $this->_isScopePrivate = true;
57  }
58 
64  protected function _prepareLayout()
65  {
66  $this->pageConfig->getTitle()->set(
67  __('Billing Information - %1', $this->pageConfig->getTitle()->getDefault())
68  );
69 
70  return parent::_prepareLayout();
71  }
72 
79  protected function _canUseMethod($method)
80  {
81  return $method && $this->paymentSpecification->isSatisfiedBy(
82  $method->getCode()
83  ) && parent::_canUseMethod(
84  $method
85  );
86  }
87 
93  public function getSelectedMethodCode()
94  {
95  $method = $this->getQuote()->getPayment()->getMethod();
96  if ($method) {
97  return $method;
98  }
99  return false;
100  }
101 
107  public function getAddress()
108  {
109  $address = $this->getData('address');
110  if ($address === null) {
111  $address = $this->_multishipping->getQuote()->getBillingAddress();
112  $this->setData('address', $address);
113  }
114  return $address;
115  }
116 
122  public function getQuote()
123  {
124  return $this->_checkoutSession->getQuote();
125  }
126 
132  public function getQuoteBaseGrandTotal()
133  {
134  return (double)$this->getQuote()->getBaseGrandTotal();
135  }
136 
142  public function getSelectAddressUrl()
143  {
144  return $this->getUrl('*/checkout_address/selectBilling');
145  }
146 
152  public function getPostActionUrl()
153  {
154  return $this->getUrl('*/*/overview');
155  }
156 
162  public function getBackUrl()
163  {
164  return $this->getUrl('*/*/backtoshipping');
165  }
166 }
getData($key='', $index=null)
Definition: DataObject.php:119
__()
Definition: __.php:13
$address
Definition: customer.php:38
$method
Definition: info.phtml:13
setData($key, $value=null)
Definition: DataObject.php:72
__construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Payment\Helper\Data $paymentHelper, \Magento\Payment\Model\Checks\SpecificationFactory $methodSpecificationFactory, \Magento\Multishipping\Model\Checkout\Type\Multishipping $multishipping, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Payment\Model\Method\SpecificationInterface $paymentSpecification, array $data=[], array $additionalChecks=[])
Definition: Billing.php:42