Skip to content
Snippets Groups Projects
Commit 685c343e authored by Stanislav Idolov's avatar Stanislav Idolov
Browse files

MAGETWO-38660: Provide ability to log-in during checkout

-- fixes after CR
parent de648148
Branches
No related merge requests found
......@@ -159,4 +159,14 @@ class Sidebar extends AbstractCart
{
return $this->getUrl('customer/account/forgotpassword');
}
/**
* Return base url.
*
* @return string
*/
public function getBaseUrl()
{
return $this->_storeManager->getStore()->getBaseUrl();
}
}
......@@ -49,23 +49,20 @@
removeItemUrl: '<?=$block->getRemoveItemUrl()?>',
imageTemplate: '<?= $block->getImageHtmlTemplate()?>',
customerRegisterUrl: '<?= $block->getCustomerRegisterUrlUrl()?>',
customerForgotPasswordUrl: '<?= $block->getCustomerForgotPasswordUrl()?>'
customerForgotPasswordUrl: '<?= $block->getCustomerForgotPasswordUrl()?>',
baseUrl: '<?= $block->getBaseUrl()?>'
};
</script>
<script type="text/x-magento-init">
{
"[data-block='minicart']": {
"Magento_Ui/js/core/app": <?php echo $block->getJsLayout();?>
},
"*": {
"Magento_Ui/js/block-loader": "<?php echo $block->getViewFileUrl('images/loader-1.gif'); ?>"
}
}
</script>
<script>
require([
'Magento_Ui/js/block-loader'
], function(blockLoader) {
blockLoader("<?php echo $block->getViewFileUrl('images/loader-1.gif'); ?>");
})
</script>
</div>
......@@ -10,31 +10,9 @@
<button type="button"
data-role="proceed-to-checkout"
title="<?php echo __('Proceed to Checkout') ?>"
data-mage-init='{"Magento_Checkout/js/proceed-to-checkout":{}}'
class="action primary checkout<?php echo($block->isDisabled()) ? ' disabled' : ''; ?>"
<?php if ($block->isDisabled()):?>disabled="disabled"<?php endif; ?>>
<span><?php echo __('Proceed to Checkout') ?></span>
</button>
<script>
require(
[
'jquery',
'Magento_Checkout/js/model/cart/authentication-popup',
'Magento_Customer/js/customer-data'
],
function($, authenticationPopup, customerData) {
$('button[data-role="proceed-to-checkout"]').click(function(event) {
event.preventDefault();
var cart = customerData.get('cart'),
customer = customerData.get('customer');
if (customer() == false && !cart().isGuestCheckoutAllowed) {
authenticationPopup.showModal();
return false;
}
location.href = window.checkout.checkoutUrl;
});
}
);
</script>
<?php endif?>
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'jquery',
'Magento_Checkout/js/model/cart/authentication-popup',
'Magento_Customer/js/customer-data'
],
function($, authenticationPopup, customerData) {
return function (config, element) {
$(element).click(function(event) {
event.preventDefault();
var cart = customerData.get('cart'),
customer = customerData.get('customer');
if (customer() == false && !cart().isGuestCheckoutAllowed) {
authenticationPopup.showModal();
return false;
}
location.href = window.checkout.checkoutUrl;
});
};
}
);
......@@ -6,11 +6,13 @@ define([
'uiComponent',
'Magento_Customer/js/customer-data',
'jquery',
'ko'
], function (Component, customerData, $, ko) {
'ko',
'mage/url'
], function (Component, customerData, $, ko, url) {
'use strict';
var sidebarInitialized = false;
url.setBaseUrl(window.checkout.baseUrl);
function initSidebar() {
var minicart = $("[data-block='minicart']");
......
......@@ -15,7 +15,7 @@ define(
var callbacks = [],
action = function(loginData, redirectUrl) {
return storage.post(
'/customer/ajax/login',
'customer/ajax/login',
JSON.stringify(loginData)
).done(function (response) {
if (response.errors) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment