1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Multishipping\Block\Checkout;
/**
* Multishipping billing information
*
* @api
* @author Magento Core Team <core@magentocommerce.com>
* @since 100.0.2
*/
class Billing extends \Magento\Payment\Block\Form\Container
{
/**
* @var \Magento\Multishipping\Model\Checkout\Type\Multishipping
*/
protected $_multishipping;
/**
* @var \Magento\Checkout\Model\Session
*/
protected $_checkoutSession;
/**
* @var \Magento\Payment\Model\Method\SpecificationInterface
*/
protected $paymentSpecification;
/**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Payment\Helper\Data $paymentHelper
* @param \Magento\Payment\Model\Checks\SpecificationFactory $methodSpecificationFactory
* @param \Magento\Multishipping\Model\Checkout\Type\Multishipping $multishipping
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Magento\Payment\Model\Method\SpecificationInterface $paymentSpecification
* @param array $data
* @param array $additionalChecks
*/
public function __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 = []
) {
$this->_multishipping = $multishipping;
$this->_checkoutSession = $checkoutSession;
$this->paymentSpecification = $paymentSpecification;
parent::__construct($context, $paymentHelper, $methodSpecificationFactory, $data, $additionalChecks);
$this->_isScopePrivate = true;
}
/**
* Prepare children blocks
*
* @return $this
*/
protected function _prepareLayout()
{
$this->pageConfig->getTitle()->set(
__('Billing Information - %1', $this->pageConfig->getTitle()->getDefault())
);
return parent::_prepareLayout();
}
/**
* Check payment method model
*
* @param \Magento\Payment\Model\Method\AbstractMethod|null $method
* @return bool
*/
protected function _canUseMethod($method)
{
return $method && $this->paymentSpecification->isSatisfiedBy(
$method->getCode()
) && parent::_canUseMethod(
$method
);
}
/**
* Retrieve code of current payment method
*
* @return mixed
*/
public function getSelectedMethodCode()
{
$method = $this->getQuote()->getPayment()->getMethod();
if ($method) {
return $method;
}
return false;
}
/**
* Retrieve billing address
*
* @return \Magento\Quote\Model\Quote\Address
*/
public function getAddress()
{
$address = $this->getData('address');
if ($address === null) {
$address = $this->_multishipping->getQuote()->getBillingAddress();
$this->setData('address', $address);
}
return $address;
}
/**
* Retrieve quote model object
*
* @return \Magento\Quote\Model\Quote
*/
public function getQuote()
{
return $this->_checkoutSession->getQuote();
}
/**
* Getter
*
* @return float
*/
public function getQuoteBaseGrandTotal()
{
return (double)$this->getQuote()->getBaseGrandTotal();
}
/**
* Retrieve url for select billing address
*
* @return string
*/
public function getSelectAddressUrl()
{
return $this->getUrl('*/checkout_address/selectBilling');
}
/**
* Retrieve data post destination url
*
* @return string
*/
public function getPostActionUrl()
{
return $this->getUrl('*/*/overview');
}
/**
* Retrieve back url
*
* @return string
*/
public function getBackUrl()
{
return $this->getUrl('*/*/backtoshipping');
}
}