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 1c7b14abfa13d308f65ec8ff17aa6042c42a1497..126f80a2e25e82ba2d4c82638fb13d035844481d 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 @@ <block class="Magento\Framework\View\Element\Text\ListText" name="paypal.additional.actions"/> <block class="Magento\Paypal\Block\Express\Review\Details" name="paypal.express.review.details" as="details" template="express/review/details.phtml"> <block class="Magento\Framework\View\Element\RendererList" name="checkout.onepage.review.item.renderers" as="renderer.list"/> - <block class="Magento\Checkout\Block\Cart\Totals" name="paypal.express.review.details.totals" as="totals" template="onepage/review/totals.phtml"/> + <block class="Magento\Checkout\Block\Cart\Totals" name="paypal.express.review.details.totals" as="totals" template="checkout/onepage/review/totals.phtml"/> </block> <block class="Magento\CheckoutAgreements\Block\Agreements" name="paypal.express.review.details.agreements" as="agreements" template="Magento_CheckoutAgreements::additional_agreements.phtml"/> </block> diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/Preprocessor.php b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/Preprocessor.php index 98aa6bb7e710ab1492fff90a66ae24dd7f5391ea..e692ea59d2d6ef1b97ea0b81a6458c8773907cf4 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/Preprocessor.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/Preprocessor.php @@ -6,6 +6,7 @@ namespace Magento\CatalogSearch\Model\Adapter\Mysql\Filter; use Magento\Catalog\Model\Product; +use Magento\Catalog\Model\ResourceModel\Eav\Attribute; use Magento\CatalogSearch\Model\Search\TableMapper; use Magento\Eav\Model\Config; use Magento\Framework\App\ResourceConnection; @@ -97,7 +98,7 @@ class Preprocessor implements PreprocessorInterface */ private function processQueryWithField(FilterInterface $filter, $isNegation, $query) { - /** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */ + /** @var Attribute $attribute */ $attribute = $this->config->getAttribute(Product::ENTITY, $filter->getField()); if ($filter->getField() === 'price') { $resultQuery = str_replace( @@ -114,24 +115,16 @@ class Preprocessor implements PreprocessorInterface $this->connection->quoteIdentifier($alias . '.' . $attribute->getAttributeCode()), $query ); - } elseif ($filter->getType() === FilterInterface::TYPE_TERM - && in_array($attribute->getFrontendInput(), ['select', 'multiselect'], true) + } elseif ( + $filter->getType() === FilterInterface::TYPE_TERM && + in_array($attribute->getFrontendInput(), ['select', 'multiselect'], true) ) { - $alias = $this->tableMapper->getMappingAlias($filter); - if (is_array($filter->getValue())) { - $value = sprintf( - '%s IN (%s)', - ($isNegation ? 'NOT' : ''), - implode(',', $filter->getValue()) - ); - } else { - $value = ($isNegation ? '!' : '') . '= ' . $filter->getValue(); - } - $resultQuery = sprintf( - '%1$s.value %2$s', - $alias, - $value - ); + $resultQuery = $this->processTermSelect($filter, $isNegation); + } elseif ( + $filter->getType() === FilterInterface::TYPE_RANGE && + in_array($attribute->getBackendType(), ['decimal', 'int'], true) + ) { + $resultQuery = $this->processRangeNumeric($filter, $query, $attribute); } else { $table = $attribute->getBackendTable(); $select = $this->connection->select(); @@ -161,4 +154,57 @@ class Preprocessor implements PreprocessorInterface return $resultQuery; } + + /** + * @param FilterInterface $filter + * @param string $query + * @param Attribute $attribute + * @return string + */ + private function processRangeNumeric(FilterInterface $filter, $query, $attribute) + { + $tableSuffix = $attribute->getBackendType() === 'decimal' ? '_decimal' : ''; + $table = $this->resource->getTableName("catalog_product_index_eav{$tableSuffix}"); + $select = $this->connection->select(); + + $currentStoreId = $this->scopeResolver->getScope()->getId(); + + $select->from(['main_table' => $table], 'entity_id') + ->columns([$filter->getField() => 'main_table.value']) + ->where('main_table.attribute_id = ?', $attribute->getAttributeId()) + ->where('main_table.store_id = ?', $currentStoreId) + ->having($query); + + $resultQuery = 'search_index.entity_id IN ( + select entity_id from ' . $this->conditionManager->wrapBrackets($select) . ' as filter + )'; + + return $resultQuery; + } + + /** + * @param FilterInterface $filter + * @param bool $isNegation + * @return string + */ + private function processTermSelect(FilterInterface $filter, $isNegation) + { + $alias = $this->tableMapper->getMappingAlias($filter); + if (is_array($filter->getValue())) { + $value = sprintf( + '%s IN (%s)', + ($isNegation ? 'NOT' : ''), + implode(',', $filter->getValue()) + ); + } else { + $value = ($isNegation ? '!' : '') . '= ' . $filter->getValue(); + } + $resultQuery = sprintf( + '%1$s.value %2$s', + $alias, + $value + ); + + return $resultQuery; + } } diff --git a/app/code/Magento/Checkout/Block/Onepage.php b/app/code/Magento/Checkout/Block/Onepage.php index d298599319540e5cbdf5143567e4e04fda46246b..25cbb6081959d727fd6415fec3896657846faf93 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 6b4e92640ec7090878068aed4f6f6be55afee980..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Block/Onepage/AbstractOnepage.php +++ /dev/null @@ -1,391 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Block\Onepage; - -use Magento\Customer\Api\CustomerRepositoryInterface; -use Magento\Customer\Model\Address\Config as AddressConfig; -use Magento\Directory\Model\ResourceModel\Country\Collection; -use Magento\Directory\Model\ResourceModel\Region\Collection as RegionCollection; -use Magento\Framework\Exception\NoSuchEntityException; -use Magento\Quote\Model\Quote; - -/** - * One page common functionality block - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ -abstract class AbstractOnepage extends \Magento\Framework\View\Element\Template -{ - /** - * @var \Magento\Framework\App\Cache\Type\Config - */ - protected $_configCacheType; - - /** - * @var \Magento\Customer\Api\Data\CustomerInterface - */ - protected $_customer; - - /** - * @var Quote - */ - protected $_quote; - - /** - * @var Collection - */ - protected $_countryCollection; - - /** - * @var RegionCollection - */ - protected $_regionCollection; - - /** - * @var mixed - */ - protected $_addressesCollection; - - /** - * @var \Magento\Checkout\Model\Session - */ - protected $_checkoutSession; - - /** - * @var \Magento\Directory\Model\ResourceModel\Region\CollectionFactory - */ - protected $_regionCollectionFactory; - - /** - * @var \Magento\Directory\Model\ResourceModel\Country\CollectionFactory - */ - protected $_countryCollectionFactory; - - /** - * @var \Magento\Directory\Helper\Data - */ - protected $directoryHelper; - - /** - * @var CustomerRepositoryInterface - */ - protected $customerRepository; - - /** - * @var \Magento\Customer\Model\Address\Config - */ - private $_addressConfig; - - /** - * @var \Magento\Framework\App\Http\Context - */ - protected $httpContext; - - /** - * @var \Magento\Customer\Model\Address\Mapper - */ - protected $addressMapper; - - /** - * @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 array $data - * @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, - array $data = [] - ) { - $this->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 1aee1948f0f3518fd9480e9e2992db5fca543824..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Block/Onepage/Billing.php +++ /dev/null @@ -1,235 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Block\Onepage; - -use Magento\Customer\Api\CustomerRepositoryInterface; -use Magento\Customer\Model\Address\Config as AddressConfig; - -/** - * One page checkout status - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - * @removeCandidate - */ -class Billing extends \Magento\Checkout\Block\Onepage\AbstractOnepage -{ - /** - * 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; - - /** - * @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\Quote\Model\Quote\AddressFactory $addressFactory - * @param array $data - * @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\Quote\Model\Quote\AddressFactory $addressFactory, - array $data = [] - ) { - $this->_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 4298784226ae932e3c74dea26f35d79cf082b1eb..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Block/Onepage/Payment.php +++ /dev/null @@ -1,69 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Block\Onepage; - -/** - * One page checkout status - * - * @author Magento Core Team <core@magentocommerce.com> - * @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 67f682a25c19d95c37798e534a75376a8f7c2b49..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Block/Onepage/Payment/Info.php +++ /dev/null @@ -1,63 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Block\Onepage\Payment; - -/** - * Checkout payment information data - * - * @author Magento Core Team <core@magentocommerce.com> - * @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 48285ad73dc277fa9890d46e7fa758246d5865e0..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Block/Onepage/Payment/Methods.php +++ /dev/null @@ -1,113 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -/** - * One page checkout status - * - * @author Magento Core Team <core@magentocommerce.com> - * @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 39cba9ffce7470f1f0508fc8503fed741cf84341..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Block/Onepage/Review/Button.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Block\Onepage\Review; - -use Magento\Framework\View\Element\Template; - -/** - * One page checkout order review button - * @removeCandidate - */ -class Button extends Template -{ - /** - * {@inheritdoc} - * - * @param string $template - * @return $this - */ - public function setTemplate($template) - { - if (!empty($template)) { - parent::setTemplate($template); - } - return $this; - } -} diff --git a/app/code/Magento/Checkout/Block/Onepage/Review/Info.php b/app/code/Magento/Checkout/Block/Onepage/Review/Info.php deleted file mode 100644 index 9adbc1c4e5ed140507e0c613ae8bd66c13ea7b6b..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Block/Onepage/Review/Info.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Block\Onepage\Review; - -/** - * One page checkout order review - * @removeCandidate - */ -class Info extends \Magento\Sales\Block\Items\AbstractItems -{ - /** - * @var \Magento\Checkout\Model\Session - */ - protected $_checkoutSession; - - /** - * @param \Magento\Framework\View\Element\Template\Context $context - * @param \Magento\Checkout\Model\Session $checkoutSession - * @param array $data - */ - public function __construct( - \Magento\Framework\View\Element\Template\Context $context, - \Magento\Checkout\Model\Session $checkoutSession, - array $data = [] - ) { - $this->_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 d8dcad11e01c0e50a726c2f85e2f1a10165ac12c..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Block/Onepage/Shipping.php +++ /dev/null @@ -1,131 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Block\Onepage; - -use Magento\Customer\Api\CustomerRepositoryInterface; -use Magento\Customer\Model\Address\Config as AddressConfig; - -/** - * One page checkout status - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - * @removeCandidate - */ -class Shipping extends \Magento\Checkout\Block\Onepage\AbstractOnepage -{ - /** - * Sales Quote Shipping Address instance - * - * @var \Magento\Quote\Model\Quote\Address - */ - protected $_address = null; - - /** - * @var \Magento\Quote\Model\Quote\AddressFactory - */ - protected $_addressFactory; - - /** - * @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\Quote\Model\Quote\AddressFactory $addressFactory - * @param array $data - * @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\Quote\Model\Quote\AddressFactory $addressFactory, - array $data = [] - ) { - $this->_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 5145d6fdca269a7613618b6b12f0dd979220e0e9..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Block/Onepage/Shipping/Method.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Block\Onepage\Shipping; - -/** - * One page checkout status - * - * @author Magento Core Team <core@magentocommerce.com> - * @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 bf27a8fa212086889f4b88616f84edb14f6307df..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Block/Onepage/Shipping/Method/Additional.php +++ /dev/null @@ -1,16 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Block\Onepage\Shipping\Method; - -/** - * Block for additional information in shipping method - * - * @author Magento Core Team <core@magentocommerce.com> - * @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 582beafbbb5f4710f9be6558cc1644cad16e8376..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/Block/Onepage/Shipping/Method/Available.php +++ /dev/null @@ -1,122 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Checkout\Block\Onepage\Shipping\Method; - -use Magento\Customer\Api\CustomerRepositoryInterface; -use Magento\Customer\Model\Address\Config as AddressConfig; -use Magento\Quote\Model\Quote\Address; - -/** - * One page checkout status - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - * @removeCandidate - */ -class Available extends \Magento\Checkout\Block\Onepage\AbstractOnepage -{ - /** - * @var array - */ - protected $_rates; - - /** - * @var Address - */ - protected $_address; - - /** - * @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 array $data - * @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, - array $data = [] - ) { - parent::__construct( - $context, - $directoryHelper, - $configCacheType, - $customerSession, - $resourceSession, - $countryCollectionFactory, - $regionCollectionFactory, - $customerRepository, - $addressConfig, - $httpContext, - $addressMapper, - $data - ); - $this->_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/Controller/Onepage/SaveOrder.php b/app/code/Magento/Checkout/Controller/Onepage/SaveOrder.php index 82e9d18b8854e5e2f0e51b131a2f4a84a496bb69..6c66fd165de554889cdbbd39b4b1f40608bb9983 100644 --- a/app/code/Magento/Checkout/Controller/Onepage/SaveOrder.php +++ b/app/code/Magento/Checkout/Controller/Onepage/SaveOrder.php @@ -8,9 +8,6 @@ namespace Magento\Checkout\Controller\Onepage; use Magento\Framework\DataObject; use Magento\Framework\Exception\PaymentException; -/** - * @removeCandidate - */ class SaveOrder extends \Magento\Checkout\Controller\Onepage { /** diff --git a/app/code/Magento/Checkout/Test/Unit/Block/OnepageTest.php b/app/code/Magento/Checkout/Test/Unit/Block/OnepageTest.php index e3ef9b58e827f6031b03c6678e8aeea99f0dd536..d29475962ef4dfe3b80b3b98f01f8ccb5983cd0e 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 @@ class OnepageTest extends \PHPUnit_Framework_TestCase '', 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 @@ class OnepageTest extends \PHPUnit_Framework_TestCase $this->model = new \Magento\Checkout\Block\Onepage( $contextMock, - $directoryHelperMock, - $configCacheTypeMock, - $customerSessionMock, - $resourceSessionMock, - $countryCollectionFactoryMock, - $regionCollectionFactoryMock, - $customerRepositoryMock, - $addressConfigMock, - $httpContextMock, - $addressMapperMock, $this->formKeyMock, $this->configProviderMock, [$this->layoutProcessorMock] diff --git a/app/code/Magento/Checkout/composer.json b/app/code/Magento/Checkout/composer.json index 775fe8406e930313ad64a49daf716d7792b60335..ca4d5b91da09dd595225d73f954bfefe0c0cfcac 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/Checkout/view/frontend/requirejs-config.js b/app/code/Magento/Checkout/view/frontend/requirejs-config.js index e8a99235212544b2c3c7c219865cda4b7d3eab9c..a7055ed7d1558505ac1bf32b6c377d7b13f879f7 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/billing.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/billing.phtml deleted file mode 100644 index 49369053b5be56cb3ea02dee5726ba776aa1c40d..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/billing.phtml +++ /dev/null @@ -1,214 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -/** @var \Magento\Checkout\Block\Onepage\Billing $block */ -/** - * @removeCandidate - */ -?> -<form class="form billing" id="co-billing-form" data-hasrequired="<?php /* @escapeNotVerified */ echo __('* Required Fields') ?>"> - - <?php if ($block->customerHasAddresses()): ?> - <div class="field addresses"> - <label class="label" for="billing:address-select"><span><?php /* @escapeNotVerified */ echo __('Select a billing address from your address book or enter a new address.') ?></span></label> - <div class="control"> - <?php echo $block->getAddressesHtmlSelect('billing') ?> - </div> - </div> - <?php endif; ?> - <fieldset class="fieldset address" id="billing-new-address-form"<?php if ($block->customerHasAddresses()): ?> style="display:none;"<?php endif; ?>> - <input type="hidden" name="billing[address_id]" value="<?php /* @escapeNotVerified */ echo $block->getAddress()->getId() ?>" id="billing:address_id" /> - - <?php echo $block->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() ?> - - <?php if (!$block->isCustomerLoggedIn()): ?> - <div class="field required email"> - <label class="label" for="billing:email"><span><?php /* @escapeNotVerified */ echo __('Email') ?></span></label> - <div class="control"> - <input type="email" name="billing[email]" id="billing:email" value="<?php echo $block->escapeHtml($block->getAddress()->getEmail()) ?>" title="<?php /* @escapeNotVerified */ echo __('Email') ?>" class="input-text" data-validate="{required:true, 'validate-email':true}"/> - </div> - </div> - <?php endif; ?> - - <div class="field company"> - <label class="label" for="billing:company"><span><?php /* @escapeNotVerified */ echo __('Company') ?></span></label> - <div class="control"> - <input type="text" id="billing:company" name="billing[company]" value="<?php echo $block->escapeHtml($block->getAddress()->getCompany()) ?>" title="<?php /* @escapeNotVerified */ echo __('Company') ?>" class="input-text <?php /* @escapeNotVerified */ echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('company') ?>" /> - </div> - </div> - - <?php if ($this->helper('Magento\Customer\Helper\Address')->isVatAttributeVisible()) : ?> - <div class="field taxvat"> - <label class="label" for="billing:vat_id"><span><?php /* @escapeNotVerified */ echo __('VAT Number') ?></span></label> - <div class="control"> - <input type="text" id="billing:vat_id" name="billing[vat_id]" value="<?php echo $block->escapeHtml($block->getAddress()->getVatId()) ?>" title="<?php /* @escapeNotVerified */ echo __('VAT Number') ?>" class="input-text <?php /* @escapeNotVerified */ echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('vat_id') ?>" /> - </div> - </div> - <?php endif; ?> - - <?php $_streetValidationClass = $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('street'); ?> - <div class="field street required"> - <label class="label" for="billing:street1"><span><?php /* @escapeNotVerified */ echo __('Address') ?></span></label> - <div class="control"> - <input type="text" title="<?php /* @escapeNotVerified */ echo __('Street Address') ?>" name="billing[street][]" id="billing:street1" value="<?php echo $block->escapeHtml($block->getAddress()->getStreetLine(1)) ?>" class="input-text <?php /* @escapeNotVerified */ echo $_streetValidationClass ?>" /> - <div class="nested"> - <?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?> - <?php for ($_i = 2, $_n = $this->helper('Magento\Customer\Helper\Address')->getStreetLines(); $_i <= $_n; $_i++): ?> - <div class="field additional"> - <label class="label" for="billing:street<?php /* @escapeNotVerified */ echo $_i ?>"> - <span><?php /* @escapeNotVerified */ echo __('Address') ?></span> - </label> - <div class="control"> - <input type="text" title="<?php /* @escapeNotVerified */ echo __('Street Address %1', $_i) ?>" name="billing[street][]" id="billing:street<?php /* @escapeNotVerified */ echo $_i ?>" value="<?php echo $block->escapeHtml($block->getAddress()->getStreetLine($_i)) ?>" class="input-text <?php /* @escapeNotVerified */ echo $_streetValidationClass ?>" /> - </div> - </div> - <?php endfor; ?> - </div> - </div> - </div> - - - <div class="field city required"> - <label class="label" for="billing:city"><span><?php /* @escapeNotVerified */ echo __('City') ?></span></label> - <div class="control"> - <input type="text" title="<?php /* @escapeNotVerified */ echo __('City') ?>" name="billing[city]" value="<?php echo $block->escapeHtml($block->getAddress()->getCity()) ?>" class="input-text <?php /* @escapeNotVerified */ echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('city') ?>" id="billing:city" /> - </div> - </div> - - <div class="field region required"> - <label class="label" for="billing:region_id"><span><?php /* @escapeNotVerified */ echo __('State/Province') ?></span></label> - <div class="control"> - <select id="billing:region_id" - name="billing[region_id]" - title="<?php /* @escapeNotVerified */ echo __('State/Province') ?>" - data-validate="{'validate-select':true}" - <?php if ($block->getConfig('general/region/display_all') === 0):?>disabled="disabled"<?php endif; ?> - style="display:none;"> - <option value=""><?php /* @escapeNotVerified */ echo __('Please select a region, state or province.') ?></option> - </select> - <input type="text" - id="billing:region" - name="billing[region]" - value="<?php echo $block->escapeHtml($block->getAddress()->getRegion()) ?>" - title="<?php /* @escapeNotVerified */ echo __('State/Province') ?>" - class="input-text <?php /* @escapeNotVerified */ echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('region') ?>" - <?php if ($block->getConfig('general/region/display_all') === 0):?>disabled="disabled"<?php endif; ?> - style="display:none;" /> - </div> - </div> - - <div class="field zip required"> - <label class="label" for="billing:postcode"><span><?php /* @escapeNotVerified */ echo __('Zip/Postal Code') ?></span></label> - <div class="control"> - <input type="text" title="<?php /* @escapeNotVerified */ echo __('Zip/Postal Code') ?>" name="billing[postcode]" id="billing:postcode" value="<?php echo $block->escapeHtml($block->getAddress()->getPostcode()) ?>" class="input-text <?php /* @escapeNotVerified */ echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('postcode') ?>" data-validate="{'required':true, 'validate-zip-international':true}"/> - </div> - </div> - - <div class="field country required"> - <label class="label" for="billing:country_id"><span><?php /* @escapeNotVerified */ echo __('Country') ?></span></label> - <div class="control"> - <?php echo $block->getCountryHtmlSelect('billing') ?> - </div> - </div> - - <div class="field telephone required"> - <label class="label" for="billing:telephone"><span><?php /* @escapeNotVerified */ echo __('Phone Number') ?></span></label> - <div class="control"> - <input type="text" name="billing[telephone]" value="<?php echo $block->escapeHtml($block->getAddress()->getTelephone()) ?>" title="<?php /* @escapeNotVerified */ echo __('Telephone') ?>" class="input-text <?php /* @escapeNotVerified */ echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('telephone') ?>" id="billing:telephone" /> - </div> - </div> - - <div class="field fax"> - <label class="label" for="billing:fax"><span><?php /* @escapeNotVerified */ echo __('Fax') ?></span></label> - <div class="control"> - <input type="text" name="billing[fax]" value="<?php echo $block->escapeHtml($block->getAddress()->getFax()) ?>" title="<?php /* @escapeNotVerified */ echo __('Fax') ?>" class="input-text <?php /* @escapeNotVerified */ echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('fax') ?>" id="billing:fax" /> - </div> - </div> - - <?php if (!$block->isCustomerLoggedIn()): ?> - <?php $_dob = $block->getLayout()->createBlock('Magento\Customer\Block\Widget\Dob') ?> - <?php $_taxvat = $block->getLayout()->createBlock('Magento\Customer\Block\Widget\Taxvat') ?> - <?php $_gender = $block->getLayout()->createBlock('Magento\Customer\Block\Widget\Gender') ?> - - <?php if ($_dob->isEnabled()): ?> - <?php echo $_dob->setDate($block->getQuote()->getCustomerDob())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?> - <?php endif; ?> - <?php if ($_taxvat->isEnabled()): ?> - <?php echo $_taxvat->setTaxvat($block->getQuote()->getCustomerTaxvat())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?> - <?php endif ?> - <?php if ($_gender->isEnabled()): ?> - <?php echo $_gender->setGender($block->getQuote()->getCustomerGender())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?> - <?php endif ?> - <?php $customerAttributes = $block->getChildBlock('customer_form_customer_user_defined_attributes');?> - <?php if ($customerAttributes): ?> - <?php $customerAttributes->setEntityModelClass('Magento\Customer\Model\Customer')->setFieldIdFormat('billing:%1$s');?> - <?php $customerAttributes->setFieldNameFormat('billing[%1$s]')->setShowContainer(false);?> - <?php echo $customerAttributes->toHtml()?> - <?php endif;?> - <div class="field password required"> - <label class="label" for="billing:customer_password"><span><?php /* @escapeNotVerified */ echo __('Password') ?></span></label> - <div class="control"> - <input type="password" name="billing[customer_password]" id="billing:customer_password" title="<?php /* @escapeNotVerified */ echo __('Password') ?>" class="input-text" data-validate="{required:true, 'validate-password':true}"/> - </div> - </div> - <div class="field confirm required"> - <label class="label" for="billing:confirm_password"><span><?php /* @escapeNotVerified */ echo __('Confirm Password') ?></span></label> - <div class="control"> - <input type="password" name="billing[confirm_password]" title="<?php /* @escapeNotVerified */ echo __('Confirm Password') ?>" id="billing:confirm_password" class="input-text" data-validate="{required:true, 'validate-cpassword':true, equalTo: '#billing\\:customer_password'}"/> - </div> - </div> - <?php endif; ?> - <?php echo $block->getChildHtml('form_additional_info'); ?> - <?php if ($block->isCustomerLoggedIn() && $block->customerHasAddresses()):?> - <div class="field save choice"> - <input type="checkbox" name="billing[save_in_address_book]" value="1" title="<?php /* @escapeNotVerified */ echo __('Save in address book') ?>" id="billing:save_in_address_book" <?php if ($block->getAddress()->getSaveInAddressBook()):?> checked="checked"<?php endif;?> class="checkbox" /> - <label class="label" for="billing:save_in_address_book"><span><?php /* @escapeNotVerified */ echo __('Save in address book') ?></span></label> - </div> - <?php else:?> - <input type="hidden" name="billing[save_in_address_book]" value="1" /> - <?php endif; ?> - <?php /* Extensions placeholder */ ?> - <?php echo $block->getChildHtml('checkout.onepage.billing.extra')?> -</fieldset> -<?php if ($block->canShip()): ?> - <div class="field choice"> - <input type="radio" name="billing[use_for_shipping]" id="billing:use_for_shipping_yes" value="1"<?php if ($block->isUseBillingAddressForShipping()) { - ?> checked="checked"<?php -}?> class="radio" /> - <label class="label" for="billing:use_for_shipping_yes"><span><?php /* @escapeNotVerified */ echo __('Ship to this address') ?></span></label> - </div> - <div class="field choice"> - <input type="radio" name="billing[use_for_shipping]" id="billing:use_for_shipping_no" value="0"<?php if (!$block->isUseBillingAddressForShipping()) { - ?> checked="checked"<?php -}?> class="radio" /> - <label class="label" for="billing:use_for_shipping_no"><span><?php /* @escapeNotVerified */ echo __('Ship to different address') ?></span></label> - </div> -<?php endif; ?> - -<?php if (!$block->canShip()): ?> - <input type="hidden" name="billing[use_for_shipping]" value="1" /> -<?php endif; ?> -<div class="actions" id="billing-buttons-container"> - <div class="primary"><button data-role="opc-continue" type="button" class="button action continue primary"><span><?php /* @escapeNotVerified */ echo __('Continue') ?></span></button></div> -</div> -</form> -<script type="text/x-magento-init"> - { - "#billing\\:country_id": { - "regionUpdater": { - "optionalRegionAllowed": <?php /* @escapeNotVerified */ echo($block->getConfig('general/region/display_all') ? 'true' : 'false'); ?>, - "regionListId": "#billing\\:region_id", - "regionInputId": "#billing\\:region", - "postcodeId": "#billing\\:postcode", - "regionJson": <?php /* @escapeNotVerified */ echo $this->helper('Magento\Directory\Helper\Data')->getRegionJson() ?>, - "defaultRegion": "<?php /* @escapeNotVerified */ echo $block->getAddress()->getRegionId() ?>", - "countriesWithOptionalZip": <?php /* @escapeNotVerified */ echo $this->helper('Magento\Directory\Helper\Data')->getCountriesWithOptionalZip(true) ?> - } - } - } -</script> 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 f9ac39fd39dca380af9b9e422fb7e45656f50c20..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/payment.phtml +++ /dev/null @@ -1,31 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -/** - * @removeCandidate - */ -?> -<form id="co-payment-form" class="form payments"> - <?php echo $block->getBlockHtml('formkey') ?> - <fieldset class="fieldset"> - <legend class="legend payments-title"> - <span><?php /* @escapeNotVerified */ echo __('Payment Information') ?></span> - </legend><br> - <?php echo $block->getChildChildHtml('methods_additional') ?> - <div id="checkout-payment-method-load" class="opc-payment"></div> - </fieldset> - <?php echo $block->getChildChildHtml('additional') ?> - <div class="actions-toolbar" id="payment-buttons-container"> - <div class="primary"> - <button data-role="opc-continue" type="button" class="button action continue primary"><span><?php /* @escapeNotVerified */ echo __('Continue') ?></span></button> - </div> - <div class="secondary"> - <a class="action back" href="#"><span><?php /* @escapeNotVerified */ echo __('Back') ?></span></a> - </div> - </div> -</form> 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 f3c0f86cc46bb59bf8528a71db0e40a63635ec1a..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/payment/methods.phtml +++ /dev/null @@ -1,52 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -/** - * @removeCandidate - */ -?> -<?php -/** - * One page checkout payment methods - * - * @var $block \Magento\Checkout\Block\Onepage\Payment\Methods - */ -?> -<dl class="items methods-payment"> -<?php - $methods = $block->getMethods(); - $oneMethod = count($methods) <= 1; -?> -<?php if (empty($methods)): ?> - <dt class="item-title"> - <?php /* @escapeNotVerified */ echo __('No Payment Methods') ?> - </dt> -<?php else: - foreach ($methods as $_method): - $_code = $_method->getCode(); -?> - <dt class="item-title <?php /* @escapeNotVerified */ echo $_code ?>"> - <?php if (!$oneMethod): ?> - <input id="p_method_<?php /* @escapeNotVerified */ echo $_code ?>" value="<?php /* @escapeNotVerified */ echo $_code ?>" type="radio" name="payment[method]" title="<?php echo $block->escapeHtml($_method->getTitle()) ?>" <?php if ($block->getSelectedMethodCode() == $_code): ?> checked="checked"<?php endif; ?> class="radio" /> - <?php else: ?> - <input id="p_method_<?php /* @escapeNotVerified */ echo $_code ?>" value="<?php /* @escapeNotVerified */ echo $_code ?>" type="radio" name="payment[method]" checked="checked" class="radio no-display" /> - <?php $oneMethod = $_code; ?> - <?php endif; ?> - <label for="p_method_<?php /* @escapeNotVerified */ echo $_code ?>"><?php echo $block->escapeHtml($block->getMethodTitle($_method)) ?> <?php echo $block->getMethodLabelAfterHtml($_method) ?></label> - </dt> - <?php if ($html = $block->getPaymentMethodFormHtml($_method)): ?> - <dd class="item-content <?php /* @escapeNotVerified */ echo $_code ?>"> - <?php /* @escapeNotVerified */ echo $html; ?> - </dd> - <?php endif; ?> -<?php endforeach; - endif; -?> -</dl> -<div class="no-display" data-checkout-price="<?php echo (float)$block->getQuote()->getBaseGrandTotal(); ?>"></div> -<?php echo $block->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 1b26f9922c5faac3b3dc2e0e72d9a60644d0a925..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/button.phtml +++ /dev/null @@ -1,13 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile -/** - * @removeCandidate - */ -?> -<button data-role="review-save" type="submit" title="<?php /* @escapeNotVerified */ echo __('Place Order') ?>" - class="button action primary checkout"><span><?php /* @escapeNotVerified */ echo __('Place Order') ?></span></button> 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 8e390e653fd79cf1743b4b7c6d134310d2f02f21..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/info.phtml +++ /dev/null @@ -1,54 +0,0 @@ -\<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -/** @var $block \Magento\Checkout\Block\Onepage\Review\Info */ - -/** - * @removeCandidate - */ -?> -<?php echo $block->getChildHtml('items_before'); ?> -<div id="checkout-review-table-wrapper" class="order-review-wrapper table-wrapper"> - <?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): $colspan = $rowspan = 2; else: $colspan = $rowspan = 1; endif; ?> - <table class="data table table-order-review items" id="checkout-review-table"> - <caption class="table-caption"><?php /* @escapeNotVerified */ echo __('Order Review'); ?></caption> - <thead> - <tr> - <th class="col item" scope="col"><?php /* @escapeNotVerified */ echo __('Product Name') ?></th> - <th class="col price" scope="col"><?php /* @escapeNotVerified */ echo __('Price') ?></th> - <th class="col qty" scope="col"><?php /* @escapeNotVerified */ echo __('Qty') ?></th> - <th class="col subtotal" scope="col"><?php /* @escapeNotVerified */ echo __('Subtotal') ?></th> - </tr> - </thead> - <tbody> - <?php foreach ($block->getItems() as $_item): ?> - <?php echo $block->getItemHtml($_item)?> - <?php endforeach ?> - </tbody> - <tfoot> - <?php echo $block->getChildHtml('totals'); ?> - </tfoot> - </table> -</div> -<?php echo $block->getChildHtml('items_after'); ?> -<div id="checkout-review-submit" data-mage-init='{"paymentAuthentication":{}}' class="checkout-submit-order"> - <?php echo $block->getChildHtml('agreements') ?> - <div class="actions-toolbar" id="review-buttons-container"> - <div class="primary"><?php echo $block->getChildHtml('button') ?></div> - <div class="secondary"> - <span id="checkout-review-edit-label"> - <?php /* @escapeNotVerified */ echo __('Forgot an Item?') ?> - </span> - <a href="<?php /* @escapeNotVerified */ echo $block->getUrl('checkout/cart') ?>" - aria-describedby="checkout-review-edit-label" - class="action edit"> - <span><?php /* @escapeNotVerified */ echo __('Edit Your Cart') ?></span> - </a> - </div> - </div> -</div> 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 7d107a0589d53580c0e9b9512b3c936b063b49be..54748a318b6adedd0bf8d354eebaeaf8bdcd9c12 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(); ?> <tbody class="cart item"> 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 d10b01b1591fca77c9bd511743064a94588b836d..f0ead67e1bdc2a009f77e2bf646408e3e3d79929 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(); ?> <span class="cart-price"> 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 09230fd5c336c67769392d2d083cb95af64e20f0..df0f4f3233cb73a5a3552a3355aa9d391f5f223c 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(); ?> <?php $_incl = $this->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 f81ddc607c938bbc6acc8ba9897b1a296a7e14c6..b4b340e78b553c84f10888facbbbbb9ef55f6101 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(); ?> <span class="cart-price"> 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 6ff351b90f76a939edd05cce488504d0df22cf70..53118c3312595f301cb9afc861b3476da7a49194 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(); ?> <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item); ?> 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 aaff68ef03aca5f2230b68512bca28792c3cee9f..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping.phtml +++ /dev/null @@ -1,133 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -/** - * @removeCandidate - */ -?> -<form class="form shipping address" id="co-shipping-form" data-hasrequired="<?php /* @escapeNotVerified */ echo __('* Required Fields') ?>"> - -<?php if ($block->customerHasAddresses()): ?> - <div class="field addresses"> - <label class="label" for="shipping:address-select"><span><?php /* @escapeNotVerified */ echo __('Select a shipping address from your address book or enter a new address.') ?></span></label> - <div class="control"><?php echo $block->getAddressesHtmlSelect('shipping') ?></div> - </div> -<?php endif ?> - <fieldset class="fieldset address" id="shipping-new-address-form"<?php if ($block->customerHasAddresses()): ?> style="display:none;"<?php endif ?>> - <input type="hidden" name="shipping[address_id]" value="<?php /* @escapeNotVerified */ echo $block->getAddress()->getId() ?>" id="shipping:address_id" /> - <?php echo $block->getLayout()->createBlock('Magento\Customer\Block\Widget\Name')->setObject($block->getAddress())->setFieldIdFormat('shipping:%s')->setFieldNameFormat('shipping[%s]')->toHtml() ?> - <div class="field company"> - <label class="label" for="shipping:company"><span><?php /* @escapeNotVerified */ echo __('Company') ?></span></label> - <div class="control"> - <input type="text" id="shipping:company" name="shipping[company]" value="<?php echo $block->escapeHtml($block->getAddress()->getCompany()) ?>" title="<?php /* @escapeNotVerified */ echo __('Company') ?>" class="input-text <?php /* @escapeNotVerified */ echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('company') ?>" /> - </div> - </div> - <?php if ($this->helper('Magento\Customer\Helper\Address')->isVatAttributeVisible()) : ?> - <div class="field taxvat"> - <label class="label" for="shipping:vat_id"><span><?php /* @escapeNotVerified */ echo __('VAT Number'); ?></span></label> - <div class="control"> - <input type="text" id="shipping:vat_id" name="shipping[vat_id]" value="<?php echo $block->escapeHtml($block->getAddress()->getVatId()); ?>" title="<?php /* @escapeNotVerified */ echo __('VAT Number'); ?>" class="input-text <?php /* @escapeNotVerified */ echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('vat_id') ?>" /> - </div> - </div> - <?php endif; ?> - <?php $_streetValidationClass = $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('street'); ?> - <div class="field street required"> - <label class="label" for="shipping:street1"><span><?php /* @escapeNotVerified */ echo __('Address') ?></span></label> - <div class="control"> - <input type="text" title="<?php /* @escapeNotVerified */ echo __('Street Address') ?>" name="shipping[street][]" id="shipping:street1" value="<?php echo $block->escapeHtml($block->getAddress()->getStreetLine(1)) ?>" class="input-text <?php /* @escapeNotVerified */ echo $_streetValidationClass ?>" /> - <div class="nested"> - <?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?> - <?php for ($_i = 2, $_n = $this->helper('Magento\Customer\Helper\Address')->getStreetLines(); $_i <= $_n; $_i++): ?> - <div class="field additional"> - <label class="label" for="shipping:street<?php /* @escapeNotVerified */ echo $_i ?>"> - <span><?php /* @escapeNotVerified */ echo __('Street Address %1', $_i) ?></span> - </label> - <div class="control"> - <input type="text" title="<?php /* @escapeNotVerified */ echo __('Street Address %1', $_i) ?>" name="shipping[street][]" id="shipping:street<?php /* @escapeNotVerified */ echo $_i ?>" value="<?php echo $block->escapeHtml($block->getAddress()->getStreetLine($_i)) ?>" class="input-text <?php /* @escapeNotVerified */ echo $_streetValidationClass ?>" /> - </div> - </div> - <?php endfor; ?> - </div> - </div> - </div> - - <div class="field city required"> - <label class="label" for="shipping:city"><span><?php /* @escapeNotVerified */ echo __('City') ?></span></label> - <div class="control"> - <input type="text" title="<?php /* @escapeNotVerified */ echo __('City') ?>" name="shipping[city]" value="<?php echo $block->escapeHtml($block->getAddress()->getCity()) ?>" class="input-text <?php /* @escapeNotVerified */ echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('city') ?>" id="shipping:city" /> - </div> - </div> - <div class="field region required"> - <label class="label" for="shipping:region"><span><?php /* @escapeNotVerified */ echo __('State/Province') ?></span></label> - <div class="control"> - <select id="shipping:region_id" name="shipping[region_id]" title="<?php /* @escapeNotVerified */ echo __('State/Province') ?>" class="validate-select" style="display:none;"> - <option value=""><?php /* @escapeNotVerified */ echo __('Please select a region, state or province.') ?></option> - </select> - <input type="text" id="shipping:region" name="shipping[region]" value="<?php echo $block->escapeHtml($block->getAddress()->getRegion()) ?>" title="<?php /* @escapeNotVerified */ echo __('State/Province') ?>" class="input-text <?php /* @escapeNotVerified */ echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('region') ?>" style="display:none;" /> - </div> - </div> - <div class="field zip required"> - <label class="label" for="shipping:postcode"><span><?php /* @escapeNotVerified */ echo __('Zip/Postal Code') ?></span></label> - <div class="control"> - <input type="text" title="<?php /* @escapeNotVerified */ echo __('Zip/Postal Code') ?>" name="shipping[postcode]" id="shipping:postcode" value="<?php echo $block->escapeHtml($block->getAddress()->getPostcode()) ?>" class="input-text validate-zip-international <?php /* @escapeNotVerified */ echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('postcode') ?>" data-validate="{'required':true, 'validate-zip-international':true}" /> - </div> - </div> - <div class="field country required"> - <label class="label" for="shipping:country_id"><span><?php /* @escapeNotVerified */ echo __('Country') ?></span></label> - <div class="control"> - <?php echo $block->getCountryHtmlSelect('shipping') ?> - </div> - </div> - <div class="field telephone required"> - <label class="label" for="shipping:telephone"><span><?php /* @escapeNotVerified */ echo __('Phone Number') ?></span></label> - <div class="control"> - <input type="text" name="shipping[telephone]" value="<?php echo $block->escapeHtml($block->getAddress()->getTelephone()) ?>" title="<?php /* @escapeNotVerified */ echo __('Telephone') ?>" class="input-text <?php /* @escapeNotVerified */ echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('telephone') ?>" id="shipping:telephone" /> - </div> - </div> - <div class="field fax"> - <label class="label" for="shipping:fax"><span><?php /* @escapeNotVerified */ echo __('Fax') ?></span></label> - <div class="control"> - <input type="text" name="shipping[fax]" value="<?php echo $block->escapeHtml($block->getAddress()->getFax()) ?>" title="<?php /* @escapeNotVerified */ echo __('Fax') ?>" class="input-text <?php /* @escapeNotVerified */ echo $this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('fax') ?>" id="shipping:fax" /> - </div> - </div> - - <?php if ($block->isCustomerLoggedIn() && $block->customerHasAddresses()):?> - <div class="field choice save"> - <input type="checkbox" name="shipping[save_in_address_book]" value="1" title="<?php /* @escapeNotVerified */ echo __('Save in address book') ?>" id="shipping:save_in_address_book" <?php if ($block->getAddress()->getSaveInAddressBook()):?> checked="checked"<?php endif;?> class="checkbox" /> - <label class="label" for="shipping:save_in_address_book"><span><?php /* @escapeNotVerified */ echo __('Save in address book') ?></span></label> - </div> - <?php else:?> - <input type="hidden" name="shipping[save_in_address_book]" value="1" /> - <?php endif;?> - </fieldset> - <div class="choice field"> - <input type="checkbox" name="shipping[same_as_billing]" id="shipping:same_as_billing" value="1"<?php if ($block->getAddress()->getSameAsBilling()): ?> checked="checked"<?php endif; ?> class="checkbox" /> - <label class="label" for="shipping:same_as_billing"><span><?php /* @escapeNotVerified */ echo __('Use Billing Address') ?></span></label> - </div> - <div class="actions-toolbar" id="shipping-buttons-container"> - <div class="primary"> - <button data-role="opc-continue" type="button" class="action continue primary"><span><?php /* @escapeNotVerified */ echo __('Continue') ?></span></button> - </div> - <div class="secondary"><a href="#" class="action back"><span><?php /* @escapeNotVerified */ echo __('Back') ?></span></a></div> - </div> -</form> -<script type="text/x-magento-init"> - { - "#shipping\\:country_id": { - "regionUpdater": { - "optionalRegionAllowed": <?php /* @escapeNotVerified */ echo($block->getConfig('general/region/display_all') ? 'true' : 'false'); ?>, - "regionListId": "#shipping\\:region_id", - "regionInputId": "#shipping\\:region", - "postcodeId": "#shipping\\:postcode", - "regionJson": <?php /* @escapeNotVerified */ echo $this->helper('Magento\Directory\Helper\Data')->getRegionJson() ?>, - "defaultRegion": "<?php /* @escapeNotVerified */ echo $block->getAddress()->getRegionId() ?>", - "countriesWithOptionalZip": <?php /* @escapeNotVerified */ echo $this->helper('Magento\Directory\Helper\Data')->getCountriesWithOptionalZip(true) ?> - } - } - } -</script> 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 4ab0004006b422c96f48ffd63410853abd473a8c..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method.phtml +++ /dev/null @@ -1,24 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -/** - * @removeCandidate - */ -?> -<form class="form methods-shipping" id="co-shipping-method-form"> - <div id="checkout-shipping-method-load"></div> - <div id="onepage-checkout-shipping-method-additional-load"> - <?php echo $block->getChildHtml('additional') ?> - </div> - <div class="actions-toolbar" id="shipping-method-buttons-container"> - <div class="primary"> - <button data-role="opc-continue" type="button" class="button action continue primary"><span><?php /* @escapeNotVerified */ echo __('Continue') ?></span></button> - </div> - <div class="secondary"><a class="action back" href="#"><span><?php /* @escapeNotVerified */ echo __('Back') ?></span></a></div> - </div> -</form> 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 ac87ff9ce6691d7e0062c81b1fa59d59aa817df2..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method/additional.phtml +++ /dev/null @@ -1,15 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -/** - * @removeCandidate - */ -?> -<?php if (!$block->getQuote()->isVirtual()): ?> - <?php /* @escapeNotVerified */ echo $this->helper('Magento\GiftMessage\Helper\Message')->getInline('onepage_checkout', $block->getQuote(), $block->getDontDisplayContainer()) ?> -<?php endif; ?> 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 f2b37b4be7c835b7ec4fe521af4b907e35678510..0000000000000000000000000000000000000000 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/shipping_method/available.phtml +++ /dev/null @@ -1,50 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -/** - * @removeCandidate - */ -?> -<?php /** @var $block \Magento\Checkout\Block\Onepage\Shipping\Method\Available */ ?> -<?php $_shippingRateGroups = $block->getShippingRates(); ?> -<?php if (!$_shippingRateGroups): ?> - <p><?php /* @escapeNotVerified */ echo __('Sorry, no quotes are available for this order right now.') ?></p> -<?php else: ?> - <dl class="items methods-shipping"> - <?php $shippingCodePrice = []; ?> - <?php $_sole = count($_shippingRateGroups) == 1; foreach ($_shippingRateGroups as $code => $_rates): ?> - <dt class="item-title <?php /* @escapeNotVerified */ echo $code ?>"><?php echo $block->escapeHtml($block->getCarrierName($code)) ?></dt> - <dd class="item-content <?php /* @escapeNotVerified */ echo $code ?>"> - <fieldset class="fieldset"> - <legend class="legend"><span><?php echo $block->escapeHtml($block->getCarrierName($code)) ?></span></legend><br> - <?php $_sole = $_sole && count($_rates) == 1; foreach ($_rates as $_rate): ?> - <?php $shippingCodePrice[] = '"'.$_rate->getCode().'":'.(float)$_rate->getPrice(); ?> - <div class="field choice"> - <?php if ($_rate->getErrorMessage()): ?> - <div class="message error"><div><?php echo $block->escapeHtml($_rate->getErrorMessage()) ?></div></div> - <?php else: ?> - <?php if ($_sole) : ?> - <span class="no-display"><input name="shipping_method" type="radio" value="<?php /* @escapeNotVerified */ echo $_rate->getCode() ?>" id="s_method_<?php /* @escapeNotVerified */ echo $_rate->getCode() ?>" checked="checked" /></span> - <?php else: ?> - <div class="control"> - <input name="shipping_method" type="radio" value="<?php /* @escapeNotVerified */ echo $_rate->getCode() ?>" id="s_method_<?php /* @escapeNotVerified */ echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$block->getAddressShippingMethod()) echo ' checked="checked"' ?> class="radio"/> - </div> - <?php endif; ?> - <label class="label" for="s_method_<?php /* @escapeNotVerified */ echo $_rate->getCode() ?>"><span><?php echo $block->escapeHtml($_rate->getMethodTitle()) ?> - <?php echo $block->getShippingPriceHtml($_rate); ?> - </span> - </label> - <?php endif ?> - </div> - <?php endforeach; ?> - </fieldset> - </dd> - <?php endforeach; ?> - </dl> - <div class="no-display" data-shipping-code-price='{<?php /* @escapeNotVerified */ echo implode(",",$shippingCodePrice); ?>}'></div> -<?php endif; ?> 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 2090bdabfe69b2af20f08e340af079cd76d551bd..0c0060f737d536ec0b78774e1e9dcedf38662861 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/model/shipping-rates-validator.js b/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rates-validator.js index c510194a2087382d07fed7f8367408ce95aafdb9..732f328ff727403e2e52e10d2980d902c0839611 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; } }; 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 5ed385463d8bca9873012ce9effe69244762c47a..0000000000000000000000000000000000000000 --- 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 0f92f6ea63362f1de7e995e7db9ee721d012b15c..0000000000000000000000000000000000000000 --- 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 83313faeebf5c513acfc11577db030f644b15500..0000000000000000000000000000000000000000 --- 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 bfa87548aea2a170d7372bbc547266c482e9d7f6..0000000000000000000000000000000000000000 --- 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: '<input id="hidden-free" type="hidden" name="payment[method]" value="free">', - 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 bf3ef59bcf42938b341150c75d6df91d497be10f..0000000000000000000000000000000000000000 --- 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 505db47ab57901c4dcc73330ed27ebf66d0a4968..0000000000000000000000000000000000000000 --- 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 570dd9edf2d892eb39266dc467fc85f2861c84fc..0000000000000000000000000000000000000000 --- 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: '<input id="hidden-free" type="hidden" name="payment[method]" value="free">', - 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 8b03193bb79c95626391cfb4d75691def2f3a1cd..0000000000000000000000000000000000000000 --- 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/Checkout/view/frontend/web/js/proceed-to-checkout.js b/app/code/Magento/Checkout/view/frontend/web/js/proceed-to-checkout.js index 7a6b4e88be10c65b823c7616ac0e46a3ed5720a1..7754719a506ff406fb18b2b6f3a92aff3366073c 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/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 80d9a5982a6ab575ab68f6500ec72d0e2117d788..b69365ebc0f17eedcdc4b039c235e8286ce3bf73 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); @@ -115,6 +118,9 @@ define( useShippingAddress: function () { if (this.isAddressSameAsShipping()) { selectBillingAddress(quote.shippingAddress()); + if (window.checkoutConfig.reloadOnBillingAddress) { + setBillingAddressAction(globalMessageList); + } this.isAddressDetailsVisible(true); } else { lastSelectedBillingAddress = quote.billingAddress(); @@ -142,12 +148,13 @@ define( if (!this.source.get('params.invalid')) { var addressData = this.source.get(this.dataScopePrefix), - newBillingAddress = createBillingAddress(addressData); + newBillingAddress; - if (this.isCustomerLoggedIn && !this.customerHasAddresses) { + 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); 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 187f17e5b3962788ba0eb03a95858e4672d27c7b..53b8d8fde3b48ba4bc2579738dfe7ee55d10f8f7 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,19 +3,33 @@ * 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 false; + } + }); + + 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 dae05d712dd9b05eba81c48108e2908c0290b9ee..fc4d6931be2e0629fe444de52c4b19e8e83ae209 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({ diff --git a/app/code/Magento/GroupedProduct/view/adminhtml/layout/groupedproduct_popup_grid.xml b/app/code/Magento/GroupedProduct/view/adminhtml/layout/groupedproduct_popup_grid.xml index 87435ac42e867730101a2752f0cd1c95747d0fb2..e47123ca4322c75030941a8382f9fb8072a703ac 100644 --- a/app/code/Magento/GroupedProduct/view/adminhtml/layout/groupedproduct_popup_grid.xml +++ b/app/code/Magento/GroupedProduct/view/adminhtml/layout/groupedproduct_popup_grid.xml @@ -24,11 +24,17 @@ <arguments> <argument name="id" xsi:type="string">grouped_grid_popup</argument> </arguments> - <block class="Magento\Backend\Block\Widget\Grid\Column" as="entity_id"> + <block class="Magento\Backend\Block\Widget\Grid\Column" as="entity_ids"> <arguments> - <argument name="header" xsi:type="string" translate="true">ID</argument> <argument name="type" xsi:type="string">skip-list</argument> <argument name="renderer" xsi:type="string">Magento\Backend\Block\Widget\Grid\Column\Renderer\Checkbox</argument> + <argument name="name" xsi:type="string">entity_ids</argument> + <argument name="index" xsi:type="string">entity_id</argument> + </arguments> + </block> + <block class="Magento\Backend\Block\Widget\Grid\Column" as="entity_id"> + <arguments> + <argument name="header" xsi:type="string" translate="true">ID</argument> <argument name="index" xsi:type="string">entity_id</argument> </arguments> </block> diff --git a/app/code/Magento/GroupedProduct/view/adminhtml/web/js/grouped-product.js b/app/code/Magento/GroupedProduct/view/adminhtml/web/js/grouped-product.js index b7badba6e79c142c8c1a92e0d60cdb41500507d4..1e497ed7b8231de9c057b986dc1f6c0387aa6aa2 100644 --- a/app/code/Magento/GroupedProduct/view/adminhtml/web/js/grouped-product.js +++ b/app/code/Magento/GroupedProduct/view/adminhtml/web/js/grouped-product.js @@ -132,7 +132,7 @@ define([ if (!target.is('input')) { target.closest('[data-role=row]') - .find('[data-column=entity_id] input') + .find('[data-column=entity_ids] input') .prop('checked', function (element, value) { return !value; }) @@ -142,7 +142,7 @@ define([ popup.on( 'change', - '[data-role=row] [data-column=entity_id] input', + '[data-role=row] [data-column=entity_ids] input', $.proxy(function (event) { var element = $(event.target), product = {}; @@ -175,12 +175,12 @@ define([ return $(element).val(); }).toArray(); ajaxSettings.data.filter = $.extend(ajaxSettings.data.filter || {}, { - 'entity_id': ids + 'entity_ids': ids }); }) .on('gridajax', function (event, ajaxRequest) { ajaxRequest.done(function () { - popup.find('[data-role=row] [data-column=entity_id] input') + popup.find('[data-role=row] [data-column=entity_ids] input') .each(function (index, element) { var $element = $(element); $element.prop('checked', !!selectedProductList[$element.val()]); diff --git a/app/code/Magento/Multishipping/view/frontend/requirejs-config.js b/app/code/Magento/Multishipping/view/frontend/requirejs-config.js index 034ecbd8057cc90818703b5c87aca8e3aeec4078..dbbc46fd928660b3293d2fcd4d2f9a2c270ecb59 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 1442bb787605236b3b40abfe430e9b98af6afd24..8baea212f57c07b5449d38b38987010f0f72f790 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/Block/Express/Review/Billing.php b/app/code/Magento/Paypal/Block/Express/Review/Billing.php index c613b56c40f0eb285d1b4b63d00c98daec0bb9f4..445582f9dbd6b7024d8f7c1ebaecd998c3486b9c 100644 --- a/app/code/Magento/Paypal/Block/Express/Review/Billing.php +++ b/app/code/Magento/Paypal/Block/Express/Review/Billing.php @@ -9,8 +9,222 @@ */ namespace Magento\Paypal\Block\Express\Review; -class Billing extends \Magento\Checkout\Block\Onepage\Billing +use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Quote\Model\Quote; + +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +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; + $this->_isScopePrivate = true; + $this->httpContext = $httpContext; + $this->customerRepository = $customerRepository; + $this->checkoutSession = $resourceSession; + $this->customerSession = $customerSession; + $this->countryCollectionFactory = $countryCollectionFactory; + parent::__construct($context, $data); + } + + /** + * Initialize billing address step + * + * @return void + */ + protected function _construct() + { + $this->getCheckout()->setStepData( + 'billing', + ['label' => __('Billing Information'), 'is_show' => true] + ); + + 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 +232,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 97fe0a20e9c3f045da8a8c29c830f5b97691a8f5..e49171238ceedc62304d95b5e2e0e7a00f6f5053 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; + $this->_isScopePrivate = true; + $this->httpContext = $httpContext; + $this->customerRepository = $customerRepository; + $this->checkoutSession = $resourceSession; + $this->customerSession = $customerSession; + parent::__construct($context, $data); + } + + /** + * 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 60e525f463b8f15ad65139be01d9d31017061bd1..695adda9167dd09b65ff1ecc400ed0dcf6e4a951 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 @@ <block class="Magento\Framework\View\Element\Text\ListText" name="paypal.additional.actions"/> <block class="Magento\Paypal\Block\Express\Review\Details" name="paypal.express.review.details" as="details" template="express/review/details.phtml"> <block class="Magento\Framework\View\Element\RendererList" name="checkout.onepage.review.item.renderers" as="renderer.list"/> - <block class="Magento\Checkout\Block\Cart\Totals" name="paypal.express.review.details.totals" as="totals" template="onepage/review/totals.phtml"/> + <block class="Magento\Checkout\Block\Cart\Totals" name="paypal.express.review.details.totals" as="totals" template="checkout/onepage/review/totals.phtml"/> </block> <block class="Magento\CheckoutAgreements\Block\Agreements" name="paypal.express.review.details.agreements" as="agreements" template="Magento_CheckoutAgreements::additional_agreements.phtml"/> </block> 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 01be224c3d0f1d5c88ddce44ae8a42d1a24e8d9a..6594f0a472a8a64261dcf93a9759d7b5dc5361ca 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 @@ <container name="root"> <block class="Magento\Paypal\Block\Express\Review\Details" name="page.block" template="express/review/details.phtml"> <block class="Magento\Framework\View\Element\RendererList" name="checkout.onepage.review.item.renderers" as="renderer.list"/> - <block class="Magento\Checkout\Block\Cart\Totals" name="paypal.express.review.details.totals" as="totals" template="onepage/review/totals.phtml"/> + <block class="Magento\Checkout\Block\Cart\Totals" name="paypal.express.review.details.totals" as="totals" template="checkout/onepage/review/totals.phtml"/> </block> </container> </layout> 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 e41ab21bced7420064dde9f1340cb62e6a2279c6..7fb0e07142bea9020e7d4c361b5e682de0a0c0b4 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 @@ <block class="Magento\Framework\View\Element\Text\ListText" name="paypal.additional.actions"/> <block class="Magento\Paypal\Block\Express\Review\Details" name="paypal.express.review.details" as="details" template="express/review/details.phtml"> <block class="Magento\Framework\View\Element\RendererList" name="checkout.onepage.review.item.renderers" as="renderer.list"/> - <block class="Magento\Checkout\Block\Cart\Totals" name="paypal.express.review.details.totals" as="totals" template="onepage/review/totals.phtml"/> + <block class="Magento\Checkout\Block\Cart\Totals" name="paypal.express.review.details.totals" as="totals" template="checkout/onepage/review/totals.phtml"/> </block> <block class="Magento\CheckoutAgreements\Block\Agreements" name="paypal.express.review.details.agreements" as="agreements" template="Magento_CheckoutAgreements::additional_agreements.phtml"/> </block> diff --git a/app/code/Magento/Paypal/view/frontend/requirejs-config.js b/app/code/Magento/Paypal/view/frontend/requirejs-config.js index 49f8f54129f620c79eeee168324edeca563a4822..8e6be0da47bd15ba3550a7f04c4668a7165bbc1a 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/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 ab70dbab565d4019eb9edbca45eef9ad0a9c6f4e..94aca67913e6b768bfb4200c35327d0315da7fb4 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 - */ ?> <?php if ($block->getTotals()): ?> <?php $_colspan = 3; ?> 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 140ad1a72e4841b5cf65c1ca7d7e981ef15b7c81..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/frontend/templates/onepage.phtml +++ /dev/null @@ -1,13 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -?> -<script type="text/x-magento-init"> - { - "#checkoutSteps": { - "opcheckoutPaypalIframe": {} - } - } -</script> \ 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 416a455c511cb87b9732543fe64ed9c92bdb8d73..0000000000000000000000000000000000000000 --- 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/api-functional/testsuite/Magento/Bundle/Api/ProductOptionRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductOptionRepositoryTest.php index 8c486761f3906fd7a456e0b46c79337298ca5ea6..2554dacd770551b56fae549f9306d7bcaabd65cc 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 @@ class ProductOptionRepositoryTest extends \Magento\TestFramework\TestCase\Webapi */ 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/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.xml index 1654b19df2435385286d09db719cb4314f15fdba..530018bf81c4741e9785564800a14f39a3397ac1 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.xml @@ -129,7 +129,6 @@ <constraint name="Magento\Catalog\Test\Constraint\AssertProductVisibleInCategory" /> <constraint name="Magento\Bundle\Test\Constraint\AssertBundleProductPage" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductInStock" /> - <constraint name="Magento\Bundle\Test\Constraint\AssertGroupedPriceOnBundleProductPage" /> <constraint name="Magento\Bundle\Test\Constraint\AssertBundleItemsOnProductPage" /> <constraint name="Magento\Bundle\Test\Constraint\AssertBundlePriceView" /> <constraint name="Magento\Bundle\Test\Constraint\AssertBundlePriceType" /> diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedShoppingCart.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedShoppingCart.php index 7a4e4b605ef4b7c64a09c0ac6d613159167002c2..252a96620ece4f2838e057bd5ec1753d4f6729e1 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedShoppingCart.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedShoppingCart.php @@ -58,6 +58,7 @@ class AssertCatalogPriceRuleAppliedShoppingCart extends AbstractConstraint . "\nActual: " . $actualPrice . "\n" ); } + $checkoutCartPage->getTotalsBlock()->waitForShippingPriceBlock(); $actualPrices['sub_total'] = $checkoutCartPage->getTotalsBlock()->getSubtotal(); $actualPrices['grand_total'] = $checkoutCartPage->getTotalsBlock()->getGrandTotal(); $expectedPrices['sub_total'] = $cartPrice['sub_total']; diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Totals.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Totals.php index 8b2bfcbd56d4f4f3b90a03d9ecdad7b39d322efd..738bb89e949b6476bf67fbb1407b2be3e06ae192 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Totals.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Totals.php @@ -251,4 +251,14 @@ class Totals extends Block sleep(1); $this->waitForElementNotVisible($this->blockWaitElement); } + + /** + * Wait for shipping block to appear + * + * @return bool|null + */ + public function waitForShippingPriceBlock() + { + $this->waitForElementVisible($this->shippingPriceBlockSelector, Locator::SELECTOR_CSS); + } } diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Adminhtml/Product/Grouped/AssociatedProducts/Search/Grid.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Adminhtml/Product/Grouped/AssociatedProducts/Search/Grid.php index 55b341dc6d3b72224065b2c9b41e3bc05264834a..caa07b91ce7efd9d88bc031c324ca400c69d1d7c 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Adminhtml/Product/Grouped/AssociatedProducts/Search/Grid.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Adminhtml/Product/Grouped/AssociatedProducts/Search/Grid.php @@ -37,7 +37,7 @@ class Grid extends GridInterface * * @var string */ - protected $selectItem = '[data-column=entity_id] input'; + protected $selectItem = '[data-column=entity_ids] input'; /** * Press 'Add Selected Products' button 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 8e9cd3f440d6c2634e201e33df39a75608548b9a..0000000000000000000000000000000000000000 --- a/dev/tests/integration/testsuite/Magento/Checkout/Block/Onepage/Payment/MethodsTest.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -/** - * Test class for \Magento\Checkout\Block\Onepage\Payment\Methods - */ -namespace Magento\Checkout\Block\Onepage\Payment; - -class MethodsTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Checkout\Block\Onepage\Payment\Methods - */ - protected $_block; - - protected function setUp() - { - parent::setUp(); - $this->_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 84% 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 86ac63afe57145019c36e4f111e5e398d0c12260..c256479cc7c833efa628eb58bc084554b87d2ce3 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 @@ use Magento\TestFramework\Helper\Bootstrap; */ 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,9 +67,9 @@ class BillingTest extends \PHPUnit_Framework_TestCase ->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] + ['customerSession' => $customerSession, 'resourceSession' => $checkoutSession] ); } @@ -136,19 +136,4 @@ class BillingTest extends \PHPUnit_Framework_TestCase $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 -<select name="billing_address_id" id="billing:address-select" class="address-select" title="" ><option value="1" selected="selected" >John Smith, Green str, 67, CityM, Alabama 75477, United States</option><option value="" >New Address</option></select> -OUTPUT; - // @codingStandardsIgnoreEnd - $this->assertEquals($expected, $this->_block->getAddressesHtmlSelect('billing')); - } } diff --git a/dev/tests/integration/testsuite/Magento/Sitemap/Helper/DataTest.php b/dev/tests/integration/testsuite/Magento/Sitemap/Helper/DataTest.php index 3eacb4c386420311d3587fe3e407eae85f5319ef..2579f660db11dc69b964c33e58cc132c8010b645 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' ); 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 6349d18bdced4120969be3672cd54cb77c49ddcd..ed5c2b33fdb300f95da2efff0e1ceb3835ad1575 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 @@ class CodeMessDetector implements ToolInterface */ 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'); } /** 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 196e065ee3e70fec05aa5ff56dfe847a2677d6e6..b3b7e590f57764f349feb000fd9c778aaa4863c4 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 @@ class CodeMessDetectorTest extends \PHPUnit_Framework_TestCase '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() ); } 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 70168b63a4efb5f06f978a00c9896b0c1a6d5f12..7497804d68237b137475036e394951135630508e 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,15 +105,6 @@ 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/region-updater.js app/code/Magento/Checkout/view/frontend/web/js/shopping-cart.js @@ -219,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 @@ -688,15 +680,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 9699f47c4bcccc9dd1009437092117fae86c0f25..2cb2aca38f906e767c139a830976538f18f337cc 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 diff --git a/setup/src/Magento/Setup/Controller/Connect.php b/setup/src/Magento/Setup/Controller/Connect.php index b5a400262717c5c4ae6a1c6da7fa2f0b70e4c067..7ff039e3f4bcc85d05427b13f0c056fa08e7f08b 100644 --- a/setup/src/Magento/Setup/Controller/Connect.php +++ b/setup/src/Magento/Setup/Controller/Connect.php @@ -42,7 +42,10 @@ class Connect extends AbstractActionController */ 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'] : '';