From f6eb3585c820118d5ac02df5b25f973f96ebfe41 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Mon, 19 Oct 2015 13:30:35 +0300 Subject: [PATCH 01/17] MAGETWO-43796: Eliminate @removeCandidate anotation --- .../layout/braintree_paypal_review.xml | 2 +- app/code/Magento/Checkout/Block/Onepage.php | 47 +-- .../Block/Onepage/AbstractOnepage.php | 391 ------------------ .../Checkout/Block/Onepage/Billing.php | 235 ----------- .../Checkout/Block/Onepage/Payment.php | 69 ---- .../Checkout/Block/Onepage/Payment/Info.php | 63 --- .../Block/Onepage/Payment/Methods.php | 113 ----- .../Checkout/Block/Onepage/Review/Button.php | 29 -- .../Checkout/Block/Onepage/Review/Info.php | 49 --- .../Checkout/Block/Onepage/Shipping.php | 131 ------ .../Block/Onepage/Shipping/Method.php | 37 -- .../Onepage/Shipping/Method/Additional.php | 16 - .../Onepage/Shipping/Method/Available.php | 122 ------ .../frontend/templates/onepage/billing.phtml | 214 ---------- .../frontend/templates/onepage/payment.phtml | 31 -- .../templates/onepage/payment/methods.phtml | 52 --- .../templates/onepage/review/button.phtml | 13 - .../templates/onepage/review/info.phtml | 54 --- .../frontend/templates/onepage/shipping.phtml | 133 ------ .../templates/onepage/shipping_method.phtml | 24 -- .../onepage/shipping_method/additional.phtml | 15 - .../onepage/shipping_method/available.phtml | 50 --- .../Paypal/Block/Express/Review/Billing.php | 284 ++++++++++++- .../Paypal/Block/Express/Review/Shipping.php | 162 +++++++- .../frontend/layout/paypal_express_review.xml | 2 +- .../layout/paypal_express_review_details.xml | 2 +- .../layout/paypal_payflowexpress_review.xml | 2 +- .../checkout}/onepage/review/totals.phtml | 4 - .../Block/Onepage/Payment/MethodsTest.php | 52 --- .../Block/Express/Review}/BillingTest.php | 21 +- 30 files changed, 443 insertions(+), 1976 deletions(-) delete mode 100644 app/code/Magento/Checkout/Block/Onepage/AbstractOnepage.php delete mode 100644 app/code/Magento/Checkout/Block/Onepage/Billing.php delete mode 100644 app/code/Magento/Checkout/Block/Onepage/Payment.php delete mode 100644 app/code/Magento/Checkout/Block/Onepage/Payment/Info.php delete mode 100644 app/code/Magento/Checkout/Block/Onepage/Payment/Methods.php delete mode 100644 app/code/Magento/Checkout/Block/Onepage/Review/Button.php delete mode 100644 app/code/Magento/Checkout/Block/Onepage/Review/Info.php delete mode 100644 app/code/Magento/Checkout/Block/Onepage/Shipping.php delete mode 100644 app/code/Magento/Checkout/Block/Onepage/Shipping/Method.php delete mode 100644 app/code/Magento/Checkout/Block/Onepage/Shipping/Method/Additional.php delete mode 100644 app/code/Magento/Checkout/Block/Onepage/Shipping/Method/Available.php delete mode 100644 app/code/Magento/Checkout/view/frontend/templates/onepage/billing.phtml delete mode 100644 app/code/Magento/Checkout/view/frontend/templates/onepage/payment.phtml delete mode 100644 app/code/Magento/Checkout/view/frontend/templates/onepage/payment/methods.phtml delete mode 100644 app/code/Magento/Checkout/view/frontend/templates/onepage/review/button.phtml delete mode 100644 app/code/Magento/Checkout/view/frontend/templates/onepage/review/info.phtml delete mode 100644 app/code/Magento/Checkout/view/frontend/templates/onepage/shipping.phtml delete mode 100644 app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method.phtml delete mode 100644 app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method/additional.phtml delete mode 100644 app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method/available.phtml rename app/code/Magento/{Checkout/view/frontend/templates => Paypal/view/frontend/templates/checkout}/onepage/review/totals.phtml (97%) delete mode 100644 dev/tests/integration/testsuite/Magento/Checkout/Block/Onepage/Payment/MethodsTest.php rename dev/tests/integration/testsuite/Magento/{Checkout/Block/Onepage => Paypal/Block/Express/Review}/BillingTest.php (85%) diff --git a/app/code/Magento/Braintree/view/frontend/layout/braintree_paypal_review.xml b/app/code/Magento/Braintree/view/frontend/layout/braintree_paypal_review.xml index 1c7b14abfa13d..126f80a2e25e8 100644 --- a/app/code/Magento/Braintree/view/frontend/layout/braintree_paypal_review.xml +++ b/app/code/Magento/Braintree/view/frontend/layout/braintree_paypal_review.xml @@ -24,7 +24,7 @@ - + diff --git a/app/code/Magento/Checkout/Block/Onepage.php b/app/code/Magento/Checkout/Block/Onepage.php index d298599319540..25cbb6081959d 100644 --- a/app/code/Magento/Checkout/Block/Onepage.php +++ b/app/code/Magento/Checkout/Block/Onepage.php @@ -5,15 +5,11 @@ */ namespace Magento\Checkout\Block; -use Magento\Checkout\Block\Checkout\LayoutProcessorInterface; -use Magento\Customer\Api\CustomerRepositoryInterface; -use Magento\Customer\Model\Address\Config as AddressConfig; - /** * Onepage checkout block * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class Onepage extends \Magento\Checkout\Block\Onepage\AbstractOnepage +class Onepage extends \Magento\Framework\View\Element\Template { /** * @var \Magento\Framework\Data\Form\FormKey @@ -36,60 +32,25 @@ class Onepage extends \Magento\Checkout\Block\Onepage\AbstractOnepage protected $configProvider; /** - * @var array|Checkout\LayoutProcessorInterface[] + * @var array|\Magento\Checkout\Block\Checkout\LayoutProcessorInterface[] */ protected $layoutProcessors; /** * @param \Magento\Framework\View\Element\Template\Context $context - * @param \Magento\Directory\Helper\Data $directoryHelper - * @param \Magento\Framework\App\Cache\Type\Config $configCacheType - * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Checkout\Model\Session $resourceSession - * @param \Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollectionFactory - * @param \Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionCollectionFactory - * @param CustomerRepositoryInterface $customerRepository - * @param AddressConfig $addressConfig - * @param \Magento\Framework\App\Http\Context $httpContext - * @param \Magento\Customer\Model\Address\Mapper $addressMapper * @param \Magento\Framework\Data\Form\FormKey $formKey * @param \Magento\Checkout\Model\CompositeConfigProvider $configProvider - * @param LayoutProcessorInterface[] $layoutProcessors + * @param array $layoutProcessors * @param array $data - * @codeCoverageIgnore - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\Framework\View\Element\Template\Context $context, - \Magento\Directory\Helper\Data $directoryHelper, - \Magento\Framework\App\Cache\Type\Config $configCacheType, - \Magento\Customer\Model\Session $customerSession, - \Magento\Checkout\Model\Session $resourceSession, - \Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollectionFactory, - \Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionCollectionFactory, - CustomerRepositoryInterface $customerRepository, - AddressConfig $addressConfig, - \Magento\Framework\App\Http\Context $httpContext, - \Magento\Customer\Model\Address\Mapper $addressMapper, \Magento\Framework\Data\Form\FormKey $formKey, \Magento\Checkout\Model\CompositeConfigProvider $configProvider, array $layoutProcessors = [], array $data = [] ) { - parent::__construct( - $context, - $directoryHelper, - $configCacheType, - $customerSession, - $resourceSession, - $countryCollectionFactory, - $regionCollectionFactory, - $customerRepository, - $addressConfig, - $httpContext, - $addressMapper, - $data - ); + parent::__construct($context, $data); $this->formKey = $formKey; $this->_isScopePrivate = true; $this->jsLayout = isset($data['jsLayout']) && is_array($data['jsLayout']) ? $data['jsLayout'] : []; diff --git a/app/code/Magento/Checkout/Block/Onepage/AbstractOnepage.php b/app/code/Magento/Checkout/Block/Onepage/AbstractOnepage.php deleted file mode 100644 index 6b4e92640ec70..0000000000000 --- a/app/code/Magento/Checkout/Block/Onepage/AbstractOnepage.php +++ /dev/null @@ -1,391 +0,0 @@ -directoryHelper = $directoryHelper; - $this->_configCacheType = $configCacheType; - $this->_customerSession = $customerSession; - $this->_checkoutSession = $resourceSession; - $this->_countryCollectionFactory = $countryCollectionFactory; - $this->_regionCollectionFactory = $regionCollectionFactory; - $this->httpContext = $httpContext; - parent::__construct($context, $data); - $this->_isScopePrivate = true; - $this->customerRepository = $customerRepository; - $this->_addressConfig = $addressConfig; - $this->addressMapper = $addressMapper; - } - - /** - * Get config - * - * @param string $path - * @return string|null - */ - public function getConfig($path) - { - return $this->_scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); - } - - /** - * Get logged in customer - * - * @return \Magento\Customer\Api\Data\CustomerInterface - */ - protected function _getCustomer() - { - if (empty($this->_customer)) { - $this->_customer = $this->customerRepository->getById($this->_customerSession->getCustomerId()); - } - return $this->_customer; - } - - /** - * Retrieve checkout session model - * - * @return \Magento\Checkout\Model\Session - */ - public function getCheckout() - { - return $this->_checkoutSession; - } - - /** - * Retrieve sales quote model - * - * @return Quote - */ - public function getQuote() - { - if (empty($this->_quote)) { - $this->_quote = $this->getCheckout()->getQuote(); - } - return $this->_quote; - } - - /** - * @return bool - */ - public function isCustomerLoggedIn() - { - return $this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH); - } - - /** - * @return Collection - * @removeCandidate - */ - public function getCountryCollection() - { - if (!$this->_countryCollection) { - $this->_countryCollection = $this->_countryCollectionFactory->create()->loadByStore(); - } - return $this->_countryCollection; - } - - /** - * @return RegionCollection - * @removeCandidate - */ - public function getRegionCollection() - { - if (!$this->_regionCollection) { - $this->_regionCollection = $this->_regionCollectionFactory->create()->addCountryFilter( - $this->getAddress()->getCountryId() - )->load(); - } - return $this->_regionCollection; - } - - /** - * @return int - * @removeCandidate - */ - public function customerHasAddresses() - { - try { - return count($this->_getCustomer()->getAddresses()); - } catch (NoSuchEntityException $e) { - return 0; - } - } - - /** - * @param string $type - * @return string - * @removeCandidate - */ - public function getAddressesHtmlSelect($type) - { - if ($this->isCustomerLoggedIn()) { - $options = []; - - try { - $addresses = $this->_getCustomer()->getAddresses(); - } catch (NoSuchEntityException $e) { - $addresses = []; - } - - foreach ($addresses as $address) { - $builtOutputAddressData = $this->addressMapper->toFlatArray($address); - $label = $this->_addressConfig - ->getFormatByCode(AddressConfig::DEFAULT_ADDRESS_FORMAT) - ->getRenderer() - ->renderArray($builtOutputAddressData); - - $options[] = ['value' => $address->getId(), 'label' => $label]; - } - - $addressId = $this->getAddress()->getCustomerAddressId(); - if (empty($addressId)) { - try { - if ($type == 'billing') { - $addressId = $this->_getCustomer()->getDefaultBilling(); - } else { - $addressId = $this->_getCustomer()->getDefaultShipping(); - } - } catch (NoSuchEntityException $e) { - // Do nothing - } - } - - $select = $this->getLayout()->createBlock('Magento\Framework\View\Element\Html\Select') - ->setName($type . '_address_id') - ->setId($type . ':address-select') - ->setClass('address-select') - ->setValue($addressId) - ->setOptions($options); - - $select->addOption('', __('New Address')); - - return $select->getHtml(); - } - return ''; - } - - /** - * @param string $type - * @return string - * @removeCandidate - */ - public function getCountryHtmlSelect($type) - { - $countryId = $this->getAddress()->getCountryId(); - if ($countryId === null) { - $countryId = $this->directoryHelper->getDefaultCountry(); - } - $select = $this->getLayout()->createBlock( - 'Magento\Framework\View\Element\Html\Select' - )->setName( - $type . '[country_id]' - )->setId( - $type . ':country_id' - )->setTitle( - __('Country') - )->setClass( - 'validate-select' - )->setValue( - $countryId - )->setOptions( - $this->getCountryOptions() - ); - return $select->getHtml(); - } - - /** - * @param string $type - * @return string - * @removeCandidate - */ - public function getRegionHtmlSelect($type) - { - $select = $this->getLayout()->createBlock( - 'Magento\Framework\View\Element\Html\Select' - )->setName( - $type . '[region]' - )->setId( - $type . ':region' - )->setTitle( - __('State/Province') - )->setClass( - 'required-entry validate-state' - )->setValue( - $this->getAddress()->getRegionId() - )->setOptions( - $this->getRegionCollection()->toOptionArray() - ); - - return $select->getHtml(); - } - - /** - * @return mixed - * @removeCandidate - */ - public function getCountryOptions() - { - $options = false; - $cacheId = 'DIRECTORY_COUNTRY_SELECT_STORE_' . $this->_storeManager->getStore()->getCode(); - if ($optionsCache = $this->_configCacheType->load($cacheId)) { - $options = unserialize($optionsCache); - } - - if ($options == false) { - $options = $this->getCountryCollection()->toOptionArray(); - $this->_configCacheType->save(serialize($options), $cacheId); - } - return $options; - } - - /** - * Get checkout steps codes - * - * @return string[] - * @removeCandidate - */ - protected function _getStepCodes() - { - return ['login', 'billing', 'shipping', 'shipping_method', 'payment', 'review']; - } - - /** - * Retrieve is allow and show block - * - * @return bool - * @removeCandidate - */ - public function isShow() - { - return true; - } - - /** - * Return the html text for shipping price - * - * @param \Magento\Quote\Model\Quote\Address\Rate $rate - * @return string - * @removeCandidate - */ - public function getShippingPriceHtml(\Magento\Quote\Model\Quote\Address\Rate $rate) - { - /** @var \Magento\Checkout\Block\Shipping\Price $block */ - $block = $this->getLayout()->getBlock('checkout.shipping.price'); - $block->setShippingRate($rate); - return $block->toHtml(); - } -} diff --git a/app/code/Magento/Checkout/Block/Onepage/Billing.php b/app/code/Magento/Checkout/Block/Onepage/Billing.php deleted file mode 100644 index 1aee1948f0f35..0000000000000 --- a/app/code/Magento/Checkout/Block/Onepage/Billing.php +++ /dev/null @@ -1,235 +0,0 @@ -_addressFactory = $addressFactory; - parent::__construct( - $context, - $directoryHelper, - $configCacheType, - $customerSession, - $resourceSession, - $countryCollectionFactory, - $regionCollectionFactory, - $customerRepository, - $addressConfig, - $httpContext, - $addressMapper, - $data - ); - $this->_isScopePrivate = true; - } - - /** - * Initialize billing address step - * - * @return void - */ - protected function _construct() - { - $this->getCheckout()->setStepData( - 'billing', - ['label' => __('Billing Information'), 'is_show' => $this->isShow()] - ); - - if ($this->isCustomerLoggedIn()) { - $this->getCheckout()->setStepData('billing', 'allow', true); - } - parent::_construct(); - } - - /** - * @return bool - */ - public function isUseBillingAddressForShipping() - { - if ($this->getQuote()->getIsVirtual() || !$this->getQuote()->getShippingAddress()->getSameAsBilling()) { - return false; - } - return true; - } - - /** - * Return country collection - * - * @return \Magento\Directory\Model\ResourceModel\Country\Collection - */ - public function getCountries() - { - return $this->_countryCollectionFactory->create()->loadByStore(); - } - - /** - * Return checkout method - * - * @return string - */ - public function getMethod() - { - return $this->getQuote()->getCheckoutMethod(); - } - - /** - * Return Sales Quote Address model - * - * @return \Magento\Quote\Model\Quote\Address - */ - public function getAddress() - { - if ($this->_address === null) { - if ($this->isCustomerLoggedIn()) { - $this->_address = $this->getQuote()->getBillingAddress(); - if (!$this->_address->getFirstname()) { - $this->_address->setFirstname($this->getQuote()->getCustomer()->getFirstname()); - } - if (!$this->_address->getLastname()) { - $this->_address->setLastname($this->getQuote()->getCustomer()->getLastname()); - } - } else { - $this->_address = $this->_addressFactory->create(); - } - } - - return $this->_address; - } - - /** - * Return Customer Address First Name - * If Sales Quote Address First Name is not defined - return Customer First Name - * - * @return string - */ - public function getFirstname() - { - return $this->getAddress()->getFirstname(); - } - - /** - * Return Customer Address Last Name - * If Sales Quote Address Last Name is not defined - return Customer Last Name - * - * @return string - */ - public function getLastname() - { - return $this->getAddress()->getLastname(); - } - - /** - * Check is Quote items can ship to - * - * @return bool - */ - public function canShip() - { - return !$this->getQuote()->isVirtual(); - } - - /** - * @return void - */ - public function getSaveUrl() - { - } - - /** - * Get Customer Taxvat Widget block - * - * @return \Magento\Customer\Block\Widget\Taxvat - */ - protected function _getTaxvat() - { - if (!$this->_taxvat) { - $this->_taxvat = $this->getLayout()->createBlock('Magento\Customer\Block\Widget\Taxvat'); - } - - return $this->_taxvat; - } - - /** - * Check whether taxvat is enabled - * - * @return bool - */ - public function isTaxvatEnabled() - { - return $this->_getTaxvat()->isEnabled(); - } - - /** - * @return string - */ - public function getTaxvatHtml() - { - return $this->_getTaxvat()->setTaxvat( - $this->getQuote()->getCustomerTaxvat() - )->setFieldIdFormat( - 'billing:%s' - )->setFieldNameFormat( - 'billing[%s]' - )->toHtml(); - } -} diff --git a/app/code/Magento/Checkout/Block/Onepage/Payment.php b/app/code/Magento/Checkout/Block/Onepage/Payment.php deleted file mode 100644 index 4298784226ae9..0000000000000 --- a/app/code/Magento/Checkout/Block/Onepage/Payment.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @removeCandidate - */ -class Payment extends \Magento\Checkout\Block\Onepage\AbstractOnepage -{ - /** - * @return void - */ - protected function _construct() - { - $this->getCheckout()->setStepData( - 'payment', - ['label' => __('Payment Information'), 'is_show' => $this->isShow()] - ); - parent::_construct(); - } - - /** - * Getter - * - * @return float - */ - public function getQuoteBaseGrandTotal() - { - return (double)$this->getQuote()->getBaseGrandTotal(); - } - - /** - * Get options - * - * @return array - */ - public function getOptions() - { - $registerParam = $this->getRequest()->getParam('register'); - return [ - 'quoteBaseGrandTotal' => $this->getQuoteBaseGrandTotal(), - 'progressUrl' => $this->getUrl('checkout/onepage/progress'), - 'reviewUrl' => $this->getUrl('checkout/onepage/review'), - 'failureUrl' => $this->getUrl('checkout/cart'), - 'getAddressUrl' => $this->getUrl('checkout/onepage/getAddress') . 'address/', - 'checkout' => [ - 'suggestRegistration' => $registerParam || $registerParam === '', - 'saveUrl' => $this->getUrl('checkout/onepage/saveMethod'), - ], - 'billing' => ['saveUrl' => $this->getUrl('checkout/onepage/saveBilling')], - 'shipping' => ['saveUrl' => $this->getUrl('checkout/onepage/saveShipping')], - 'shippingMethod' => ['saveUrl' => $this->getUrl('checkout/onepage/saveShippingMethod')], - 'payment' => [ - 'defaultPaymentMethod' => $this->getChildBlock('methods')->getSelectedMethodCode(), - 'saveUrl' => $this->getUrl('checkout/onepage/savePayment'), - ], - 'review' => [ - 'saveUrl' => $this->getUrl('checkout/onepage/saveOrder'), - 'successUrl' => $this->getUrl('checkout/onepage/success'), - ] - ]; - } -} diff --git a/app/code/Magento/Checkout/Block/Onepage/Payment/Info.php b/app/code/Magento/Checkout/Block/Onepage/Payment/Info.php deleted file mode 100644 index 67f682a25c19d..0000000000000 --- a/app/code/Magento/Checkout/Block/Onepage/Payment/Info.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @removeCandidate - */ -class Info extends \Magento\Payment\Block\Info\AbstractContainer -{ - /** - * @var \Magento\Checkout\Model\Session - */ - protected $_checkoutSession; - - /** - * @param \Magento\Framework\View\Element\Template\Context $context - * @param \Magento\Payment\Helper\Data $paymentData - * @param \Magento\Checkout\Model\Session $checkoutSession - * @param array $data - */ - public function __construct( - \Magento\Framework\View\Element\Template\Context $context, - \Magento\Payment\Helper\Data $paymentData, - \Magento\Checkout\Model\Session $checkoutSession, - array $data = [] - ) { - $this->_checkoutSession = $checkoutSession; - parent::__construct($context, $paymentData, $data); - $this->_isScopePrivate = true; - } - - /** - * Retrieve payment info model - * - * @return \Magento\Payment\Model\Info|false - */ - public function getPaymentInfo() - { - $info = $this->_checkoutSession->getQuote()->getPayment(); - if ($info->getMethod()) { - return $info; - } - return false; - } - - /** - * @return string - */ - protected function _toHtml() - { - $html = ''; - if ($block = $this->getChildBlock($this->_getInfoBlockName())) { - $html = $block->toHtml(); - } - return $html; - } -} diff --git a/app/code/Magento/Checkout/Block/Onepage/Payment/Methods.php b/app/code/Magento/Checkout/Block/Onepage/Payment/Methods.php deleted file mode 100644 index 48285ad73dc27..0000000000000 --- a/app/code/Magento/Checkout/Block/Onepage/Payment/Methods.php +++ /dev/null @@ -1,113 +0,0 @@ - - * @removeCandidate - */ -namespace Magento\Checkout\Block\Onepage\Payment; - -class Methods extends \Magento\Payment\Block\Form\Container -{ - /** - * @var \Magento\Checkout\Model\Session - */ - protected $_checkoutSession; - - /** - * @param \Magento\Framework\View\Element\Template\Context $context - * @param \Magento\Payment\Helper\Data $paymentHelper - * @param \Magento\Payment\Model\Checks\SpecificationFactory $methodSpecificationFactory - * @param \Magento\Checkout\Model\Session $checkoutSession - * @param array $data - */ - public function __construct( - \Magento\Framework\View\Element\Template\Context $context, - \Magento\Payment\Helper\Data $paymentHelper, - \Magento\Payment\Model\Checks\SpecificationFactory $methodSpecificationFactory, - \Magento\Checkout\Model\Session $checkoutSession, - array $data = [] - ) { - $this->_checkoutSession = $checkoutSession; - parent::__construct($context, $paymentHelper, $methodSpecificationFactory, $data); - $this->_isScopePrivate = true; - } - - /** - * @return \Magento\Quote\Model\Quote - */ - public function getQuote() - { - return $this->_checkoutSession->getQuote(); - } - - /** - * Check payment method model - * - * @param \Magento\Payment\Model\MethodInterface $method - * @return bool - */ - protected function _canUseMethod($method) - { - return $method && $method->canUseCheckout() && 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; - } - - /** - * Payment method form html getter - * - * @param \Magento\Payment\Model\MethodInterface $method - * @return string - */ - public function getPaymentMethodFormHtml(\Magento\Payment\Model\MethodInterface $method) - { - return $this->getChildHtml('payment.method.' . $method->getCode()); - } - - /** - * Return method title for payment selection page - * - * @param \Magento\Payment\Model\MethodInterface $method - * @return string - */ - public function getMethodTitle(\Magento\Payment\Model\MethodInterface $method) - { - $form = $this->getChildBlock('payment.method.' . $method->getCode()); - if ($form && $form->hasMethodTitle()) { - return $form->getMethodTitle(); - } - return $method->getTitle(); - } - - /** - * Payment method additional label part getter - * - * @param \Magento\Payment\Model\MethodInterface $method - * @return string - */ - public function getMethodLabelAfterHtml(\Magento\Payment\Model\MethodInterface $method) - { - $form = $this->getChildBlock('payment.method.' . $method->getCode()); - if ($form) { - return $form->getMethodLabelAfterHtml(); - } - } -} diff --git a/app/code/Magento/Checkout/Block/Onepage/Review/Button.php b/app/code/Magento/Checkout/Block/Onepage/Review/Button.php deleted file mode 100644 index 39cba9ffce747..0000000000000 --- a/app/code/Magento/Checkout/Block/Onepage/Review/Button.php +++ /dev/null @@ -1,29 +0,0 @@ -_checkoutSession = $checkoutSession; - parent::__construct($context, $data); - $this->_isScopePrivate = true; - } - - /** - * @return array - */ - public function getItems() - { - return $this->_checkoutSession->getQuote()->getAllVisibleItems(); - } - - /** - * @return array - */ - public function getTotals() - { - return $this->_checkoutSession->getQuote()->getTotals(); - } -} diff --git a/app/code/Magento/Checkout/Block/Onepage/Shipping.php b/app/code/Magento/Checkout/Block/Onepage/Shipping.php deleted file mode 100644 index d8dcad11e01c0..0000000000000 --- a/app/code/Magento/Checkout/Block/Onepage/Shipping.php +++ /dev/null @@ -1,131 +0,0 @@ -_addressFactory = $addressFactory; - parent::__construct( - $context, - $directoryHelper, - $configCacheType, - $customerSession, - $resourceSession, - $countryCollectionFactory, - $regionCollectionFactory, - $customerRepository, - $addressConfig, - $httpContext, - $addressMapper, - $data - ); - $this->_isScopePrivate = true; - } - - /** - * Initialize shipping address step - * - * @return void - */ - protected function _construct() - { - $this->getCheckout()->setStepData( - 'shipping', - ['label' => __('Shipping Information'), 'is_show' => $this->isShow()] - ); - - parent::_construct(); - } - - /** - * Return checkout method - * - * @return string - */ - public function getMethod() - { - return $this->getQuote()->getCheckoutMethod(); - } - - /** - * Return Sales Quote Address model (shipping address) - * - * @return \Magento\Quote\Model\Quote\Address - */ - public function getAddress() - { - if ($this->_address === null) { - if ($this->isCustomerLoggedIn()) { - $this->_address = $this->getQuote()->getShippingAddress(); - } else { - $this->_address = $this->_addressFactory->create(); - } - } - - return $this->_address; - } - - /** - * Retrieve is allow and show block - * - * @return bool - */ - public function isShow() - { - return !$this->getQuote()->isVirtual(); - } -} diff --git a/app/code/Magento/Checkout/Block/Onepage/Shipping/Method.php b/app/code/Magento/Checkout/Block/Onepage/Shipping/Method.php deleted file mode 100644 index 5145d6fdca269..0000000000000 --- a/app/code/Magento/Checkout/Block/Onepage/Shipping/Method.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @removeCandidate - */ -class Method extends \Magento\Checkout\Block\Onepage\AbstractOnepage -{ - /** - * @return void - */ - protected function _construct() - { - $this->getCheckout()->setStepData( - 'shipping_method', - ['label' => __('Shipping Method'), 'is_show' => $this->isShow()] - ); - parent::_construct(); - } - - /** - * Retrieve is allow and show block - * - * @return bool - */ - public function isShow() - { - return !$this->getQuote()->isVirtual(); - } -} diff --git a/app/code/Magento/Checkout/Block/Onepage/Shipping/Method/Additional.php b/app/code/Magento/Checkout/Block/Onepage/Shipping/Method/Additional.php deleted file mode 100644 index bf27a8fa21208..0000000000000 --- a/app/code/Magento/Checkout/Block/Onepage/Shipping/Method/Additional.php +++ /dev/null @@ -1,16 +0,0 @@ - - * @removeCandidate - */ -class Additional extends \Magento\Checkout\Block\Onepage\AbstractOnepage -{ -} diff --git a/app/code/Magento/Checkout/Block/Onepage/Shipping/Method/Available.php b/app/code/Magento/Checkout/Block/Onepage/Shipping/Method/Available.php deleted file mode 100644 index 582beafbbb5f4..0000000000000 --- a/app/code/Magento/Checkout/Block/Onepage/Shipping/Method/Available.php +++ /dev/null @@ -1,122 +0,0 @@ -_isScopePrivate = true; - } - - /** - * @return array - */ - public function getShippingRates() - { - if (empty($this->_rates)) { - $this->getAddress()->collectShippingRates()->save(); - $this->_rates = $this->getAddress()->getGroupedAllShippingRates(); - } - - return $this->_rates; - } - - /** - * @return Address - */ - public function getAddress() - { - if (empty($this->_address)) { - $this->_address = $this->getQuote()->getShippingAddress(); - } - return $this->_address; - } - - /** - * @param string $carrierCode - * @return string - */ - public function getCarrierName($carrierCode) - { - if ($name = $this->_scopeConfig->getValue( - 'carriers/' . $carrierCode . '/title', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - ) - ) { - return $name; - } - return $carrierCode; - } - - /** - * @return string - */ - public function getAddressShippingMethod() - { - return $this->getAddress()->getShippingMethod(); - } -} diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/billing.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/billing.phtml deleted file mode 100644 index 49369053b5be5..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/billing.phtml +++ /dev/null @@ -1,214 +0,0 @@ - -
- - customerHasAddresses()): ?> -
- -
- getAddressesHtmlSelect('billing') ?> -
-
- -
customerHasAddresses()): ?> style="display:none;"> - - - getLayout()->createBlock('Magento\Customer\Block\Widget\Name')->setObject($block->getAddress()->getFirstname() ? $block->getAddress() : $block->getQuote()->getCustomer())->setForceUseCustomerRequiredAttributes(!$block->isCustomerLoggedIn())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?> - - isCustomerLoggedIn()): ?> - - - -
- -
- -
-
- - helper('Magento\Customer\Helper\Address')->isVatAttributeVisible()) : ?> -
- -
- -
-
- - - helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('street'); ?> -
- -
- -
- - helper('Magento\Customer\Helper\Address')->getStreetLines(); $_i <= $_n; $_i++): ?> -
- -
- -
-
- -
-
-
- - -
- -
- -
-
- -
- -
- - getConfig('general/region/display_all') === 0):?>disabled="disabled" - style="display:none;" /> -
-
- -
- -
- -
-
- -
- -
- getCountryHtmlSelect('billing') ?> -
-
- -
- -
- -
-
- -
- -
- -
-
- - isCustomerLoggedIn()): ?> - getLayout()->createBlock('Magento\Customer\Block\Widget\Dob') ?> - getLayout()->createBlock('Magento\Customer\Block\Widget\Taxvat') ?> - getLayout()->createBlock('Magento\Customer\Block\Widget\Gender') ?> - - isEnabled()): ?> - setDate($block->getQuote()->getCustomerDob())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?> - - isEnabled()): ?> - setTaxvat($block->getQuote()->getCustomerTaxvat())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?> - - isEnabled()): ?> - setGender($block->getQuote()->getCustomerGender())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?> - - getChildBlock('customer_form_customer_user_defined_attributes');?> - - setEntityModelClass('Magento\Customer\Model\Customer')->setFieldIdFormat('billing:%1$s');?> - setFieldNameFormat('billing[%1$s]')->setShowContainer(false);?> - toHtml()?> - -
- -
- -
-
-
- -
- -
-
- - getChildHtml('form_additional_info'); ?> - isCustomerLoggedIn() && $block->customerHasAddresses()):?> -
- getAddress()->getSaveInAddressBook()):?> checked="checked" class="checkbox" /> - -
- - - - - getChildHtml('checkout.onepage.billing.extra')?> -
-canShip()): ?> -
- isUseBillingAddressForShipping()) { - ?> checked="checked" class="radio" /> - -
-
- isUseBillingAddressForShipping()) { - ?> checked="checked" class="radio" /> - -
- - -canShip()): ?> - - -
-
-
-
- diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/payment.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/payment.phtml deleted file mode 100644 index f9ac39fd39dca..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/payment.phtml +++ /dev/null @@ -1,31 +0,0 @@ - -
- getBlockHtml('formkey') ?> -
- - -
- getChildChildHtml('methods_additional') ?> -
-
- getChildChildHtml('additional') ?> -
-
- -
-
- -
-
-
diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/payment/methods.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/payment/methods.phtml deleted file mode 100644 index f3c0f86cc46bb..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/payment/methods.phtml +++ /dev/null @@ -1,52 +0,0 @@ - - -
-getMethods(); - $oneMethod = count($methods) <= 1; -?> - -
- -
-getCode(); -?> -
- - getSelectedMethodCode() == $_code): ?> checked="checked" class="radio" /> - - - - - -
- getPaymentMethodFormHtml($_method)): ?> -
- -
- - -
-
-getChildChildHtml('additional'); ?> diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/button.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/button.phtml deleted file mode 100644 index 1b26f9922c5fa..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/button.phtml +++ /dev/null @@ -1,13 +0,0 @@ - - diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/info.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/info.phtml deleted file mode 100644 index 8e390e653fd79..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/info.phtml +++ /dev/null @@ -1,54 +0,0 @@ -\ -getChildHtml('items_before'); ?> -
- helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): $colspan = $rowspan = 2; else: $colspan = $rowspan = 1; endif; ?> - - - - - - - - - - - - getItems() as $_item): ?> - getItemHtml($_item)?> - - - - getChildHtml('totals'); ?> - -
-
-getChildHtml('items_after'); ?> -
- getChildHtml('agreements') ?> -
-
getChildHtml('button') ?>
-
- - - - - - -
-
-
diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping.phtml deleted file mode 100644 index aaff68ef03aca..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping.phtml +++ /dev/null @@ -1,133 +0,0 @@ - -
- -customerHasAddresses()): ?> -
- -
getAddressesHtmlSelect('shipping') ?>
-
- -
customerHasAddresses()): ?> style="display:none;"> - - getLayout()->createBlock('Magento\Customer\Block\Widget\Name')->setObject($block->getAddress())->setFieldIdFormat('shipping:%s')->setFieldNameFormat('shipping[%s]')->toHtml() ?> -
- -
- -
-
- helper('Magento\Customer\Helper\Address')->isVatAttributeVisible()) : ?> -
- -
- -
-
- - helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('street'); ?> -
- -
- -
- - helper('Magento\Customer\Helper\Address')->getStreetLines(); $_i <= $_n; $_i++): ?> -
- -
- -
-
- -
-
-
- -
- -
- -
-
-
- -
- - -
-
-
- -
- -
-
-
- -
- getCountryHtmlSelect('shipping') ?> -
-
-
- -
- -
-
-
- -
- -
-
- - isCustomerLoggedIn() && $block->customerHasAddresses()):?> -
- getAddress()->getSaveInAddressBook()):?> checked="checked" class="checkbox" /> - -
- - - -
-
- getAddress()->getSameAsBilling()): ?> checked="checked" class="checkbox" /> - -
-
-
- -
-
-
-
- diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method.phtml deleted file mode 100644 index 4ab0004006b42..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method.phtml +++ /dev/null @@ -1,24 +0,0 @@ - -
-
-
- getChildHtml('additional') ?> -
-
-
- -
-
-
-
diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method/additional.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method/additional.phtml deleted file mode 100644 index ac87ff9ce6691..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method/additional.phtml +++ /dev/null @@ -1,15 +0,0 @@ - -getQuote()->isVirtual()): ?> - helper('Magento\GiftMessage\Helper\Message')->getInline('onepage_checkout', $block->getQuote(), $block->getDontDisplayContainer()) ?> - diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method/available.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method/available.phtml deleted file mode 100644 index f2b37b4be7c83..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method/available.phtml +++ /dev/null @@ -1,50 +0,0 @@ - - -getShippingRates(); ?> - -

- -
- - $_rates): ?> -
escapeHtml($block->getCarrierName($code)) ?>
-
-
- escapeHtml($block->getCarrierName($code)) ?>
- - getCode().'":'.(float)$_rate->getPrice(); ?> -
- getErrorMessage()): ?> -
escapeHtml($_rate->getErrorMessage()) ?>
- - - - -
- getCode()===$block->getAddressShippingMethod()) echo ' checked="checked"' ?> class="radio"/> -
- - - -
- -
-
- -
-
- diff --git a/app/code/Magento/Paypal/Block/Express/Review/Billing.php b/app/code/Magento/Paypal/Block/Express/Review/Billing.php index c613b56c40f0e..c61ea7d1bc1a4 100644 --- a/app/code/Magento/Paypal/Block/Express/Review/Billing.php +++ b/app/code/Magento/Paypal/Block/Express/Review/Billing.php @@ -9,8 +9,219 @@ */ namespace Magento\Paypal\Block\Express\Review; -class Billing extends \Magento\Checkout\Block\Onepage\Billing +use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Quote\Model\Quote; + +class Billing extends \Magento\Framework\View\Element\Template { + /** + * Sales Quote Billing Address instance + * + * @var \Magento\Quote\Model\Quote\Address + */ + protected $address; + + /** + * Customer Taxvat Widget block + * + * @var \Magento\Customer\Block\Widget\Taxvat + */ + protected $taxvat; + + /** + * @var \Magento\Quote\Model\Quote\AddressFactory + */ + protected $addressFactory; + + /** + * @var \Magento\Customer\Api\Data\CustomerInterface + */ + protected $customer; + + /** + * @var Quote + */ + protected $quote; + + /** + * @var \Magento\Checkout\Model\Session + */ + protected $checkoutSession; + + /** + * @var \Magento\Customer\Model\Session + */ + protected $customerSession; + + /** + * @var CustomerRepositoryInterface + */ + protected $customerRepository; + + /** + * @var \Magento\Framework\App\Http\Context + */ + protected $httpContext; + + /** + * @var \Magento\Directory\Model\ResourceModel\Country\CollectionFactory + */ + protected $countryCollectionFactory; + + /** + * @param \Magento\Framework\View\Element\Template\Context $context + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Checkout\Model\Session $resourceSession + * @param \Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollectionFactory + * @param CustomerRepositoryInterface $customerRepository + * @param \Magento\Framework\App\Http\Context $httpContext + * @param Quote\AddressFactory $addressFactory + * @param array $data + */ + public function __construct( + \Magento\Framework\View\Element\Template\Context $context, + \Magento\Customer\Model\Session $customerSession, + \Magento\Checkout\Model\Session $resourceSession, + \Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollectionFactory, + CustomerRepositoryInterface $customerRepository, + \Magento\Framework\App\Http\Context $httpContext, + \Magento\Quote\Model\Quote\AddressFactory $addressFactory, + array $data = [] + ) { + $this->addressFactory = $addressFactory; + parent::__construct($context, $data); + $this->_isScopePrivate = true; + $this->httpContext = $httpContext; + $this->customerRepository = $customerRepository; + $this->checkoutSession = $resourceSession; + $this->customerSession = $customerSession; + $this->countryCollectionFactory = $countryCollectionFactory; + } + + /** + * Initialize billing address step + * + * @return void + */ + protected function _construct() + { + $this->getCheckout()->setStepData( + 'billing', + ['label' => __('Billing Information'), 'is_show' => $this->isShow()] + ); + + if ($this->isCustomerLoggedIn()) { + $this->getCheckout()->setStepData('billing', 'allow', true); + } + parent::_construct(); + } + + /** + * @return bool + */ + public function isUseBillingAddressForShipping() + { + if ($this->getQuote()->getIsVirtual() || !$this->getQuote()->getShippingAddress()->getSameAsBilling()) { + return false; + } + return true; + } + + /** + * Return country collection + * + * @return \Magento\Directory\Model\ResourceModel\Country\Collection + */ + public function getCountries() + { + return $this->countryCollectionFactory->create()->loadByStore(); + } + + /** + * Return checkout method + * + * @return string + */ + public function getMethod() + { + return $this->getQuote()->getCheckoutMethod(); + } + + /** + * Return Customer Address First Name + * If Sales Quote Address First Name is not defined - return Customer First Name + * + * @return string + */ + public function getFirstname() + { + return $this->getAddress()->getFirstname(); + } + + /** + * Return Customer Address Last Name + * If Sales Quote Address Last Name is not defined - return Customer Last Name + * + * @return string + */ + public function getLastname() + { + return $this->getAddress()->getLastname(); + } + + /** + * Check is Quote items can ship to + * + * @return bool + */ + public function canShip() + { + return !$this->getQuote()->isVirtual(); + } + + /** + * @return void + */ + public function getSaveUrl() + { + } + + /** + * Get Customer Taxvat Widget block + * + * @return \Magento\Customer\Block\Widget\Taxvat + */ + protected function _getTaxvat() + { + if (!$this->taxvat) { + $this->taxvat = $this->getLayout()->createBlock('Magento\Customer\Block\Widget\Taxvat'); + } + + return $this->taxvat; + } + + /** + * Check whether taxvat is enabled + * + * @return bool + */ + public function isTaxvatEnabled() + { + return $this->_getTaxvat()->isEnabled(); + } + + /** + * @return string + */ + public function getTaxvatHtml() + { + return $this->_getTaxvat() + ->setTaxvat($this->getQuote()->getCustomerTaxvat()) + ->setFieldIdFormat('billing:%s') + ->setFieldNameFormat('billing[%s]') + ->toHtml(); + } + /** * Return Sales Quote Address model * @@ -18,20 +229,75 @@ class Billing extends \Magento\Checkout\Block\Onepage\Billing */ public function getAddress() { - if ($this->_address === null) { + if ($this->address === null) { if ($this->isCustomerLoggedIn() || $this->getQuote()->getBillingAddress()) { - $this->_address = $this->getQuote()->getBillingAddress(); - if (!$this->_address->getFirstname()) { - $this->_address->setFirstname($this->getQuote()->getCustomer()->getFirstname()); + $this->address = $this->getQuote()->getBillingAddress(); + if (!$this->address->getFirstname()) { + $this->address->setFirstname($this->getQuote()->getCustomer()->getFirstname()); } - if (!$this->_address->getLastname()) { - $this->_address->setLastname($this->getQuote()->getCustomer()->getLastname()); + if (!$this->address->getLastname()) { + $this->address->setLastname($this->getQuote()->getCustomer()->getLastname()); } } else { - $this->_address = $this->_addressFactory->create(); + $this->address = $this->addressFactory->create(); } } - return $this->_address; + return $this->address; + } + + /** + * Get config + * + * @param string $path + * @return string|null + */ + public function getConfig($path) + { + return $this->_scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); + } + + /** + * Get logged in customer + * + * @return \Magento\Customer\Api\Data\CustomerInterface + */ + protected function _getCustomer() + { + if (empty($this->customer)) { + $this->customer = $this->customerRepository->getById($this->customerSession->getCustomerId()); + } + return $this->customer; + } + + /** + * Retrieve checkout session model + * + * @return \Magento\Checkout\Model\Session + */ + public function getCheckout() + { + return $this->checkoutSession; + } + + /** + * Retrieve sales quote model + * + * @return Quote + */ + public function getQuote() + { + if (empty($this->quote)) { + $this->quote = $this->getCheckout()->getQuote(); + } + return $this->quote; + } + + /** + * @return bool + */ + public function isCustomerLoggedIn() + { + return $this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH); } } diff --git a/app/code/Magento/Paypal/Block/Express/Review/Shipping.php b/app/code/Magento/Paypal/Block/Express/Review/Shipping.php index 97fe0a20e9c3f..73fe0336cf81b 100644 --- a/app/code/Magento/Paypal/Block/Express/Review/Shipping.php +++ b/app/code/Magento/Paypal/Block/Express/Review/Shipping.php @@ -9,8 +9,115 @@ */ namespace Magento\Paypal\Block\Express\Review; -class Shipping extends \Magento\Checkout\Block\Onepage\Shipping +use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Quote\Model\Quote; + +class Shipping extends \Magento\Framework\View\Element\Template { + /** + * Sales Quote Shipping Address instance + * + * @var \Magento\Quote\Model\Quote\Address + */ + protected $address = null; + + /** + * @var \Magento\Quote\Model\Quote\AddressFactory + */ + protected $addressFactory; + + /** + * @var \Magento\Customer\Api\Data\CustomerInterface + */ + protected $customer; + + /** + * @var Quote + */ + protected $quote; + + /** + * @var \Magento\Checkout\Model\Session + */ + protected $checkoutSession; + + /** + * @var CustomerRepositoryInterface + */ + protected $customerRepository; + + /** + * @var \Magento\Framework\App\Http\Context + */ + protected $httpContext; + + /** + * @var \Magento\Customer\Model\Session + */ + protected $customerSession; + + /** + * @param \Magento\Framework\View\Element\Template\Context $context + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Checkout\Model\Session $resourceSession + * @param CustomerRepositoryInterface $customerRepository + * @param \Magento\Framework\App\Http\Context $httpContext + * @param \Magento\Quote\Model\Quote\AddressFactory $addressFactory + * @param array $data + */ + public function __construct( + \Magento\Framework\View\Element\Template\Context $context, + \Magento\Customer\Model\Session $customerSession, + \Magento\Checkout\Model\Session $resourceSession, + CustomerRepositoryInterface $customerRepository, + \Magento\Framework\App\Http\Context $httpContext, + \Magento\Quote\Model\Quote\AddressFactory $addressFactory, + array $data = [] + ) { + $this->addressFactory = $addressFactory; + parent::__construct($context, $data); + $this->_isScopePrivate = true; + $this->httpContext = $httpContext; + $this->customerRepository = $customerRepository; + $this->checkoutSession = $resourceSession; + $this->customerSession = $customerSession; + } + + /** + * Initialize shipping address step + * + * @return void + */ + protected function _construct() + { + $this->checkoutSession->setStepData( + 'shipping', + ['label' => __('Shipping Information'), 'is_show' => $this->isShow()] + ); + + parent::_construct(); + } + + /** + * Return checkout method + * + * @return string + */ + public function getMethod() + { + return $this->getQuote()->getCheckoutMethod(); + } + + /** + * Retrieve is allow and show block + * + * @return bool + */ + public function isShow() + { + return !$this->getQuote()->isVirtual(); + } + /** * Return Sales Quote Address model (shipping address) * @@ -18,14 +125,59 @@ class Shipping extends \Magento\Checkout\Block\Onepage\Shipping */ public function getAddress() { - if ($this->_address === null) { + if ($this->address === null) { if ($this->isCustomerLoggedIn() || $this->getQuote()->getShippingAddress()) { - $this->_address = $this->getQuote()->getShippingAddress(); + $this->address = $this->getQuote()->getShippingAddress(); } else { - $this->_address = $this->_addressFactory->create(); + $this->address = $this->addressFactory->create(); } } - return $this->_address; + return $this->address; + } + + /** + * Get config + * + * @param string $path + * @return string|null + */ + public function getConfig($path) + { + return $this->_scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); + } + + /** + * Get logged in customer + * + * @return \Magento\Customer\Api\Data\CustomerInterface + */ + protected function _getCustomer() + { + if (empty($this->customer)) { + $this->customer = $this->customerRepository->getById($this->customerSession->getCustomerId()); + } + return $this->customer; + } + + /** + * Retrieve sales quote model + * + * @return Quote + */ + public function getQuote() + { + if (empty($this->quote)) { + $this->quote = $this->checkoutSession->getQuote(); + } + return $this->quote; + } + + /** + * @return bool + */ + public function isCustomerLoggedIn() + { + return $this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH); } } diff --git a/app/code/Magento/Paypal/view/frontend/layout/paypal_express_review.xml b/app/code/Magento/Paypal/view/frontend/layout/paypal_express_review.xml index 60e525f463b8f..695adda9167dd 100644 --- a/app/code/Magento/Paypal/view/frontend/layout/paypal_express_review.xml +++ b/app/code/Magento/Paypal/view/frontend/layout/paypal_express_review.xml @@ -24,7 +24,7 @@ - + diff --git a/app/code/Magento/Paypal/view/frontend/layout/paypal_express_review_details.xml b/app/code/Magento/Paypal/view/frontend/layout/paypal_express_review_details.xml index 01be224c3d0f1..6594f0a472a8a 100644 --- a/app/code/Magento/Paypal/view/frontend/layout/paypal_express_review_details.xml +++ b/app/code/Magento/Paypal/view/frontend/layout/paypal_express_review_details.xml @@ -10,7 +10,7 @@ - + diff --git a/app/code/Magento/Paypal/view/frontend/layout/paypal_payflowexpress_review.xml b/app/code/Magento/Paypal/view/frontend/layout/paypal_payflowexpress_review.xml index e41ab21bced74..7fb0e07142bea 100644 --- a/app/code/Magento/Paypal/view/frontend/layout/paypal_payflowexpress_review.xml +++ b/app/code/Magento/Paypal/view/frontend/layout/paypal_payflowexpress_review.xml @@ -27,7 +27,7 @@ - + diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/totals.phtml b/app/code/Magento/Paypal/view/frontend/templates/checkout/onepage/review/totals.phtml similarity index 97% rename from app/code/Magento/Checkout/view/frontend/templates/onepage/review/totals.phtml rename to app/code/Magento/Paypal/view/frontend/templates/checkout/onepage/review/totals.phtml index ab70dbab565d4..94aca67913e6b 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/totals.phtml +++ b/app/code/Magento/Paypal/view/frontend/templates/checkout/onepage/review/totals.phtml @@ -9,10 +9,6 @@ /** * @see \Magento\Checkout\Block\Cart\Totals */ - -/** - * @removeCandidate - */ ?> getTotals()): ?> diff --git a/dev/tests/integration/testsuite/Magento/Checkout/Block/Onepage/Payment/MethodsTest.php b/dev/tests/integration/testsuite/Magento/Checkout/Block/Onepage/Payment/MethodsTest.php deleted file mode 100644 index 8e9cd3f440d6c..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Checkout/Block/Onepage/Payment/MethodsTest.php +++ /dev/null @@ -1,52 +0,0 @@ -_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Framework\View\LayoutInterface' - )->createBlock( - 'Magento\Checkout\Block\Onepage\Payment\Methods' - ); - } - - /** - * @magentoAppArea frontend - */ - public function testGetMethodTitleAndMethodLabelAfterHtml() - { - $expectedTitle = 'Free Method'; - $expectedLabel = 'Label After Html'; - $method = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Payment\Model\Method\Free' - ); - - $block = $this->_block->getLayout()->createBlock('Magento\Framework\View\Element\Text') - ->setMethodTitle($expectedTitle) - ->setMethodLabelAfterHtml($expectedLabel); - - $this->assertEquals('No Payment Information Required', $this->_block->getMethodTitle($method)); - $this->_block->setChild('payment.method.free', $block); - $actualTitle = $this->_block->getMethodTitle($method); - $actualLabel = $this->_block->getMethodLabelAfterHtml($method); - - $this->assertEquals($expectedTitle, $actualTitle); - $this->assertEquals($expectedLabel, $actualLabel); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Checkout/Block/Onepage/BillingTest.php b/dev/tests/integration/testsuite/Magento/Paypal/Block/Express/Review/BillingTest.php similarity index 85% rename from dev/tests/integration/testsuite/Magento/Checkout/Block/Onepage/BillingTest.php rename to dev/tests/integration/testsuite/Magento/Paypal/Block/Express/Review/BillingTest.php index 86ac63afe5714..ec4442baf1de5 100644 --- a/dev/tests/integration/testsuite/Magento/Checkout/Block/Onepage/BillingTest.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/Block/Express/Review/BillingTest.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Checkout\Block\Onepage; +namespace Magento\Paypal\Block\Express\Review; use Magento\Customer\Model\Context; use Magento\TestFramework\Helper\Bootstrap; @@ -13,7 +13,7 @@ */ class BillingTest extends \PHPUnit_Framework_TestCase { - /** @var \Magento\Checkout\Block\Onepage\Billing */ + /** @var \Magento\Paypal\Block\Express\Review\Billing */ protected $_block; /** @var \Magento\Customer\Api\AddressRepositoryInterface */ @@ -67,7 +67,7 @@ protected function setUp() ->setValue(Context::CONTEXT_AUTH, true, false); $this->_block = $objectManager->get('Magento\Framework\View\LayoutInterface') ->createBlock( - 'Magento\Checkout\Block\Onepage\Billing', + 'Magento\Paypal\Block\Express\Review\Billing', '', ['customerSession' => $customerSession, 'checkoutSession' => $checkoutSession] ); @@ -136,19 +136,4 @@ protected function _updateQuoteCustomerName() $this->assertEquals(self::SAMPLE_FIRST_NAME, $this->_block->getFirstname()); $this->assertEquals(self::SAMPLE_LAST_NAME, $this->_block->getLastname()); } - - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - * @magentoDataFixture Magento/Customer/_files/customer_address.php - */ - public function testGetAddressesHtmlSelect() - { - Bootstrap::getObjectManager()->get('Magento\Customer\Model\Session')->setCustomerId(1); - // @codingStandardsIgnoreStart - $expected = << -OUTPUT; - // @codingStandardsIgnoreEnd - $this->assertEquals($expected, $this->_block->getAddressesHtmlSelect('billing')); - } } From 1b2ce9bbbcb696edd6472181b0a0fa13a558811b Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Mon, 19 Oct 2015 13:50:32 +0300 Subject: [PATCH 02/17] MAGETWO-43796: Eliminate @removeCandidate anotation --- .../Checkout/Test/Unit/Block/OnepageTest.php | 38 ------------------- 1 file changed, 38 deletions(-) diff --git a/app/code/Magento/Checkout/Test/Unit/Block/OnepageTest.php b/app/code/Magento/Checkout/Test/Unit/Block/OnepageTest.php index e3ef9b58e827f..d29475962ef4d 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/OnepageTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/OnepageTest.php @@ -35,13 +35,6 @@ class OnepageTest extends \PHPUnit_Framework_TestCase protected function setUp() { $contextMock = $this->getMock('\Magento\Framework\View\Element\Template\Context', [], [], '', false); - $directoryHelperMock = $this->getMock('\Magento\Directory\Helper\Data', [], [], '', false); - $configCacheTypeMock = $this->getMock('\Magento\Framework\App\Cache\Type\Config', [], [], '', false); - $customerSessionMock = $this->getMock('\Magento\Customer\Model\Session', [], [], '', false); - $resourceSessionMock = $this->getMock('\Magento\Checkout\Model\Session', [], [], '', false); - $addressConfigMock = $this->getMock('\Magento\Customer\Model\Address\Config', [], [], '', false); - $httpContextMock = $this->getMock('\Magento\Framework\App\Http\Context', [], [], '', false); - $addressMapperMock = $this->getMock('\Magento\Customer\Model\Address\Mapper', [], [], '', false); $this->formKeyMock = $this->getMock('\Magento\Framework\Data\Form\FormKey', [], [], '', false); $this->configProviderMock = $this->getMock( '\Magento\Checkout\Model\CompositeConfigProvider', @@ -50,27 +43,6 @@ protected function setUp() '', false ); - $countryCollectionFactoryMock = $this->getMock( - 'Magento\Directory\Model\ResourceModel\Country\CollectionFactory', - ['create'], - [], - '', - false - ); - $regionCollectionFactoryMock = $this->getMock( - 'Magento\Directory\Model\ResourceModel\Region\CollectionFactory', - ['create'], - [], - '', - false - ); - $customerRepositoryMock = $this->getMock( - '\Magento\Customer\Api\CustomerRepositoryInterface', - [], - [], - '', - false - ); $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface', [], [], '', false); $contextMock->expects($this->once())->method('getStoreManager')->willReturn($this->storeManagerMock); @@ -84,16 +56,6 @@ protected function setUp() $this->model = new \Magento\Checkout\Block\Onepage( $contextMock, - $directoryHelperMock, - $configCacheTypeMock, - $customerSessionMock, - $resourceSessionMock, - $countryCollectionFactoryMock, - $regionCollectionFactoryMock, - $customerRepositoryMock, - $addressConfigMock, - $httpContextMock, - $addressMapperMock, $this->formKeyMock, $this->configProviderMock, [$this->layoutProcessorMock] From 96a63e6d74722b302bb5bdd9ab4243872c405598 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Mon, 19 Oct 2015 15:38:45 +0300 Subject: [PATCH 03/17] MAGETWO-43796: Eliminate @removeCandidate anotation --- app/code/Magento/Paypal/Block/Express/Review/Billing.php | 4 ++-- app/code/Magento/Paypal/Block/Express/Review/Shipping.php | 2 +- .../Magento/Paypal/Block/Express/Review/BillingTest.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Paypal/Block/Express/Review/Billing.php b/app/code/Magento/Paypal/Block/Express/Review/Billing.php index c61ea7d1bc1a4..adbf50d7c4343 100644 --- a/app/code/Magento/Paypal/Block/Express/Review/Billing.php +++ b/app/code/Magento/Paypal/Block/Express/Review/Billing.php @@ -89,13 +89,13 @@ public function __construct( array $data = [] ) { $this->addressFactory = $addressFactory; - parent::__construct($context, $data); $this->_isScopePrivate = true; $this->httpContext = $httpContext; $this->customerRepository = $customerRepository; $this->checkoutSession = $resourceSession; $this->customerSession = $customerSession; $this->countryCollectionFactory = $countryCollectionFactory; + parent::__construct($context, $data); } /** @@ -107,7 +107,7 @@ protected function _construct() { $this->getCheckout()->setStepData( 'billing', - ['label' => __('Billing Information'), 'is_show' => $this->isShow()] + ['label' => __('Billing Information'), 'is_show' => true] ); if ($this->isCustomerLoggedIn()) { diff --git a/app/code/Magento/Paypal/Block/Express/Review/Shipping.php b/app/code/Magento/Paypal/Block/Express/Review/Shipping.php index 73fe0336cf81b..e49171238ceed 100644 --- a/app/code/Magento/Paypal/Block/Express/Review/Shipping.php +++ b/app/code/Magento/Paypal/Block/Express/Review/Shipping.php @@ -75,12 +75,12 @@ public function __construct( array $data = [] ) { $this->addressFactory = $addressFactory; - parent::__construct($context, $data); $this->_isScopePrivate = true; $this->httpContext = $httpContext; $this->customerRepository = $customerRepository; $this->checkoutSession = $resourceSession; $this->customerSession = $customerSession; + parent::__construct($context, $data); } /** diff --git a/dev/tests/integration/testsuite/Magento/Paypal/Block/Express/Review/BillingTest.php b/dev/tests/integration/testsuite/Magento/Paypal/Block/Express/Review/BillingTest.php index ec4442baf1de5..c256479cc7c83 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/Block/Express/Review/BillingTest.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/Block/Express/Review/BillingTest.php @@ -69,7 +69,7 @@ protected function setUp() ->createBlock( 'Magento\Paypal\Block\Express\Review\Billing', '', - ['customerSession' => $customerSession, 'checkoutSession' => $checkoutSession] + ['customerSession' => $customerSession, 'resourceSession' => $checkoutSession] ); } From 85760a3b5aec6283a3c0e40adf4b7088a46403da Mon Sep 17 00:00:00 2001 From: Iryna Lagno Date: Mon, 19 Oct 2015 16:36:39 +0300 Subject: [PATCH 04/17] MAGETWO-44228: Unable to set gift options in the shopping cart --- .../frontend/web/js/model/gift-options.js | 30 +++++++++++++------ .../view/frontend/web/js/view/gift-message.js | 7 ++++- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/app/code/Magento/GiftMessage/view/frontend/web/js/model/gift-options.js b/app/code/Magento/GiftMessage/view/frontend/web/js/model/gift-options.js index 187f17e5b3962..c8ee517f5508c 100644 --- a/app/code/Magento/GiftMessage/view/frontend/web/js/model/gift-options.js +++ b/app/code/Magento/GiftMessage/view/frontend/web/js/model/gift-options.js @@ -3,18 +3,30 @@ * See COPYING.txt for license details. */ /*global define*/ -define(['underscore'], - function (_) { - "use strict"; +define(['underscore', 'ko'], + function (_, ko) { + + 'use strict'; + return { - options: [], - addOption: function(option) { - if(!this.options.hasOwnProperty(option.itemId)) { - this.options[option.itemId] = option; + options: ko.observableArray([]), + addOption: function (option) { + if (!this.options().hasOwnProperty(option.itemId)) { + this.options.push({ + id: option.itemId, value: option + } + ); } }, - getOptionByItemId: function(itemId) { - return this.options.hasOwnProperty(itemId) ? this.options[itemId] : null; + getOptionByItemId: function (itemId) { + var option = null; + _.each(this.options(), function (data) { + if (data.id === itemId) { + option = data.value; + } + }); + + return option; } } } diff --git a/app/code/Magento/GiftMessage/view/frontend/web/js/view/gift-message.js b/app/code/Magento/GiftMessage/view/frontend/web/js/view/gift-message.js index dae05d712dd9b..fc4d6931be2e0 100644 --- a/app/code/Magento/GiftMessage/view/frontend/web/js/view/gift-message.js +++ b/app/code/Magento/GiftMessage/view/frontend/web/js/view/gift-message.js @@ -3,7 +3,12 @@ * See COPYING.txt for license details. */ /*global define*/ -define(['uiComponent', '../model/gift-message', '../model/gift-options', '../action/gift-options'], +define([ + 'uiComponent', + 'Magento_GiftMessage/js/model/gift-message', + 'Magento_GiftMessage/js/model/gift-options', + 'Magento_GiftMessage/js/action/gift-options' + ], function (Component, giftMessage, giftOptions, giftOptionsService) { "use strict"; return Component.extend({ From d55b53ac5e656d6d12c3dc50f00edb7d252061cd Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Mon, 19 Oct 2015 16:53:54 +0300 Subject: [PATCH 05/17] MAGETWO-43796: Eliminate @removeCandidate anotation --- app/code/Magento/Checkout/composer.json | 1 - app/code/Magento/Paypal/Block/Express/Review/Billing.php | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/composer.json b/app/code/Magento/Checkout/composer.json index 775fe8406e930..ca4d5b91da09d 100644 --- a/app/code/Magento/Checkout/composer.json +++ b/app/code/Magento/Checkout/composer.json @@ -15,7 +15,6 @@ "magento/module-tax": "1.0.0-beta", "magento/module-directory": "1.0.0-beta", "magento/module-eav": "1.0.0-beta", - "magento/module-gift-message": "1.0.0-beta", "magento/module-page-cache": "1.0.0-beta", "magento/module-sales-rule": "1.0.0-beta", "magento/module-theme": "1.0.0-beta", diff --git a/app/code/Magento/Paypal/Block/Express/Review/Billing.php b/app/code/Magento/Paypal/Block/Express/Review/Billing.php index adbf50d7c4343..445582f9dbd6b 100644 --- a/app/code/Magento/Paypal/Block/Express/Review/Billing.php +++ b/app/code/Magento/Paypal/Block/Express/Review/Billing.php @@ -12,6 +12,9 @@ use Magento\Customer\Api\CustomerRepositoryInterface; use Magento\Quote\Model\Quote; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class Billing extends \Magento\Framework\View\Element\Template { /** From 93bc15b235880affe9eb7855cdd1d1323681617a Mon Sep 17 00:00:00 2001 From: Serhiy Shkolyarenko Date: Mon, 19 Oct 2015 17:46:13 +0300 Subject: [PATCH 06/17] MAGETWO-40822: [PHP7] Incompatible tests uncommented tests --- .../Magento/Bundle/Api/ProductOptionRepositoryTest.php | 10 ---------- .../testsuite/Magento/Sitemap/Helper/DataTest.php | 9 --------- 2 files changed, 19 deletions(-) diff --git a/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductOptionRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductOptionRepositoryTest.php index 8c486761f3906..2554dacd77055 100644 --- a/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductOptionRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductOptionRepositoryTest.php @@ -147,16 +147,6 @@ public function testAdd() */ public function testUpdate() { - /** TODO: Remove after MAGETWO-40822 */ - $isPhpVersionSupported = version_compare( - '7.0.0', - preg_replace('#^([^~+-]+).*$#', '$1', PHP_VERSION), - '>' - ); - if (!$isPhpVersionSupported) { - $this->markTestSkipped('MAGETWO-40822'); - } - $productSku = 'bundle-product'; $request = [ 'title' => 'someTitle', diff --git a/dev/tests/integration/testsuite/Magento/Sitemap/Helper/DataTest.php b/dev/tests/integration/testsuite/Magento/Sitemap/Helper/DataTest.php index 3eacb4c386420..2579f660db11d 100644 --- a/dev/tests/integration/testsuite/Magento/Sitemap/Helper/DataTest.php +++ b/dev/tests/integration/testsuite/Magento/Sitemap/Helper/DataTest.php @@ -14,15 +14,6 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - // TODO: Remove provided check after PHPMD will support PHP version 7 - $isSupported = version_compare( - '7.0.0', - preg_replace('#^([^~+-]+).*$#', '$1', PHP_VERSION), - '>' - ); - if (!$isSupported) { - $this->markTestSkipped('MAGETWO-40822: PHP7 incompatible'); - } $this->_helper = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( 'Magento\Sitemap\Helper\Data' ); From 043a32c10e1a2a8cf25151c4fcbfd2a59c93b463 Mon Sep 17 00:00:00 2001 From: Serhiy Shkolyarenko Date: Mon, 19 Oct 2015 18:25:18 +0300 Subject: [PATCH 07/17] MAGETWO-40822: [PHP7] Incompatible tests fixed decoding --- setup/src/Magento/Setup/Controller/Connect.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/setup/src/Magento/Setup/Controller/Connect.php b/setup/src/Magento/Setup/Controller/Connect.php index b5a400262717c..7ff039e3f4bcc 100644 --- a/setup/src/Magento/Setup/Controller/Connect.php +++ b/setup/src/Magento/Setup/Controller/Connect.php @@ -42,7 +42,10 @@ public function __construct(ComposerInformation $composerInformation, ConnectMan */ public function saveAuthJsonAction() { - $params = Json::decode($this->getRequest()->getContent(), Json::TYPE_ARRAY); + $params = []; + if ($this->getRequest()->getContent()) { + $params = Json::decode($this->getRequest()->getContent(), Json::TYPE_ARRAY); + } try { $userName = isset($params['username']) ? $params['username'] : ''; $password = isset($params['password']) ? $params['password'] : ''; From de97dffa8f3ef4629454d6a883fd6ea3b4924e34 Mon Sep 17 00:00:00 2001 From: Serhiy Shkolyarenko Date: Mon, 19 Oct 2015 18:45:36 +0300 Subject: [PATCH 08/17] MAGETWO-40822: [PHP7] Incompatible tests fixed mess detector test --- .../CodingStandard/Tool/CodeMessDetectorTest.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/CodingStandard/Tool/CodeMessDetectorTest.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/CodingStandard/Tool/CodeMessDetectorTest.php index 196e065ee3e70..b3b7e590f5776 100644 --- a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/CodingStandard/Tool/CodeMessDetectorTest.php +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/CodingStandard/Tool/CodeMessDetectorTest.php @@ -14,15 +14,8 @@ public function testCanRun() 'some/report/file.xml' ); - /** TODO: Remove provided check after PHPMD will support PHP version 7 */ - $isPhpVersionSupported = version_compare( - '7.0.0', - preg_replace('#^([^~+-]+).*$#', '$1', PHP_VERSION), - '>' - ); - $this->assertEquals( - class_exists('PHPMD\TextUI\Command') && $isPhpVersionSupported, + class_exists('PHPMD\TextUI\Command'), $messDetector->canRun() ); } From 2f6a433eaa233d2e5d99fb9f35b527042bfa57c5 Mon Sep 17 00:00:00 2001 From: Serhiy Shkolyarenko Date: Tue, 20 Oct 2015 10:14:33 +0300 Subject: [PATCH 09/17] MAGETWO-40822: [PHP7] Incompatible tests fixed mess detector test --- .../TestFramework/CodingStandard/Tool/CodeMessDetector.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CodeMessDetector.php b/dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CodeMessDetector.php index 6349d18bdced4..ed5c2b33fdb30 100644 --- a/dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CodeMessDetector.php +++ b/dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CodeMessDetector.php @@ -46,9 +46,7 @@ public function __construct($rulesetFile, $reportFile) */ public function canRun() { - /** TODO: Remove provided check after PHPMD will support PHP version 7 */ - $isPhpVersionSupported = PHP_VERSION_ID < 70000; - return class_exists('PHPMD\TextUI\Command') && $isPhpVersionSupported; + return class_exists('PHPMD\TextUI\Command'); } /** From e66add0257d07a8065f3e907d2fbb9032bc063c4 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Tue, 20 Oct 2015 15:19:30 +0300 Subject: [PATCH 10/17] MAGETWO-43796: Eliminate @removeCandidate anotation --- .../Checkout/Controller/Onepage/SaveOrder.php | 3 - .../view/frontend/requirejs-config.js | 5 +- .../templates/onepage/review/item.phtml | 4 - .../review/item/price/row_excl_tax.phtml | 4 - .../review/item/price/row_incl_tax.phtml | 4 - .../review/item/price/unit_excl_tax.phtml | 4 - .../review/item/price/unit_incl_tax.phtml | 4 - .../view/frontend/web/js/opc-billing-info.js | 57 -- .../frontend/web/js/opc-checkout-method.js | 291 -------- .../view/frontend/web/js/opc-order-review.js | 60 -- .../view/frontend/web/js/opc-payment-info.js | 178 ----- .../view/frontend/web/js/opc-shipping-info.js | 81 --- .../frontend/web/js/opc-shipping-method.js | 85 --- .../view/frontend/web/js/opcheckout.js | 645 ------------------ .../frontend/web/js/payment-authentication.js | 38 -- .../view/frontend/requirejs-config.js | 3 +- .../view/frontend/web/js/payment.js | 4 +- .../Paypal/view/frontend/requirejs-config.js | 1 - .../view/frontend/templates/onepage.phtml | 13 - .../Paypal/view/frontend/web/js/opcheckout.js | 35 - .../Test/Js/_files/blacklist/magento.txt | 20 +- .../Test/Js/_files/jshint/blacklist/core.txt | 1 - 22 files changed, 5 insertions(+), 1535 deletions(-) delete mode 100644 app/code/Magento/Checkout/view/frontend/web/js/opc-billing-info.js delete mode 100644 app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js delete mode 100644 app/code/Magento/Checkout/view/frontend/web/js/opc-order-review.js delete mode 100644 app/code/Magento/Checkout/view/frontend/web/js/opc-payment-info.js delete mode 100644 app/code/Magento/Checkout/view/frontend/web/js/opc-shipping-info.js delete mode 100644 app/code/Magento/Checkout/view/frontend/web/js/opc-shipping-method.js delete mode 100644 app/code/Magento/Checkout/view/frontend/web/js/opcheckout.js delete mode 100644 app/code/Magento/Checkout/view/frontend/web/js/payment-authentication.js rename app/code/Magento/{Checkout => Multishipping}/view/frontend/web/js/payment.js (99%) delete mode 100644 app/code/Magento/Paypal/view/frontend/templates/onepage.phtml delete mode 100644 app/code/Magento/Paypal/view/frontend/web/js/opcheckout.js diff --git a/app/code/Magento/Checkout/Controller/Onepage/SaveOrder.php b/app/code/Magento/Checkout/Controller/Onepage/SaveOrder.php index 82e9d18b8854e..6c66fd165de55 100644 --- a/app/code/Magento/Checkout/Controller/Onepage/SaveOrder.php +++ b/app/code/Magento/Checkout/Controller/Onepage/SaveOrder.php @@ -8,9 +8,6 @@ use Magento\Framework\DataObject; use Magento\Framework\Exception\PaymentException; -/** - * @removeCandidate - */ class SaveOrder extends \Magento\Checkout\Controller\Onepage { /** diff --git a/app/code/Magento/Checkout/view/frontend/requirejs-config.js b/app/code/Magento/Checkout/view/frontend/requirejs-config.js index e8a9923521254..a7055ed7d1558 100644 --- a/app/code/Magento/Checkout/view/frontend/requirejs-config.js +++ b/app/code/Magento/Checkout/view/frontend/requirejs-config.js @@ -9,10 +9,7 @@ var config = { discountCode: 'Magento_Checkout/js/discount-codes', shoppingCart: 'Magento_Checkout/js/shopping-cart', regionUpdater: 'Magento_Checkout/js/region-updater', - opcOrderReview: 'Magento_Checkout/js/opc-order-review', - sidebar: 'Magento_Checkout/js/sidebar', - payment: 'Magento_Checkout/js/payment', - paymentAuthentication: 'Magento_Checkout/js/payment-authentication' + sidebar: 'Magento_Checkout/js/sidebar' } } }; diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item.phtml index 7d107a0589d53..54748a318b6ad 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item.phtml @@ -8,10 +8,6 @@ /** @var $block Magento\Checkout\Block\Cart\Item\Renderer */ -/** - * @removeCandidate - */ - $_item = $block->getItem(); ?> diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/row_excl_tax.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/row_excl_tax.phtml index d10b01b1591fc..f0ead67e1bdc2 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/row_excl_tax.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/row_excl_tax.phtml @@ -8,10 +8,6 @@ /** @var $block \Magento\Checkout\Block\Item\Price\Renderer */ -/** - * @removeCandidate - */ - $_item = $block->getItem(); ?> diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/row_incl_tax.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/row_incl_tax.phtml index 09230fd5c336c..df0f4f3233cb7 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/row_incl_tax.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/row_incl_tax.phtml @@ -8,10 +8,6 @@ /** @var $block \Magento\Checkout\Block\Item\Price\Renderer */ -/** - * @removeCandidate - */ - $_item = $block->getItem(); ?> helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/unit_excl_tax.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/unit_excl_tax.phtml index f81ddc607c938..b4b340e78b553 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/unit_excl_tax.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/unit_excl_tax.phtml @@ -8,10 +8,6 @@ /** @var $block \Magento\Checkout\Block\Item\Price\Renderer */ -/** - * @removeCandidate - */ - $_item = $block->getItem(); ?> diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/unit_incl_tax.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/unit_incl_tax.phtml index 6ff351b90f76a..53118c3312595 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/unit_incl_tax.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item/price/unit_incl_tax.phtml @@ -8,10 +8,6 @@ /** @var $block \Magento\Checkout\Block\Item\Price\Renderer */ -/** - * @removeCandidate - */ - $_item = $block->getItem(); ?> helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item); ?> diff --git a/app/code/Magento/Checkout/view/frontend/web/js/opc-billing-info.js b/app/code/Magento/Checkout/view/frontend/web/js/opc-billing-info.js deleted file mode 100644 index 5ed385463d8bc..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/web/js/opc-billing-info.js +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @category one page checkout second step - * @package mage - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -/*jshint browser:true jquery:true*/ -/*global alert*/ -/** - * @removeCandidate - */ -define([ - "jquery", - "jquery/ui", - "Magento_Checkout/js/opc-checkout-method", - "mage/validation" -], function($){ - 'use strict'; - - // Extension for mage.opcheckout - second section(Billing Information) in one page checkout accordion - $.widget('mage.opcBillingInfo', $.mage.opcCheckoutMethod, { - options: { - billing: { - form: '#co-billing-form', - continueSelector: '#opc-billing [data-role=opc-continue]', - addressDropdownSelector: '#billing\\:address-select', - newAddressFormSelector: '#billing-new-address-form', - emailAddressName: 'billing[email]' - } - }, - - _create: function() { - this._super(); - var events = {}; - events['change ' + this.options.billing.addressDropdownSelector] = function(e) { - this.element.find(this.options.billing.newAddressFormSelector).toggle(!$(e.target).val()); - }; - events['click ' + this.options.billing.continueSelector] = function() { - if ($(this.options.billing.form).validation && $(this.options.billing.form).validation('isValid')) { - this._billingSave(); - } - }; - this._on(events); - - this.element.find(this.options.billing.form).validation(); - } , - - _billingSave: function() { - this._ajaxContinue(this.options.billing.saveUrl, $(this.options.billing.form).serialize(), false, function() { - //Trigger indicating billing save. eg. GiftMessage listens to this to inject gift options - this.element.trigger('billingSave'); - }); - } - }); - - return $.mage.opcBillingInfo; -}); \ No newline at end of file diff --git a/app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js b/app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js deleted file mode 100644 index 0f92f6ea63362..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js +++ /dev/null @@ -1,291 +0,0 @@ -/** - * @category one page checkout first step - * @package mage - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -/*jshint browser:true jquery:true*/ -/*global alert*/ -/** - * @removeCandidate - */ -define([ - "jquery", - "accordion", - 'Magento_Ui/js/modal/alert', - "jquery/ui", - "mage/validation/validation", - "mage/translate" -], function($, accordion, alert){ - 'use strict'; - - // Base widget, handle ajax events and first section(Checkout Method) in one page checkout accordion - $.widget('mage.opcCheckoutMethod', { - options: { - checkout: { - loginGuestSelector: '[data-role=checkout-method-guest]', - loginRegisterSelector: '[data-role=checkout-method-register]', - loginFormSelector: 'form[data-role=login]', - continueSelector: '#opc-login [data-role=opc-continue]', - registerCustomerPasswordSelector: '#co-billing-form .field.password,#co-billing-form .field.confirm', - captchaGuestCheckoutSelector: '#co-billing-form [role="guest_checkout"]', - registerDuringCheckoutSelector: '#co-billing-form [role="register_during_checkout"]', - suggestRegistration: false - }, - pageMessages: '#maincontent .messages .message', - sectionSelectorPrefix: 'opc-', - billingSection: 'billing', - ajaxLoaderPlaceButton: false, - updateSelectorPrefix: '#checkout-', - updateSelectorSuffix: '-load', - backSelector: '.action.back', - minBalance: 0.0001, - methodsListContainer: 'dl', - methodContainer: 'dt', - methodDescription : 'dd ul', - methodOn: 'dt input:radio' - }, - - _create: function() { - var self = this; - - this._initAccordion(); - - this.sectionActiveClass = this.element.accordion("option","openedState"); - this.contentSelector = this.element.accordion("option","content"); - this.checkoutPrice = this.options.quoteBaseGrandTotal; - - if (this.options.checkout.suggestRegistration) { - $(this.options.checkout.loginGuestSelector).prop('checked', false); - $(this.options.checkout.loginRegisterSelector).prop('checked', true); - } - this._handleSteps(); - var events = {}; - events['click ' + this.options.checkout.continueSelector] = function(e) { - this._continue($(e.currentTarget)); - }; - events['click ' + this.options.backSelector] = function(event) { - event.preventDefault(); - var prev = self.steps.index($('li.' + self.sectionActiveClass)) -1 ; - this._activateSection(prev); - }; - events['click ' + '[data-action=checkout-method-login]'] = function(event) { - if($(self.options.checkout.loginFormSelector).validation('isValid')){ - self.element.find('.section').filter('.' + self.sectionActiveClass).children(self.contentSelector).trigger("processStart"); - event.preventDefault(); - setTimeout(function(){ - $(self.options.checkout.loginFormSelector).submit(); - }, 300); - } - }; - - $(document).on({ - 'ajaxError': this._ajaxError.bind(this) - }); - - $.extend(events, { - showAjaxLoader: '_ajaxSend', - hideAjaxLoader: '_ajaxComplete', - gotoSection: function(e, section) { - self.element.find('.section').filter('.' + self.sectionActiveClass).children(self.contentSelector).trigger("processStop"); - var toActivate = this.steps.index($('#' + self.options.sectionSelectorPrefix + section)); - this._activateSection(toActivate); - } - }); - this._on(events); - - this._on($(this.options.checkoutProgressContainer), { - 'click [data-goto-section]' : function(e) { - var gotoSection = $(e.target).data('goto-section'); - self.element.find('.section').filter('.' + self.sectionActiveClass).children(self.contentSelector).trigger("processStop"); - var toActivate = this.steps.index($('#' + self.options.sectionSelectorPrefix + gotoSection)); - this._activateSection(toActivate); - return false; - } - }); - }, - - _initAccordion: function(){ - var config = this.element.data('accordion'); - - accordion(config, this.element[0]); - }, - - /** - * Get the checkout steps, disable steps but first, adding callback on before opening section to - * disable all next steps - * @private - */ - _handleSteps: function() { - var self = this; - this.steps = $(this.element).children('[id^=' + this.options.sectionSelectorPrefix + ']'); - this.element.accordion("disable"); - this._activateSection(0); - $.each(this.steps,function() { - $(this).on("beforeOpen",function() { - $(this).nextAll('[id^=' + self.options.sectionSelectorPrefix + ']').collapsible("disable"); - $(this).prevAll('[id^=' + self.options.sectionSelectorPrefix + ']').collapsible("enable"); - }); - }); - }, - - /** - * Activate section - * @param index the index of section you want to open - * @private - */ - _activateSection: function(index) { - this.element.accordion("enable",index); - this.element.accordion("activate",index); - }, - - /** - * Callback function for before ajax send event(global) - * @private - */ - _ajaxSend: function() { - this.element.find('.section').filter('.' + this.sectionActiveClass).children(this.contentSelector).trigger("processStart"); - }, - - /** - * Callback function for ajax complete event(global) - * @private - */ - _ajaxComplete: function() { - this.element.find('.section').filter('.' + this.sectionActiveClass).children(this.contentSelector).trigger("processStop"); - }, - - /** - * ajax error for all onepage checkout ajax calls - * @private - */ - _ajaxError: function() { - window.location.href = this.options.failureUrl; - }, - - /** - * callback function when continue button is clicked - * @private - * @param elem - continue button - * @return {Boolean} - */ - _continue: function(elem) { - var json = elem.data('checkout'), - checkout = this.options.checkout, - guestChecked = $( checkout.loginGuestSelector ).is( ':checked' ), - registerChecked = $( checkout.loginRegisterSelector ).is( ':checked' ), - method = 'register', - isRegistration = true; - - //Remove page messages - $(this.options.pageMessages).remove(); - - if (json.isGuestCheckoutAllowed) { - - if( !guestChecked && !registerChecked ){ - alert({ - content: $.mage.__('Please create an account or check out as a guest.') - }); - - return false; - } - - if( guestChecked ){ - method = 'guest'; - isRegistration = false; - } - - this._ajaxContinue( - checkout.saveUrl, - { method: method }, - this.options.billingSection - ); - - this.element.find(checkout.registerCustomerPasswordSelector).toggle(isRegistration); - this.element.find(checkout.captchaGuestCheckoutSelector).toggle(!isRegistration); - this.element.find(checkout.registerDuringCheckoutSelector).toggle(isRegistration); - } - else if( json.registrationUrl ){ - window.location = json.registrationUrl; - } - - this.element.trigger('login'); - }, - - /** - * Ajax call to save checkout info to backend and enable next section in accordion - * @private - * @param url - ajax url - * @param data - post data for ajax call - * @param gotoSection - the section needs to show after ajax call - * @param successCallback - custom callback function in ajax success - */ - _ajaxContinue: function(url, data, gotoSection, successCallback) { - $.ajax({ - url: url, - type: 'post', - context: this, - data: data, - dataType: 'json', - beforeSend: this._ajaxSend, - complete: this._ajaxComplete, - success: function (response) { - if (successCallback) { - successCallback.call(this, response); - } - if ($.type(response) === 'object' && !$.isEmptyObject(response)) { - if (response.error) { - var msg = response.message || response.error_messages || response.error; - - if (msg) { - if (Array.isArray(msg)) { - msg = msg.reduce(function (str, chunk) { - str += '\n' + chunk; - return str; - }, ''); - } - - $(this.options.countrySelector).trigger('change'); - - alert({ - content: msg - }); - } - - return; - } - if (response.redirect) { - $.mage.redirect(response.redirect); - return false; - } - else if (response.success) { - $.mage.redirect(this.options.review.successUrl); - return false; - } - if (response.update_section) { - if (response.update_section.name === 'payment-method' && response.update_section.html.indexOf('data-checkout-price')) { - this.element.find(this.options.payment.form).find('[data-checkout-price]').remove(); - } - $(this.options.updateSelectorPrefix + response.update_section.name + this.options.updateSelectorSuffix) - .html($(response.update_section.html)).trigger('contentUpdated'); - } - if (response.update_progress) { - $(this.options.checkoutProgressContainer).html($(response.update_progress.html)).trigger('progressUpdated'); - } - if (response.duplicateBillingInfo) { - $(this.options.shipping.copyBillingSelector).prop('checked', true).trigger('click'); - $(this.options.shipping.addressDropdownSelector).val($(this.options.billing.addressDropdownSelector).val()).change(); - } - if (response.goto_section) { - this.element.trigger('gotoSection', response.goto_section); - } - } else { - this.element.trigger('gotoSection', gotoSection); - } - } - }); - } - }); - - return $.mage.opcCheckoutMethod; -}); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/opc-order-review.js b/app/code/Magento/Checkout/view/frontend/web/js/opc-order-review.js deleted file mode 100644 index 83313faeebf5c..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/web/js/opc-order-review.js +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @category one page checkout last step - * @package mage - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -/*jshint browser:true jquery:true*/ -/*global alert*/ -/** - * @removeCandidate - */ -define([ - "jquery", - "jquery/ui", - "Magento_Checkout/js/opc-payment-info" -], function($){ - 'use strict'; - - // Extension for mage.opcheckout - last section(Order Review) in one page checkout accordion - $.widget('mage.opcOrderReview', $.mage.opcPaymentInfo, { - options: { - review: { - continueSelector: '#opc-review [data-role=review-save]', - container: '#opc-review', - agreementGroupSelector: '#checkout-agreements' - } - }, - - _create: function() { - this._super(); - var events = {}; - events['click ' + this.options.review.continueSelector] = this._saveOrder; - events['saveOrder' + this.options.review.container] = this._saveOrder; - this._on(events); - }, - - _saveOrder: function() { - var agreementFormsGroup = $(this.options.review.agreementGroupSelector), - paymentForm = $(this.options.payment.form); - var isAgreementValid = true; - agreementFormsGroup.find('form').each( - function(){ - isAgreementValid = $(this).validation() && $(this).validation('isValid') && isAgreementValid; - } - ); - - if (isAgreementValid && - paymentForm.validation && - paymentForm.validation('isValid')) { - var serializedAgreement = ''; - agreementFormsGroup.find('form').each(function(){serializedAgreement += '&' + $(this).serialize();}); - this._ajaxContinue( - this.options.review.saveUrl, - paymentForm.serialize() + serializedAgreement); - } - } - }); - - return $.mage.opcOrderReview; -}); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/opc-payment-info.js b/app/code/Magento/Checkout/view/frontend/web/js/opc-payment-info.js deleted file mode 100644 index bfa87548aea2a..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/web/js/opc-payment-info.js +++ /dev/null @@ -1,178 +0,0 @@ -/** - * @category one page checkout fifth step - * @package mage - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -/*jshint browser:true*/ -/*global alert*/ -/** - * @removeCandidate - */ -define([ - 'jquery', - 'mage/template', - 'Magento_Ui/js/modal/alert', - 'jquery/ui', - 'mage/translate', - 'Magento_Checkout/js/opc-shipping-method' -], function ($, mageTemplate, alert) { - 'use strict'; - - // Extension for mage.opcheckout - fifth section(Payment Information) in one page checkout accordion - $.widget('mage.opcPaymentInfo', $.mage.opcShippingMethod, { - options: { - payment: { - form: '#co-payment-form', - continueSelector: '#payment [data-role=opc-continue]', - methodsContainer: '#checkout-payment-method-load', - freeInput: { - tmpl: '', - selector: '#hidden-free' - } - } - }, - - _create: function () { - this._super(); - - var events = {}; - - this.freeInputTmpl = mageTemplate(this.options.payment.freeInput.tmpl); - - events['click ' + this.options.payment.continueSelector] = function () { - if (this._validatePaymentMethod() && - $(this.options.payment.form).validation && - $(this.options.payment.form).validation('isValid')) { - this._ajaxContinue(this.options.payment.saveUrl, $(this.options.payment.form).serialize()); - } - }; - - events['contentUpdated ' + this.options.payment.form] = function () { - $(this.options.payment.form).find('dd [name^="payment["]').prop('disabled', true); - var checkoutPrice = this.element.find(this.options.payment.form).find('[data-checkout-price]').data('checkout-price'); - - if ($.isNumeric(checkoutPrice)) { - this.checkoutPrice = checkoutPrice; - } - - if (this.checkoutPrice < this.options.minBalance) { - this._disablePaymentMethods(); - } else { - this._enablePaymentMethods(); - } - }; - - events['click ' + this.options.payment.form + ' dt input:radio'] = '_paymentMethodHandler'; - - $.extend(events, { - updateCheckoutPrice: function (event, data) { - if (data.price) { - this.checkoutPrice += data.price; - } - - if (data.totalPrice) { - data.totalPrice = this.checkoutPrice; - } - - if (this.checkoutPrice < this.options.minBalance) { - // Add free input field, hide and disable unchecked checkbox payment method and all radio button payment methods - this._disablePaymentMethods(); - } else { - // Remove free input field, show all payment method - this._enablePaymentMethods(); - } - } - }); - - this._on(events); - - this.element.find(this.options.payment.form).validation({ - errorPlacement: function (error, element) { - if (element.attr('data-validate') && element.attr('data-validate').indexOf('validate-cc-ukss') >= 0) { - element.parents('form').find('[data-validation-msg="validate-cc-ukss"]').html(error); - } else { - element.after(error); - } - } - }); - }, - - /** - * Display payment details when payment method radio button is checked - * @private - * @param {EventObject} e - */ - _paymentMethodHandler: function (e) { - var _this = $(e.target), - parentsDl = _this.closest(this.options.methodsListContainer); - parentsDl.find(this.options.methodOn).prop('checked', false); - _this.prop('checked', true); - parentsDl.find(this.options.methodDescription).hide().find('[name^="payment["]').prop('disabled', true); - _this.parent().nextUntil(this.options.methodContainer).find(this.options.methodDescription).show().find('[name^="payment["]').prop('disabled', false); - }, - - /** - * make sure one payment method is selected - * @private - * @return {Boolean} - */ - _validatePaymentMethod: function () { - var methods = this.element.find('[name^="payment["]'); - - if (methods.length === 0) { - alert({ - content: $.mage.__('We can\'t complete your order because you don\'t have a payment method set up.') - }); - - return false; - } - - if (this.checkoutPrice < this.options.minBalances) { - return true; - } else if (methods.filter('input:radio:checked').length) { - return true; - } - - alert({ - content: $.mage.__('Please choose a payment method.') - }); - - return false; - }, - - /** - * Disable and enable payment methods - * @private - */ - _disablePaymentMethods: function () { - var paymentForm = $(this.options.payment.form), - tmpl = this.freeInputTmpl({ - data: {} - }); - - paymentForm.find('input[name="payment[method]"]').prop('disabled', true); - paymentForm.find(this.options.payment.methodsContainer).find('[name^="payment["]').prop('disabled', true); - paymentForm.find('input[id^="use"][name^="payment[use"]:not(:checked)').prop('disabled', true).parent(); - paymentForm.find(this.options.payment.freeInput.selector).remove(); - - $(tmpl).appendTo(paymentForm); - }, - - /** - * Enable and enable payment methods - * @private - */ - _enablePaymentMethods: function () { - var paymentForm = $(this.options.payment.form); - - paymentForm.find('input[name="payment[method]"]').prop('disabled', false); - paymentForm.find('input[name="payment[method]"]:checked').trigger('click'); - paymentForm.find(this.options.payment.methodsContainer).show(); - paymentForm.find('input[id^="use"][name^="payment[use"]:not(:checked)').prop('disabled', false).parent().show(); - paymentForm.find(this.options.payment.freeInput.selector).remove(); - } - }); - - return $.mage.opcPaymentInfo; -}); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/opc-shipping-info.js b/app/code/Magento/Checkout/view/frontend/web/js/opc-shipping-info.js deleted file mode 100644 index bf3ef59bcf429..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/web/js/opc-shipping-info.js +++ /dev/null @@ -1,81 +0,0 @@ -/** - * @category one page checkout third step - * @package mage - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -/*jshint browser:true jquery:true*/ -/*global alert*/ -/** - * @removeCandidate - */ -define([ - "jquery", - "jquery/ui", - "Magento_Checkout/js/opc-billing-info", - "mage/validation" -], function($){ - 'use strict'; - - // Extension for mage.opcheckout - third section(Shipping Information) in one page checkout accordion - $.widget('mage.opcShippingInfo', $.mage.opcBillingInfo, { - options: { - shipping: { - form: '#co-shipping-form', - continueSelector:'#shipping [data-role=opc-continue]', - addressDropdownSelector: '#shipping\\:address-select', - newAddressFormSelector: '#shipping-new-address-form', - copyBillingSelector: '#shipping\\:same_as_billing', - countrySelector: '#shipping\\:country_id' - } - }, - - _create: function() { - this._super(); - var events = {}; - var onInputPropChange = function() { - $(this.options.shipping.copyBillingSelector).prop('checked', false); - }; - events['change ' + this.options.shipping.addressDropdownSelector] = function(e) { - $(this.options.shipping.newAddressFormSelector).toggle(!$(e.target).val()); - onInputPropChange.call(this); - }; - // for guest checkout - events['input ' + this.options.shipping.form + ' :input[name]'] = onInputPropChange; - events['propertychange ' + this.options.shipping.form + ' :input[name]'] = onInputPropChange; - events['click ' + this.options.shipping.copyBillingSelector] = function(e) { - if ($(e.target).is(':checked')) { - this._billingToShipping(); - } - }; - events['click ' + this.options.shipping.continueSelector] = function() { - if ($(this.options.shipping.form).validation && $(this.options.shipping.form).validation('isValid')) { - this._ajaxContinue(this.options.shipping.saveUrl, $(this.options.shipping.form).serialize(), false, function() { - //Trigger indicating shipping save. eg. GiftMessage listens to this to inject gift options - this.element.trigger('shippingSave'); - }); - } - }; - this._on(events); - - this.element.find(this.options.shipping.form).validation(); - }, - - /** - * Copy billing address info to shipping address - * @private - */ - _billingToShipping: function() { - $(':input[name]', this.options.billing.form).each($.proxy(function(key, value) { - var fieldObj = $(value.id.replace('billing:', '#shipping\\:')); - fieldObj.val($(value).val()); - if (fieldObj.is("select")) { - fieldObj.trigger('change'); - } - }, this)); - $(this.options.shipping.copyBillingSelector).prop('checked', true); - } - }); - - return $.mage.opcShippingInfo; -}); \ No newline at end of file diff --git a/app/code/Magento/Checkout/view/frontend/web/js/opc-shipping-method.js b/app/code/Magento/Checkout/view/frontend/web/js/opc-shipping-method.js deleted file mode 100644 index 505db47ab5790..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/web/js/opc-shipping-method.js +++ /dev/null @@ -1,85 +0,0 @@ -/** - * @category one page checkout fourth step - * @package mage - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -/*jshint browser:true jquery:true*/ -/*global alert*/ -/** - * @removeCandidate - */ -define([ - "jquery", - 'Magento_Ui/js/modal/alert', - "jquery/ui", - "Magento_Checkout/js/opc-shipping-info", - "mage/validation", - "mage/translate" -], function($, alert){ - 'use strict'; - - // Extension for mage.opcheckout - fourth section(Shipping Method) in one page checkout accordion - $.widget('mage.opcShippingMethod', $.mage.opcShippingInfo, { - options: { - shippingMethod: { - form: '#co-shipping-method-form', - continueSelector: '#opc-shipping_method [data-role=opc-continue]' - } - }, - - _create: function() { - this._super(); - var events = {}; - events['click ' + this.options.shippingMethod.continueSelector] = function() { - if (this._validateShippingMethod()&& - $(this.options.shippingMethod.form).validation && - $(this.options.shippingMethod.form).validation('isValid')) { - this._ajaxContinue(this.options.shippingMethod.saveUrl, $(this.options.shippingMethod.form).serialize()); - } - }; - $.extend(events, { - 'click input[name=shipping_method]': function(e) { - var selectedPrice = this.shippingCodePrice[$(e.target).val()] || 0, - oldPrice = this.shippingCodePrice[this.currentShippingMethod] || 0; - this.checkoutPrice = this.checkoutPrice - oldPrice + selectedPrice; - this.currentShippingMethod = $(e.target).val(); - }, - 'contentUpdated': function() { - this.currentShippingMethod = this.element.find('input[name="shipping_method"]:checked').val(); - this.shippingCodePrice = this.element.find('[data-shipping-code-price]').data('shipping-code-price'); - } - }); - this._on(events); - - this.element.find(this.options.shippingMethod.form).validation(); - }, - - /** - * Make sure at least one shipping method is selected - * @return {Boolean} - * @private - */ - _validateShippingMethod: function() { - var methods = this.element.find('[name="shipping_method"]'); - if (methods.length === 0) { - alert({ - content: $.mage.__('We can\'t ship to this address. Please enter another address or edit this one.') - }); - - return false; - } - - if (methods.filter(':checked').length) { - return true; - } - alert({ - content:$.mage.__('Please specify a shipping method.') - }); - - return false; - } - }); - - return $.mage.opcShippingMethod; -}); \ No newline at end of file diff --git a/app/code/Magento/Checkout/view/frontend/web/js/opcheckout.js b/app/code/Magento/Checkout/view/frontend/web/js/opcheckout.js deleted file mode 100644 index 570dd9edf2d89..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/web/js/opcheckout.js +++ /dev/null @@ -1,645 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -/*jshint browser:true*/ -/*global alert*/ -/** - * @removeCandidate - */ -define([ - 'jquery', - 'mage/template', - 'Magento_Ui/js/modal/alert', - 'jquery/ui', - 'mage/validation', - 'mage/translate' -], function ($, mageTemplate, alert) { - 'use strict'; - - // Base widget, handle ajax events and first section(Checkout Method) in one page checkout accordion - $.widget('mage.opcheckout', { - options: { - checkout: { - loginGuestSelector: '#login\\:guest', - loginRegisterSelector: '#login\\:register', - loginFormSelector: '#login-form', - continueSelector: '#onepage-guest-register-button', - registerCustomerPasswordSelector: '#co-billing-form .field.password,#co-billing-form .field.confirm', - suggestRegistration: false - }, - sectionSelectorPrefix: '#opc-', - billingSection: 'billing', - ajaxLoaderPlaceButton: false, - updateSelectorPrefix: '#checkout-', - updateSelectorSuffix: '-load', - backSelector: '.action.back', - minBalance: 0.0001, - methodsListContainer: 'dl', - methodContainer: 'dt', - methodDescription: 'dd ul', - methodOn: 'dt input:radio' - }, - - _create: function () { - var events = {}; - - this.checkoutPrice = this.options.quoteBaseGrandTotal; - - if (this.options.checkout.suggestRegistration) { - $(this.options.checkout.loginGuestSelector).prop('checked', false); - $(this.options.checkout.loginRegisterSelector).prop('checked', true); - } - - events['click ' + this.options.checkout.continueSelector] = function (e) { - this._continue($(e.currentTarget)); - }; - - events['click ' + this.options.backSelector] = function () { - this.element.trigger('enableSection', { - selector: '#' + this.element.find('.active').prev().attr('id') - }); - }; - - $(document).on({ - 'ajaxError': this._ajaxError.bind(this) - }); - - $.extend(events, { - showAjaxLoader: '_ajaxSend', - hideAjaxLoader: '_ajaxComplete', - gotoSection: function (e, section) { - this._ajaxUpdateProgress(section); - this.element.trigger('enableSection', { - selector: this.options.sectionSelectorPrefix + section - }); - }, - 'click [data-action=login-form-submit]': function () { - $(this.options.checkout.loginFormSelector).submit(); - } - }); - - this._on(events); - - this._on($(this.options.checkoutProgressContainer), { - 'click [data-goto-section]': function (e) { - var gotoSection = $(e.target).data('goto-section'); - - this._ajaxUpdateProgress(gotoSection); - - this.element.trigger('enableSection', { - selector: this.options.sectionSelectorPrefix + gotoSection - }); - - return false; - } - }); - }, - - /** - * Callback function for before ajax send event(global) - * @private - */ - _ajaxSend: function () { - var loader; - - this.element.addClass('loading'); - - loader = this.element.find('.please-wait').show(); - - if (this.options.ajaxLoaderPlaceButton) { - loader.siblings('.button').hide(); - } - }, - - /** - * Callback function for ajax complete event(global) - * @private - */ - _ajaxComplete: function () { - this.element.removeClass('loading'); - this.element.find('.please-wait').hide(); - - if (this.options.ajaxLoaderPlaceButton) { - this.element.find('.button').show(); - } - }, - - /** - * ajax error for all onepage checkout ajax calls - * @private - */ - _ajaxError: function () { - window.location.href = this.options.failureUrl; - }, - - /** - * callback function when continue button is clicked - * @private - * @param elem - continue button - * @return {Boolean} - */ - _continue: function (elem) { - var json = elem.data('checkout'); - - if (json.isGuestCheckoutAllowed) { - if ($(this.options.checkout.loginGuestSelector).is(':checked')) { - this._ajaxContinue(this.options.checkout.saveUrl, { - method: 'guest' - }, this.options.billingSection); - - this.element.find(this.options.checkout.registerCustomerPasswordSelector).hide(); - } else if ($(this.options.checkout.loginRegisterSelector).is(':checked')) { - this._ajaxContinue(this.options.checkout.saveUrl, { - method: 'register' - }, this.options.billingSection); - - this.element.find(this.options.checkout.registerCustomerPasswordSelector).show(); - } else { - alert({ - content: $.mage.__('Please create an account or check out as a guest.') - }); - - return false; - } - } else { - if (json.registrationUrl) { - window.location.href = json.registrationUrl; - } - } - - this.element.trigger('login'); - }, - - /** - * Ajax call to save checkout info to backend and enable next section in accordion - * @private - * @param url - ajax url - * @param data - post data for ajax call - * @param gotoSection - the section needs to show after ajax call - * @param successCallback - custom callback function in ajax success - */ - _ajaxContinue: function (url, data, gotoSection, successCallback) { - $.ajax({ - url: url, - type: 'post', - context: this, - data: data, - dataType: 'json', - beforeSend: this._ajaxSend, - complete: this._ajaxComplete, - success: function (response) { - if (successCallback) { - successCallback.call(this, response); - } - - if ($.type(response) === 'object' && !$.isEmptyObject(response)) { - if (response.error) { - var msg = response.message || response.error_messages; - - if (msg) { - if ($.type(msg) === 'array') { - msg = msg.join("\n"); - } - - $(this.options.countrySelector).trigger('change'); - - alert({ - content: msg - }); - } else { - alert({ - content: response.error - }); - } - - return; - } - - if (response.redirect) { - $.mage.redirect(response.redirect); - - return false; - } else if (response.success) { - $.mage.redirect(this.options.review.successUrl); - - return false; - } - - if (response.update_section) { - if (response.update_section.name === 'payment-method' && response.update_section.html.indexOf('data-checkout-price')) { - this.element.find(this.options.payment.form).find('[data-checkout-price]').remove(); - } - $(this.options.updateSelectorPrefix + response.update_section.name + this.options.updateSelectorSuffix) - .html($(response.update_section.html)).trigger('contentUpdated'); - } - - if (response.duplicateBillingInfo) { - $(this.options.shipping.copyBillingSelector).prop('checked', true).trigger('click'); - $(this.options.shipping.addressDropdownSelector).val($(this.options.billing.addressDropdownSelector).val()).change(); - } - - if (response.goto_section) { - this.element.trigger('gotoSection', response.goto_section); - } - } else { - this.element.trigger('gotoSection', gotoSection); - } - } - }); - }, - - /** - * Update progress sidebar content - * @private - * @param {*} toStep - */ - _ajaxUpdateProgress: function (toStep) { - if (toStep) { - $.ajax({ - url: this.options.progressUrl, - type: 'get', - async: false, - cache: false, - context: this, - data: toStep ? { - toStep: toStep - } : null, - success: function (response) { - $(this.options.checkoutProgressContainer).html(response); - } - }); - } - } - }); - - // Extension for mage.opcheckout - second section(Billing Information) in one page checkout accordion - $.widget('mage.opcheckout', $.mage.opcheckout, { - options: { - billing: { - addressDropdownSelector: '#billing\\:address-select', - newAddressFormSelector: '#billing-new-address-form', - continueSelector: '#billing-buttons-container .button', - form: '#co-billing-form' - } - }, - - _create: function () { - var events; - - this._super(); - - events = {}; - - events['change ' + this.options.billing.addressDropdownSelector] = function (e) { - this.element.find(this.options.billing.newAddressFormSelector).toggle(!$(e.target).val()); - }; - - events['click ' + this.options.billing.continueSelector] = function () { - if ($(this.options.billing.form).validation && $(this.options.billing.form).validation('isValid')) { - this._billingSave(); - } - }; - - this._on(events); - - this.element.find(this.options.billing.form).validation(); - }, - - _billingSave: function () { - this._ajaxContinue(this.options.billing.saveUrl, $(this.options.billing.form).serialize(), false, function () { - //Trigger indicating billing save. eg. GiftMessage listens to this to inject gift options - this.element.trigger('billingSave'); - }); - } - }); - - // Extension for mage.opcheckout - third section(Shipping Information) in one page checkout accordion - $.widget('mage.opcheckout', $.mage.opcheckout, { - options: { - shipping: { - form: '#co-shipping-form', - addressDropdownSelector: '#shipping\\:address-select', - newAddressFormSelector: '#shipping-new-address-form', - copyBillingSelector: '#shipping\\:same_as_billing', - countrySelector: '#shipping\\:country_id', - continueSelector: '#shipping-buttons-container .button' - } - }, - - _create: function () { - var events, - onInputPropChange; - - this._super(); - - events = {}; - - onInputPropChange = function () { - $(this.options.shipping.copyBillingSelector).prop('checked', false); - }; - - events['change ' + this.options.shipping.addressDropdownSelector] = function (e) { - $(this.options.shipping.newAddressFormSelector).toggle(!$(e.target).val()); - onInputPropChange.call(this); - }; - - // for guest checkout - events['input ' + this.options.shipping.form + ' :input[name]'] = onInputPropChange; - - events['propertychange ' + this.options.shipping.form + ' :input[name]'] = onInputPropChange; - - events['click ' + this.options.shipping.copyBillingSelector] = function (e) { - if ($(e.target).is(':checked')) { - this._billingToShipping(); - } - }; - - events['click ' + this.options.shipping.continueSelector] = function () { - if ($(this.options.shipping.form).validation && $(this.options.shipping.form).validation('isValid')) { - this._ajaxContinue(this.options.shipping.saveUrl, $(this.options.shipping.form).serialize(), false, function () { - //Trigger indicating shipping save. eg. GiftMessage listens to this to inject gift options - this.element.trigger('shippingSave'); - }); - } - }; - - this._on(events); - - this.element.find(this.options.shipping.form).validation(); - }, - - /** - * Copy billing address info to shipping address - * @private - */ - _billingToShipping: function () { - $(':input[name]', this.options.billing.form).each($.proxy(function (key, value) { - var fieldObj = $(value.id.replace('billing:', '#shipping\\:')); - - fieldObj.val($(value).val()); - - if (fieldObj.is('select')) { - fieldObj.trigger('change'); - } - }, this)); - - $(this.options.shipping.copyBillingSelector).prop('checked', true); - } - }); - - // Extension for mage.opcheckout - fourth section(Shipping Method) in one page checkout accordion - $.widget('mage.opcheckout', $.mage.opcheckout, { - options: { - shippingMethod: { - continueSelector: '#shipping-method-buttons-container .button', - form: '#co-shipping-method-form' - } - }, - - _create: function () { - this._super(); - var events = {}; - events['click ' + this.options.shippingMethod.continueSelector] = function () { - if (this._validateShippingMethod() && - $(this.options.shippingMethod.form).validation && - $(this.options.shippingMethod.form).validation('isValid')) { - this._ajaxContinue(this.options.shippingMethod.saveUrl, $(this.options.shippingMethod.form).serialize()); - } - }; - $.extend(events, { - 'click input[name=shipping_method]': function (e) { - var selectedPrice = this.shippingCodePrice[$(e.target).val()] || 0, - oldPrice = this.shippingCodePrice[this.currentShippingMethod] || 0; - this.checkoutPrice = this.checkoutPrice - oldPrice + selectedPrice; - this.currentShippingMethod = $(e.target).val(); - }, - 'contentUpdated': function () { - this.currentShippingMethod = this.element.find('input[name="shipping_method"]:checked').val(); - this.shippingCodePrice = this.element.find('[data-shipping-code-price]').data('shipping-code-price'); - } - }); - this._on(events); - - this.element.find(this.options.shippingMethod.form).validation(); - }, - - /** - * Make sure at least one shipping method is selected - * @return {Boolean} - * @private - */ - _validateShippingMethod: function () { - var methods = this.element.find('[name="shipping_method"]'); - - if (methods.length === 0) { - alert({ - content: $.mage.__('We can\'t ship to this address. Please choose another address or edit the current one.') - }); - - return false; - } - - if (methods.filter(':checked').length) { - return true; - } - - alert({ - content: $.mage.__('Please specify a shipping method.') - }); - - return false; - } - }); - - // Extension for mage.opcheckout - fifth section(Payment Information) in one page checkout accordion - $.widget('mage.opcheckout', $.mage.opcheckout, { - options: { - payment: { - continueSelector: '#payment-buttons-container .button', - form: '#co-payment-form', - methodsContainer: '#checkout-payment-method-load', - freeInput: { - tmpl: '', - selector: '#hidden-free' - } - } - }, - - _create: function () { - var events; - - this._super(); - - this.freeInputTmpl = mageTemplate(this.options.payment.freeInput.tmpl); - - events = {}; - - events['click ' + this.options.payment.continueSelector] = function () { - if (this._validatePaymentMethod() && - $(this.options.payment.form).validation && - $(this.options.payment.form).validation('isValid')) { - this._ajaxContinue(this.options.payment.saveUrl, $(this.options.payment.form).serialize()); - } - }; - - events['contentUpdated ' + this.options.payment.form] = function () { - var checkoutPrice; - - $(this.options.payment.form).find('dd [name^="payment["]').prop('disabled', true); - - checkoutPrice = this.element.find(this.options.payment.form).find('[data-checkout-price]').data('checkout-price'); - - if ($.isNumeric(checkoutPrice)) { - this.checkoutPrice = checkoutPrice; - } - - if (this.checkoutPrice < this.options.minBalance) { - this._disablePaymentMethods(); - } else { - this._enablePaymentMethods(); - } - }; - - events['click ' + this.options.payment.form + ' dt input:radio'] = '_paymentMethodHandler'; - - $.extend(events, { - updateCheckoutPrice: function (event, data) { - if (data.price) { - this.checkoutPrice += data.price; - } - - if (data.totalPrice) { - data.totalPrice = this.checkoutPrice; - } - - if (this.checkoutPrice < this.options.minBalance) { - // Add free input field, hide and disable unchecked checkbox payment method and all radio button payment methods - this._disablePaymentMethods(); - } else { - // Remove free input field, show all payment method - this._enablePaymentMethods(); - } - } - }); - - this._on(events); - - this.element.find(this.options.payment.form).validation({ - errorPlacement: function (error, element) { - if (element.attr('data-validate') && element.attr('data-validate').indexOf('validate-cc-ukss') >= 0) { - element.parents('form').find('[data-validation-msg="validate-cc-ukss"]').html(error); - } else { - element.after(error); - } - } - }); - }, - - /** - * Display payment details when payment method radio button is checked - * @private - * @param {EventObject} e - */ - _paymentMethodHandler: function (e) { - var _this = $(e.target), - parentsDl = _this.closest(this.options.methodsListContainer); - parentsDl.find(this.options.methodOn).prop('checked', false); - _this.prop('checked', true); - parentsDl.find(this.options.methodDescription).hide().find('[name^="payment["]').prop('disabled', true); - _this.closest(this.options.methodContainer) - .nextUntil(this.options.methodContainer) - .find(this.options.methodDescription).show().find('[name^="payment["]').prop('disabled', false); - }, - - /** - * make sure one payment method is selected - * @private - * @return {Boolean} - */ - _validatePaymentMethod: function () { - var methods = this.element.find('[name^="payment["]'); - - if (methods.length === 0) { - alert({ - content: $.mage.__('We can\'t complete your order because you don\'t have a payment method set up.') - }); - - return false; - } - - if (this.checkoutPrice < this.options.minBalance) { - return true; - } else if (methods.filter('input:radio:checked').length) { - return true; - } - - alert({ - content: $.mage.__('Please choose a payment method.') - }); - - return false; - }, - - /** - * Disable and enable payment methods - * @private - */ - _disablePaymentMethods: function () { - var paymentForm = $(this.options.payment.form), - tmpl = this.freeInputTmpl({ - data: {} - }); - - paymentForm.find('input[name="payment[method]"]').prop('disabled', true); - paymentForm.find(this.options.payment.methodsContainer).find('[name^="payment["]').prop('disabled', true); - paymentForm.find('input[id^="use"][name^="payment[use"]:not(:checked)').prop('disabled', true).parent(); - paymentForm.find(this.options.payment.freeInput.selector).remove(); - - $(tmpl).appendTo(paymentForm); - }, - - /** - * Enable and enable payment methods - * @private - */ - _enablePaymentMethods: function () { - var paymentForm = $(this.options.payment.form); - paymentForm.find('input[name="payment[method]"]').prop('disabled', false); - paymentForm.find('input[name="payment[method]"]:checked').trigger('click'); - paymentForm.find(this.options.payment.methodsContainer).show(); - paymentForm.find('input[id^="use"][name^="payment[use"]:not(:checked)').prop('disabled', false).parent().show(); - paymentForm.find(this.options.payment.freeInput.selector).remove(); - } - }); - - // Extension for mage.opcheckout - last section(Order Review) in one page checkout accordion - $.widget('mage.opcheckout', $.mage.opcheckout, { - options: { - review: { - continueSelector: '#review-buttons-container .button', - container: '#opc-review', - agreementFormSelector: '#checkout-agreements input[type="checkbox"]' - } - }, - - _create: function () { - this._super(); - var events = {}; - events['click ' + this.options.review.continueSelector] = this._saveOrder; - events['saveOrder' + this.options.review.container] = this._saveOrder; - this._on(events); - }, - - _saveOrder: function () { - if ($(this.options.payment.form).validation && - $(this.options.payment.form).validation('isValid')) { - this._ajaxContinue( - this.options.review.saveUrl, - $(this.options.payment.form).serialize() + '&' + $(this.options.review.agreementFormSelector).serialize()); - } - } - }); - - return $.mage.opcheckout; -}); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/payment-authentication.js b/app/code/Magento/Checkout/view/frontend/web/js/payment-authentication.js deleted file mode 100644 index 8b03193bb79c9..0000000000000 --- a/app/code/Magento/Checkout/view/frontend/web/js/payment-authentication.js +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -/*jshint jquery:true*/ -/** - * @removeCandidate - */ -define([ - "jquery", - "jquery/ui" -], function($){ - "use strict"; - - $.widget('mage.paymentAuthentication', { - options : { - bodySelector: '[data-container="body"]' - }, - - _create: function () { - // add a trigger on the body for payment authentication state changes - this.element.closest(this.options.bodySelector).on("paymentAuthentication", $.proxy(this._paymentmentAthenticationTrigger, this)); - }, - - /** - * This method processes the paymentAuthentication actions. - */ - _paymentmentAthenticationTrigger: function (event, data) { - if (data.state === 'start') { - this.element.hide(); - } else { - this.element.show(); - } - } - }); - - return $.mage.paymentAuthentication; -}); \ No newline at end of file diff --git a/app/code/Magento/Multishipping/view/frontend/requirejs-config.js b/app/code/Magento/Multishipping/view/frontend/requirejs-config.js index 034ecbd8057cc..dbbc46fd92866 100644 --- a/app/code/Magento/Multishipping/view/frontend/requirejs-config.js +++ b/app/code/Magento/Multishipping/view/frontend/requirejs-config.js @@ -7,7 +7,8 @@ var config = { map: { '*': { multiShipping: 'Magento_Multishipping/js/multi-shipping', - orderOverview: 'Magento_Multishipping/js/overview' + orderOverview: 'Magento_Multishipping/js/overview', + payment: 'Magento_Multishipping/js/payment' } } }; \ No newline at end of file diff --git a/app/code/Magento/Checkout/view/frontend/web/js/payment.js b/app/code/Magento/Multishipping/view/frontend/web/js/payment.js similarity index 99% rename from app/code/Magento/Checkout/view/frontend/web/js/payment.js rename to app/code/Magento/Multishipping/view/frontend/web/js/payment.js index 1442bb7876052..8baea212f57c0 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/payment.js +++ b/app/code/Magento/Multishipping/view/frontend/web/js/payment.js @@ -4,9 +4,7 @@ */ /*jshint browser:true*/ /*global alert*/ -/** - * @removeCandidate - */ + define([ 'jquery', 'mage/template', diff --git a/app/code/Magento/Paypal/view/frontend/requirejs-config.js b/app/code/Magento/Paypal/view/frontend/requirejs-config.js index 49f8f54129f62..8e6be0da47bd1 100644 --- a/app/code/Magento/Paypal/view/frontend/requirejs-config.js +++ b/app/code/Magento/Paypal/view/frontend/requirejs-config.js @@ -6,7 +6,6 @@ var config = { map: { '*': { - opcheckoutPaypalIframe: 'Magento_Paypal/js/opcheckout', orderReview: 'Magento_Paypal/order-review', paypalCheckout: 'Magento_Paypal/js/paypal-checkout' } diff --git a/app/code/Magento/Paypal/view/frontend/templates/onepage.phtml b/app/code/Magento/Paypal/view/frontend/templates/onepage.phtml deleted file mode 100644 index 140ad1a72e484..0000000000000 --- a/app/code/Magento/Paypal/view/frontend/templates/onepage.phtml +++ /dev/null @@ -1,13 +0,0 @@ - - \ No newline at end of file diff --git a/app/code/Magento/Paypal/view/frontend/web/js/opcheckout.js b/app/code/Magento/Paypal/view/frontend/web/js/opcheckout.js deleted file mode 100644 index 416a455c511cb..0000000000000 --- a/app/code/Magento/Paypal/view/frontend/web/js/opcheckout.js +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -/*jshint browser:true jquery:true*/ -define([ - "jquery", - "Magento_Checkout/js/opc-order-review", - "jquery/ui" -], function($, opcOrderReview){ - "use strict"; - - $.widget('mage.opcheckoutPaypalIframe', opcOrderReview, { - options: { - review: { - submitContainer: '#checkout-review-submit' - } - }, - - _create: function() { - var events = {}; - events['contentUpdated' + this.options.review.container] = function() { - var paypalIframe = this.element.find(this.options.review.container) - .find('[data-container="paypal-iframe"]'); - if (paypalIframe.length) { - paypalIframe.show(); - $(this.options.review.submitContainer).hide(); - } - }; - this._on(events); - } - }); - - return $.mage.opcheckoutPaypalIframe; -}); \ No newline at end of file diff --git a/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/magento.txt b/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/magento.txt index 70168b63a4efb..6b2b0611cbb08 100644 --- a/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/magento.txt +++ b/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/magento.txt @@ -105,16 +105,7 @@ app/code/Magento/Checkout/view/frontend/web/js/model/sidebar.js app/code/Magento/Checkout/view/frontend/web/js/model/step-navigator.js app/code/Magento/Checkout/view/frontend/web/js/model/totals.js app/code/Magento/Checkout/view/frontend/web/js/model/url-builder.js -app/code/Magento/Checkout/view/frontend/web/js/opc-billing-info.js -app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js -app/code/Magento/Checkout/view/frontend/web/js/opc-order-review.js -app/code/Magento/Checkout/view/frontend/web/js/opc-payment-info.js -app/code/Magento/Checkout/view/frontend/web/js/opc-shipping-info.js -app/code/Magento/Checkout/view/frontend/web/js/opc-shipping-method.js -app/code/Magento/Checkout/view/frontend/web/js/opcheckout.js -app/code/Magento/Checkout/view/frontend/web/js/payment-authentication.js -app/code/Magento/Checkout/view/frontend/web/js/payment.js -app/code/Magento/Checkout/view/frontend/web/js/proceed-to-checkout.js +app/code/Magento/Checkout/view/frontend/web/js/payment.js app/code/Magento/Checkout/view/frontend/web/js/proceed-to-checkout.js app/code/Magento/Checkout/view/frontend/web/js/region-updater.js app/code/Magento/Checkout/view/frontend/web/js/shopping-cart.js app/code/Magento/Checkout/view/frontend/web/js/sidebar.js @@ -688,15 +679,6 @@ vendor/magento/module-checkout/view/frontend/web/js/model/step-loader.js vendor/magento/module-checkout/view/frontend/web/js/model/step-navigator.js vendor/magento/module-checkout/view/frontend/web/js/model/totals.js vendor/magento/module-checkout/view/frontend/web/js/model/url-builder.js -vendor/magento/module-checkout/view/frontend/web/js/opc-billing-info.js -vendor/magento/module-checkout/view/frontend/web/js/opc-checkout-method.js -vendor/magento/module-checkout/view/frontend/web/js/opc-order-review.js -vendor/magento/module-checkout/view/frontend/web/js/opc-payment-info.js -vendor/magento/module-checkout/view/frontend/web/js/opc-shipping-info.js -vendor/magento/module-checkout/view/frontend/web/js/opc-shipping-method.js -vendor/magento/module-checkout/view/frontend/web/js/opcheckout.js -vendor/magento/module-checkout/view/frontend/web/js/payment-authentication.js -vendor/magento/module-checkout/view/frontend/web/js/payment.js vendor/magento/module-checkout/view/frontend/web/js/proceed-to-checkout.js vendor/magento/module-checkout/view/frontend/web/js/region-updater.js vendor/magento/module-checkout/view/frontend/web/js/shopping-cart.js diff --git a/dev/tests/static/testsuite/Magento/Test/Js/_files/jshint/blacklist/core.txt b/dev/tests/static/testsuite/Magento/Test/Js/_files/jshint/blacklist/core.txt index 9699f47c4bccc..2cb2aca38f906 100644 --- a/dev/tests/static/testsuite/Magento/Test/Js/_files/jshint/blacklist/core.txt +++ b/dev/tests/static/testsuite/Magento/Test/Js/_files/jshint/blacklist/core.txt @@ -4,7 +4,6 @@ module Magento_Catalog view/adminhtml/web/catalog/category/edit.js module Magento_Catalog view/adminhtml/web/catalog/product.js module Magento_Catalog view/adminhtml/web/catalog/product/composite/configure.js module Magento_Checkout view/frontend/web/js/opcheckout.js -module Magento_Checkout view/frontend/web/js/payment.js module Magento_Rule view/adminhtml/web/rules.js module Magento_Sales view/adminhtml/web/order/create/giftmessage.js module Magento_Sales view/adminhtml/web/order/create/scripts.js From 174c26a673343ffbf4e1f13245c5776b3acacece Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Tue, 20 Oct 2015 15:50:54 +0300 Subject: [PATCH 11/17] MAGETWO-43796: Eliminate @removeCandidate anotation --- .../view/frontend/web/js/proceed-to-checkout.js | 10 +++++++--- .../Magento/Test/Js/_files/blacklist/magento.txt | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/proceed-to-checkout.js b/app/code/Magento/Checkout/view/frontend/web/js/proceed-to-checkout.js index 7a6b4e88be10c..7754719a506ff 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/proceed-to-checkout.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/proceed-to-checkout.js @@ -8,15 +8,19 @@ define([ 'Magento_Customer/js/model/authentication-popup', 'Magento_Customer/js/customer-data' ], - function($, authenticationPopup, customerData) { + function ($, authenticationPopup, customerData) { + 'use strict'; + return function (config, element) { - $(element).click(function(event) { - event.preventDefault(); + $(element).click(function (event) { var cart = customerData.get('cart'), customer = customerData.get('customer'); + event.preventDefault(); + if (!customer().firstname && !cart().isGuestCheckoutAllowed) { authenticationPopup.showModal(); + return false; } location.href = config.checkoutUrl; diff --git a/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/magento.txt b/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/magento.txt index 6b2b0611cbb08..7497804d68237 100644 --- a/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/magento.txt +++ b/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/magento.txt @@ -105,7 +105,7 @@ app/code/Magento/Checkout/view/frontend/web/js/model/sidebar.js app/code/Magento/Checkout/view/frontend/web/js/model/step-navigator.js app/code/Magento/Checkout/view/frontend/web/js/model/totals.js app/code/Magento/Checkout/view/frontend/web/js/model/url-builder.js -app/code/Magento/Checkout/view/frontend/web/js/payment.js app/code/Magento/Checkout/view/frontend/web/js/proceed-to-checkout.js +app/code/Magento/Checkout/view/frontend/web/js/proceed-to-checkout.js app/code/Magento/Checkout/view/frontend/web/js/region-updater.js app/code/Magento/Checkout/view/frontend/web/js/shopping-cart.js app/code/Magento/Checkout/view/frontend/web/js/sidebar.js @@ -210,6 +210,7 @@ app/code/Magento/Msrp/view/frontend/requirejs-config.js app/code/Magento/Multishipping/view/frontend/requirejs-config.js app/code/Magento/Multishipping/view/frontend/web/js/multi-shipping.js app/code/Magento/Multishipping/view/frontend/web/js/overview.js +app/code/Magento/Multishipping/view/frontend/web/js/payment.js app/code/Magento/OfflinePayments/view/frontend/web/js/view/payment/method-renderer/banktransfer-method.js app/code/Magento/OfflinePayments/view/frontend/web/js/view/payment/method-renderer/cashondelivery-method.js app/code/Magento/OfflinePayments/view/frontend/web/js/view/payment/method-renderer/checkmo-method.js From 0c5934e777f78d5c3a5d1ac6364166bfff4a825e Mon Sep 17 00:00:00 2001 From: Alex Akimov Date: Tue, 20 Oct 2015 15:53:03 +0300 Subject: [PATCH 12/17] MAGETWO-44329: Unable to Update Billing Address in Checkout when tax Calculation is Based on Billing Address --- .../view/frontend/web/js/action/set-billing-address.js | 1 + .../Checkout/view/frontend/web/js/view/billing-address.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/action/set-billing-address.js b/app/code/Magento/Checkout/view/frontend/web/js/action/set-billing-address.js index 2090bdabfe69b..0c0060f737d53 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/action/set-billing-address.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/action/set-billing-address.js @@ -59,6 +59,7 @@ define( if (!quote.isVirtual()) { getTotalsAction([]); + fullScreenLoader.stopLoader(); } else { deferred = $.Deferred(); getPaymentInformationAction(deferred); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js b/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js index 80d9a5982a6ab..e103b35aef531 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js @@ -115,6 +115,9 @@ define( useShippingAddress: function () { if (this.isAddressSameAsShipping()) { selectBillingAddress(quote.shippingAddress()); + if (window.checkoutConfig.reloadOnBillingAddress) { + setBillingAddressAction(globalMessageList); + } this.isAddressDetailsVisible(true); } else { lastSelectedBillingAddress = quote.billingAddress(); From a58cb7e16c96440a66a0d9d61483de43f2fc187c Mon Sep 17 00:00:00 2001 From: Serhiy Shkolyarenko Date: Tue, 20 Oct 2015 17:26:03 +0300 Subject: [PATCH 13/17] MAGETWO-44336: Unable to place order with virtual quote using customer without default shipping address --- .../view/frontend/web/js/view/billing-address.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js b/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js index e103b35aef531..fa4f63f963316 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js @@ -82,11 +82,14 @@ define( }); quote.billingAddress.subscribe(function (newAddress) { - this.isAddressSameAsShipping( - newAddress != null && - newAddress.getCacheKey() == quote.shippingAddress().getCacheKey() && - !quote.isVirtual() - ); + if (quote.isVirtual()) { + this.isAddressSameAsShipping(false); + } else { + this.isAddressSameAsShipping( + newAddress != null && + newAddress.getCacheKey() == quote.shippingAddress().getCacheKey() + ); + } if (newAddress != null && newAddress.saveInAddressBook !== undefined) { this.saveInAddressBook(newAddress.saveInAddressBook); From df6ab512062115f5be84fb00e221f85fd2370d9d Mon Sep 17 00:00:00 2001 From: Iryna Lagno Date: Wed, 21 Oct 2015 15:43:50 +0300 Subject: [PATCH 14/17] MAGETWO-44228: Unable to set gift options in the shopping cart --- .../GiftMessage/view/frontend/web/js/model/gift-options.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/GiftMessage/view/frontend/web/js/model/gift-options.js b/app/code/Magento/GiftMessage/view/frontend/web/js/model/gift-options.js index c8ee517f5508c..53b8d8fde3b48 100644 --- a/app/code/Magento/GiftMessage/view/frontend/web/js/model/gift-options.js +++ b/app/code/Magento/GiftMessage/view/frontend/web/js/model/gift-options.js @@ -23,11 +23,13 @@ define(['underscore', 'ko'], _.each(this.options(), function (data) { if (data.id === itemId) { option = data.value; + + return false; } }); return option; } - } + }; } ); From 746bff63c221c825b300502f3445907649e2b27a Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Wed, 21 Oct 2015 16:51:16 +0300 Subject: [PATCH 15/17] MAGETWO-44369: Billing Address isn't saved in address book if was entered during checkout --- .../Checkout/view/frontend/web/js/view/billing-address.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js b/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js index fa4f63f963316..e94541d018067 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js @@ -150,7 +150,7 @@ define( var addressData = this.source.get(this.dataScopePrefix), newBillingAddress = createBillingAddress(addressData); - if (this.isCustomerLoggedIn && !this.customerHasAddresses) { + if (customer.isLoggedIn() && !this.customerHasAddresses) { this.saveInAddressBook(true); } addressData.save_in_address_book = this.saveInAddressBook(); From 7a20e8bd80ded118b5ec24cbe50e79a14d42823d Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Wed, 21 Oct 2015 17:26:16 +0300 Subject: [PATCH 16/17] MAGETWO-44385: Zip code format validation/hint isn't working per Country --- .../web/js/model/shipping-rates-validator.js | 83 +++++++++++++------ 1 file changed, 57 insertions(+), 26 deletions(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rates-validator.js b/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rates-validator.js index c510194a20873..732f328ff7274 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rates-validator.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rates-validator.js @@ -15,31 +15,46 @@ define( ], function ($, ko, shippingRatesValidationRules, addressConverter, selectShippingAddress, postcodeValidator, $t) { 'use strict'; - var checkoutConfig = window.checkoutConfig; - var validators = []; - var observedElements = []; - var postcodeElement = null; + + var checkoutConfig = window.checkoutConfig, + validators = [], + observedElements = [], + postcodeElement = null; return { validateAddressTimeout: 0, validateDelay: 2000, - registerValidator: function(carrier, validator) { + /** + * @param {String} carrier + * @param {Object} validator + */ + registerValidator: function (carrier, validator) { if (checkoutConfig.activeCarriers.indexOf(carrier) != -1) { validators.push(validator); } }, - validateAddressData: function(address) { + /** + * @param {Object} address + * @return {Boolean} + */ + validateAddressData: function (address) { return validators.some(function(validator) { return validator.validate(address); }); }, - bindChangeHandlers: function(elements, force, delay) { - var self = this; - var observableFields = shippingRatesValidationRules.getObservableFields(); - $.each(elements, function(index, elem) { + /** + * @param {*} elements + * @param {Boolean} force + * @param {Number} delay + */ + bindChangeHandlers: function (elements, force, delay) { + var self = this, + observableFields = shippingRatesValidationRules.getObservableFields(); + + $.each(elements, function (index, elem) { if (elem && (observableFields.indexOf(elem.index) != -1 || force)) { if (elem.index !== 'postcode') { self.bindHandler(elem, delay); @@ -53,17 +68,23 @@ define( }); }, - bindHandler: function(element, delay) { + /** + * @param {Object} element + * @param {Number} delay + */ + bindHandler: function (element, delay) { var self = this; + delay = typeof delay === "undefined" ? self.validateDelay : delay; + if (element.component.indexOf('/group') != -1) { - $.each(element.elems(), function(index, elem) { + $.each(element.elems(), function (index, elem) { self.bindHandler(elem); }); } else { - element.on('value', function() { + element.on('value', function () { clearTimeout(self.validateAddressTimeout); - self.validateAddressTimeout = setTimeout(function() { + self.validateAddressTimeout = setTimeout(function () { if (self.postcodeValidation()) { self.validateFields(); } @@ -73,36 +94,44 @@ define( } }, - postcodeValidation: function() { + /** + * @return {*} + */ + postcodeValidation: function () { + var countryId = $('select[name="country_id"]').val(), + validationResult = postcodeValidator.validate(postcodeElement.value(), countryId), + warnMessage; + if (postcodeElement == null || postcodeElement.value() == null) { return true; } - var countryId = $('select[name="shippingAddress[country_id]"]').val(); - var validationResult = postcodeValidator.validate(postcodeElement.value(), countryId); - postcodeElement.warn(null); + if (!validationResult) { - var warnMessage = $t('Provided Zip/Postal Code seems to be invalid.'); + warnMessage = $t('Provided Zip/Postal Code seems to be invalid.'); if (postcodeValidator.validatedPostCodeExample.length) { warnMessage += $t(' Example: ') + postcodeValidator.validatedPostCodeExample.join('; ') + '. '; } warnMessage += $t('If you believe it is the right one you can ignore this notice.'); postcodeElement.warn(warnMessage); } + return validationResult; }, /** * Convert form data to quote address and validate fields for shipping rates */ - validateFields: function() { + validateFields: function () { var addressFlat = addressConverter.formDataProviderToFlatData( - this.collectObservedData(), - 'shippingAddress' - ); + this.collectObservedData(), + 'shippingAddress' + ), + address; + if (this.validateAddressData(addressFlat)) { - var address = addressConverter.formAddressDataToQuoteAddress(addressFlat); + address = addressConverter.formAddressDataToQuoteAddress(addressFlat); selectShippingAddress(address); } }, @@ -112,11 +141,13 @@ define( * * @returns {*} */ - collectObservedData: function() { + collectObservedData: function () { var observedValues = {}; - $.each(observedElements, function(index, field) { + + $.each(observedElements, function (index, field) { observedValues[field.dataScope] = field.value(); }); + return observedValues; } }; From 4dd6188a1bdde983ec546c146af155ee7088b1b4 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Thu, 22 Oct 2015 11:53:33 +0300 Subject: [PATCH 17/17] MAGETWO-44369: Billing Address isn't saved in address book if was entered during checkout --- .../Checkout/view/frontend/web/js/view/billing-address.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js b/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js index e94541d018067..b69365ebc0f17 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js @@ -148,12 +148,13 @@ define( if (!this.source.get('params.invalid')) { var addressData = this.source.get(this.dataScopePrefix), - newBillingAddress = createBillingAddress(addressData); + newBillingAddress; if (customer.isLoggedIn() && !this.customerHasAddresses) { this.saveInAddressBook(true); } addressData.save_in_address_book = this.saveInAddressBook(); + newBillingAddress = createBillingAddress(addressData); // New address must be selected as a billing address selectBillingAddress(newBillingAddress);