123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <?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');
- }
- }
|