Skip to content

Commit

Permalink
Merge pull request #404 from magento-folks/checkout
Browse files Browse the repository at this point in the history
[Folks] Checkout bug-fixes and improvements
  • Loading branch information
Korshenko, Olexii(okorshenko) committed Jul 3, 2015
2 parents 485c067 + 7d8a80d commit e5376c1
Show file tree
Hide file tree
Showing 136 changed files with 602 additions and 434 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected function _prepareForm()

/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$fieldset = $form->addFieldset('set_name', ['legend' => __('Edit Set Name')]);
$fieldset = $form->addFieldset('set_name', ['legend' => __('Edit Product Template Name')]);
$fieldset->addField(
'attribute_set_name',
'text',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected function _prepareLayout()
'addButton',
'Magento\Backend\Block\Widget\Button',
[
'label' => __('Add New Set'),
'label' => __('Add Product Template'),
'onclick' => 'setLocation(\'' . $this->getUrl('catalog/*/add') . '\')',
'class' => 'add primary add-set'
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function execute()
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
$resultPage = $this->resultPageFactory->create();
$resultPage->setActiveMenu('Magento_Catalog::catalog_products');
$resultPage->getConfig()->getTitle()->set((__('Products')));
$resultPage->getConfig()->getTitle()->prepend(__('Catalog'));
return $resultPage;
}
}
2 changes: 1 addition & 1 deletion app/code/Magento/Checkout/Block/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function isWishlistActive()
*/
public function getCheckoutUrl()
{
return $this->getUrl('checkout/onepage', ['_secure' => true]);
return $this->getUrl('checkout', ['_secure' => true]);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Checkout/Block/Cart/Sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function getImageHtmlTemplate()
*/
public function getCheckoutUrl()
{
return $this->getUrl('checkout/onepage');
return $this->getUrl('checkout');
}

/**
Expand Down
9 changes: 8 additions & 1 deletion app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ public function process($jsLayout)
if (isset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
['payment']['children']
)) {
if (!isset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
['payment']['children']['payments-list']['children'])) {
$jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
['payment']['children']['payments-list']['children'] = [];
}

$jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
['payment']['children']['payments-list']['children'] =
array_merge_recursive(
Expand Down Expand Up @@ -111,6 +117,7 @@ private function processPaymentConfiguration(array &$configuration, array $eleme
'component' => 'Magento_Checkout/js/view/billing-address',
'displayArea' => 'billing-address-form-' . $paymentCode,
'provider' => 'checkoutProvider',
'deps' => 'checkoutProvider',
'dataScopePrefix' => 'billingAddress' . $paymentCode,
'sortOrder' => 1,
'children' => [
Expand Down Expand Up @@ -162,7 +169,7 @@ private function processPaymentConfiguration(array &$configuration, array $eleme
'telephone' => [
'config' => [
'tooltip' => [
'description' => 'For delivery Questions',
'description' => 'For delivery questions.',
],
],
],
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Checkout/Block/Onepage/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(
*/
public function getCheckoutUrl()
{
return $this->getUrl('checkout/onepage');
return $this->getUrl('checkout');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Checkout\Controller\Onepage;
namespace Magento\Checkout\Controller\Index;

class Index extends \Magento\Checkout\Controller\Onepage
{
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Checkout/Controller/Onepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,14 @@ protected function _expireAjax()
{
$quote = $this->getOnepage()->getQuote();
if (!$quote->hasItems() || $quote->getHasError() || !$quote->validateMinimumAmount()) {
return false;
return true;
}
$action = $this->getRequest()->getActionName();
if ($this->_objectManager->get('Magento\Checkout\Model\Session')->getCartWasUpdated(true)
&&
!in_array($action, ['index', 'progress'])
) {
return false;
return true;
}

return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
/**
* Test for \Magento\Checkout\Controller\Onepage\Index
* Test for \Magento\Checkout\Controller\Index\Index
*
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Checkout\Test\Unit\Controller\Onepage;
namespace Magento\Checkout\Test\Unit\Controller\Index;

use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManager;

Expand Down Expand Up @@ -71,7 +71,7 @@ class IndexTest extends \PHPUnit_Framework_TestCase
private $redirectMock;

/**
* @var \Magento\Checkout\Controller\Onepage\Index
* @var \Magento\Checkout\Controller\Index\Index
*/
private $model;

Expand Down Expand Up @@ -171,7 +171,7 @@ public function setUp()

// SUT
$this->model = $this->objectManager->getObject(
'Magento\Checkout\Controller\Onepage\Index',
'Magento\Checkout\Controller\Index\Index',
[
'context' => $this->contextMock,
'customerSession' => $this->sessionMock,
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Checkout/etc/frontend/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<type name="Magento\Framework\Url\SecurityInfo">
<arguments>
<argument name="secureUrlList" xsi:type="array">
<item name="checkout_onepage" xsi:type="string">/checkout/onepage</item>
<item name="checkout_index" xsi:type="string">/checkout</item>
</argument>
</arguments>
</type>
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Checkout/etc/frontend/page_types.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<type id="checkout_cart_configure" label="Configure Cart Item (Any)"/>
<type id="checkout_cart_index" label="Shopping Cart"/>
<type id="checkout_onepage_failure" label="One Page Checkout Failure"/>
<type id="checkout_onepage_index" label="One Page Checkout"/>
<type id="checkout_index_index" label="One Page Checkout"/>
<type id="checkout_onepage_paymentmethod" label="One Page Checkout Choose Payment Method"/>
<type id="checkout_onepage_review" label="One Page Checkout Overview"/>
<type id="checkout_onepage_shippingmethod" label="One Page Checkout Choose Shipping Method"/>
Expand Down
3 changes: 3 additions & 0 deletions app/code/Magento/Checkout/etc/frontend/sections.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@
<action name="checkout/sidebar/updateItemQty">
<section name="cart"/>
</action>
<action name="checkout/onepage/saveOrder">
<section name="last-ordered-items"/>
</action>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<item name="component" xsi:type="string">Magento_Ui/js/form/element/abstract</item>
<item name="config" xsi:type="array">
<item name="provider" xsi:type="string">checkoutProvider</item>
<item name="deps" xsi:type="array">
<item name="0" xsi:type="string">checkoutProvider</item>
</item>
<item name="template" xsi:type="string">ui/form/field</item>
<item name="elementTmpl" xsi:type="string">ui/form/element/input</item>
</item>
Expand Down Expand Up @@ -46,6 +49,14 @@
<item name="component" xsi:type="string">Magento_Checkout/js/view/progress-bar</item>
<item name="displayArea" xsi:type="string">progressBar</item>
</item>
<item name="estimation" xsi:type="array">
<item name="sortOrder" xsi:type="string">10</item>
<item name="component" xsi:type="string">Magento_Checkout/js/view/estimation</item>
<item name="displayArea" xsi:type="string">estimation</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">Magento_Checkout/estimation</item>
</item>
</item>
<item name="steps" xsi:type="array">
<item name="component" xsi:type="string">uiComponent</item>
<item name="displayArea" xsi:type="string">steps</item>
Expand All @@ -66,7 +77,10 @@
</item>
<item name="shippingAddress" xsi:type="array">
<item name="config" xsi:type="array">
<item name="deps" xsi:type="string">checkout.steps.shipping-step.step-config</item>
<item name="deps" xsi:type="array">
<item name="0" xsi:type="string">checkout.steps.shipping-step.step-config</item>
<item name="1" xsi:type="string">checkoutProvider</item>
</item>
<item name="popUpForm" xsi:type="array">
<item name="element" xsi:type="string">#opc-new-shipping-address</item>
<item name="options" xsi:type="array">
Expand Down Expand Up @@ -149,6 +163,11 @@
</item>
<item name="shipping-address-fieldset" xsi:type="array">
<item name="component" xsi:type="string">uiComponent</item>
<item name="config" xsi:type="array">
<item name="deps" xsi:type="array">
<item name="0" xsi:type="string">checkoutProvider</item>
</item>
</item>
<item name="displayArea" xsi:type="string">additional-fieldsets</item>
<item name="children" xsi:type="array">
<!-- The following items override configuration of corresponding address attributes -->
Expand Down Expand Up @@ -195,7 +214,7 @@
<item name="telephone" xsi:type="array">
<item name="config" xsi:type="array">
<item name="tooltip" xsi:type="array">
<item name="description" xsi:type="string">For delivery Questions</item>
<item name="description" xsi:type="string">For delivery questions.</item>
</item>
</item>
</item>
Expand Down Expand Up @@ -244,7 +263,6 @@
</item>
</item>
</item>
<!-- TODO: add billing address form -->
<item name="beforeMethods" xsi:type="array">
<item name="component" xsi:type="string">uiComponent</item>
<item name="displayArea" xsi:type="string">beforeMethods</item>
Expand Down Expand Up @@ -353,6 +371,9 @@
</item>
<item name="shipping-information" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/shipping-information</item>
<item name="config" xsi:type="array">
<item name="deps" xsi:type="string">checkout.steps.shipping-step.shippingAddress</item>
</item>
<item name="displayArea" xsi:type="string">shipping-information</item>
<item name="children" xsi:type="array">
<item name="ship-to" xsi:type="array">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ define(
'jquery',
'../model/quote',
'Magento_Checkout/js/model/resource-url-manager',
'Magento_Ui/js/model/messageList',
'Magento_Checkout/js/model/error-processor',
'mage/storage',
'Magento_Checkout/js/model/totals'
],
function ($, quote, resourceUrlManager, messageList, storage, totals) {
function ($, quote, resourceUrlManager, errorProcessor, storage, totals) {
"use strict";
return function (callbacks, deferred) {
deferred = deferred || $.Deferred();
Expand All @@ -36,9 +36,8 @@ define(
).error(
function (response) {
totals.isLoading(false);
var error = JSON.parse(response.responseText);
messageList.addErrorMessage(error);
deferred.reject();
errorProcessor.process(response);
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@ define(
'Magento_Checkout/js/model/url-builder',
'mage/storage',
'mage/url',
'Magento_Ui/js/model/messageList',
'Magento_Customer/js/model/customer',
'underscore'
'Magento_Checkout/js/model/error-processor',
'Magento_Customer/js/model/customer'
],
function (quote, urlBuilder, storage, url, messageList, customer, _) {
function (quote, urlBuilder, storage, url, errorProcessor, customer) {
'use strict';

return function (paymentData, redirectOnSuccess) {
var serviceUrl, payload;
var serviceUrl,
payload;

redirectOnSuccess = redirectOnSuccess === false ? false : true;
/**
* Checkout for guest and registered customer.
*/

/** Checkout for guest and registered customer. */
if (!customer.isLoggedIn()) {
serviceUrl = urlBuilder.createUrl('/guest-carts/:quoteId/payment-information', {
quoteId: quote.getQuoteId()
Expand All @@ -40,7 +39,7 @@ define(
billingAddress: quote.billingAddress()
};
}
storage.post(
return storage.post(
serviceUrl, JSON.stringify(payload)
).done(
function () {
Expand All @@ -50,8 +49,7 @@ define(
}
).fail(
function (response) {
var error = JSON.parse(response.responseText);
messageList.addErrorMessage(error);
errorProcessor.process(response);
}
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ define(
});
return function(shippingAddress) {
quote.shippingAddress(shippingAddress);
//set billing address same as shipping by default if it is not empty
if (shippingAddress.countryId != undefined && shippingAddress.canUseForBilling()) {
quote.billingAddress(shippingAddress);
}
};
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ define(
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/url-builder',
'mage/storage',
'Magento_Ui/js/model/messageList',
'Magento_Checkout/js/model/error-processor',
'Magento_Customer/js/model/customer'
],
function (quote, urlBuilder, storage, messageList, customer) {
function (quote, urlBuilder, storage, errorProcessor, customer) {
'use strict';

return function () {
Expand Down Expand Up @@ -47,8 +47,7 @@ define(
}
).fail(
function (response) {
var error = JSON.parse(response.responseText);
messageList.addErrorMessage(error);
errorProcessor.process(response);
}
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
define(
[
'mage/url',
'Magento_Ui/js/model/messageList'
],
function (url, messageList) {
'use strict';

return {
process: function (response) {
if (response.status == 401) {
window.location.replace(url.build('customer/account/login/'));
} else {
var error = JSON.parse(response.responseText);
messageList.addErrorMessage(error);
}
}
};
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ define(
'mage/storage',
'Magento_Checkout/js/model/shipping-service',
'Magento_Checkout/js/model/shipping-rate-registry',
'Magento_Ui/js/model/messageList'
'Magento_Checkout/js/model/error-processor'
],
function (resourceUrlManager, quote, storage, shippingService, rateRegistry, messageList) {
function (resourceUrlManager, quote, storage, shippingService, rateRegistry, errorProcessor) {
"use strict";
return {
getRates: function(address) {
Expand All @@ -35,9 +35,8 @@ define(

).fail(
function(response) {
var error = JSON.parse(response.responseText);
messageList.addErrorMessage(error);
shippingService.setShippingRates([])
shippingService.setShippingRates([]);
errorProcessor.process(response);
}
).always(
function () {
Expand Down
Loading

0 comments on commit e5376c1

Please sign in to comment.