Commit fbe4a95e by lmf

checkout页面错位临时保存

parent eeb4c96e
......@@ -121,7 +121,7 @@ Login,Login
"See Details","See Details"
"Options Details","Options Details"
Remove,Remove
"Cart Subtotal","Cart Subtotal"
"Cart Subtotal","Subtotal"
"Payment Information","Payment Information"
"No Payment method available.","No Payment method available."
"You can track your order status by creating an account.","You can track your order status by creating an account."
......@@ -132,7 +132,7 @@ Remove,Remove
"Ship To:","Ship To:"
edit,edit
"Order Summary","Order Summary"
"View and Edit Cart","View and Edit Cart"
"View and Edit Cart","View Cart"
"View Details","View Details"
"Field ","Field "
" is required."," is required."
......@@ -180,8 +180,8 @@ Payment,Payment
"Thank you for your purchase!","Thank you for your purchase!"
"Password", "Password"
"Something went wrong while saving the page. Please refresh the page and try again.","Something went wrong while saving the page. Please refresh the page and try again."
"Item in Cart","Item in Cart"
"Items in Cart","Items in Cart"
"Item in Cart","Item"
"Items in Cart","Items"
"Close","Close"
"Show Cross-sell Items in the Shopping Cart","Show Cross-sell Items in the Shopping Cart"
"You added %1 to your <a href=""%2"">shopping cart</a>.","You added %1 to your <a href=""%2"">shopping cart</a>."
......
{
"name": "magento/module-paypal",
"description": "N/A",
"type": "magento2-module",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"config": {
"sort-packages": true
},
"version": "101.0.3",
"require": {
"php": "~7.3.0||~7.4.0",
"lib-libxml": "*",
"magento/framework": "*",
"magento/module-authorization": "*",
"magento/module-backend": "*",
"magento/module-catalog": "*",
"magento/module-checkout": "*",
"magento/module-config": "*",
"magento/module-customer": "*",
"magento/module-directory": "*",
"magento/module-eav": "*",
"magento/module-instant-purchase": "*",
"magento/module-payment": "*",
"magento/module-quote": "*",
"magento/module-sales": "*",
"magento/module-store": "*",
"magento/module-tax": "*",
"magento/module-theme": "*",
"magento/module-ui": "*",
"magento/module-vault": "*"
"magento/framework": "103.0.*",
"magento/module-authorization": "100.4.*",
"magento/module-backend": "102.0.*",
"magento/module-catalog": "104.0.*",
"magento/module-checkout": "100.4.*",
"magento/module-config": "101.2.*",
"magento/module-customer": "103.0.*",
"magento/module-directory": "100.4.*",
"magento/module-eav": "102.1.*",
"magento/module-instant-purchase": "100.4.*",
"magento/module-payment": "100.4.*",
"magento/module-quote": "101.2.*",
"magento/module-sales": "103.0.*",
"magento/module-store": "101.1.*",
"magento/module-tax": "100.4.*",
"magento/module-theme": "101.1.*",
"magento/module-ui": "101.2.*",
"magento/module-vault": "101.2.*"
},
"suggest": {
"magento/module-checkout-agreements": "*"
"magento/module-checkout-agreements": "100.4.*"
},
"type": "magento2-module",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"autoload": {
"files": [
"registration.php"
......@@ -43,3 +44,4 @@
}
}
}
......@@ -30,40 +30,16 @@ if ($block->getIsInCatalogProduct()) {
"shortcutContainerClass": "<?= /* @noEscape */ "." . $shortcutHtmlId ?>"
}
}'
>
<?php
if(strpos($block->escapeUrl($block->getImageUrl()),'checkout-logo-medium') !== false){
$imgsrc = $block->getViewFileUrl('Magento_Paypal::images/paypal-color.svg');
$class = 'checkout-logo-medium';
} else {
$imgsrc = $block->getViewFileUrl('Magento_Paypal::images/paypal-credit.png');
$class = 'paypal-credit';
}
?>
<div class="<?= $class ?>">
<input type="image" data-action="checkout-form-submit"
data-checkout-url="<?= $block->escapeUrl($block->getCheckoutUrl()) ?>"
src="<?= $imgsrc ?>"
alt="<?= $block->escapeHtml(__('Checkout with PayPal')) ?>"
title="<?= $block->escapeHtml(__('Checkout with PayPal')) ?>"/>
<?php if ($block->getAdditionalLinkImage()) : ?>
<?php $linkImage = $block->getAdditionalLinkImage(); ?>
<a href="<?= $block->escapeUrl($linkImage['href']) ?>">
<img src="<?= $block->escapeHtml($linkImage['src']) ?>" />
</a>
<?php endif; ?>
<div class="checkout-txt">Checkout</div>
</div>
<!-- <input type="image" data-action="checkout-form-submit"-->
<!-- data-checkout-url="--><?//= $block->escapeUrl($block->getCheckoutUrl()) ?><!--"-->
<!-- src="--><?//= $block->escapeUrl($block->getImageUrl()) ?><!--"-->
<!-- alt="--><?//= $block->escapeHtml(__('Checkout with PayPal')) ?><!--"-->
<!-- title="--><?//= $block->escapeHtml(__('Checkout with PayPal')) ?><!--"/>-->
<!-- --><?php //if ($block->getAdditionalLinkImage()) : ?>
<!-- --><?php //$linkImage = $block->getAdditionalLinkImage(); ?>
<!-- <a href="--><?//= $block->escapeUrl($linkImage['href']) ?><!--">-->
<!-- <img src="--><?//= $block->escapeHtml($linkImage['src']) ?><!--" />-->
<!-- </a>-->
<!-- --><?php //endif; ?>
>
<input type="image" data-action="checkout-form-submit"
data-checkout-url="<?= $block->escapeUrl($block->getCheckoutUrl()) ?>"
src="<?= $block->escapeUrl($block->getImageUrl()) ?>"
alt="<?= $block->escapeHtml(__('Checkout with PayPal')) ?>"
title="<?= $block->escapeHtml(__('Checkout with PayPal')) ?>"/>
<?php if ($block->getAdditionalLinkImage()) : ?>
<?php $linkImage = $block->getAdditionalLinkImage(); ?>
<a href="<?= $block->escapeUrl($linkImage['href']) ?>">
<img src="<?= $block->escapeHtml($linkImage['src']) ?>" />
</a>
<?php endif; ?>
</div>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 188 49"><path fill="#0070E0" d="M164.01 11.446l-4.012 25.207a.643.643 0 0 0 .642.746h4.748a.701.701 0 0 0 .698-.589l4.012-25.207a.643.643 0 0 0-.642-.746h-4.748a.692.692 0 0 0-.698.589zm-5.07 7.356h-4.505a.699.699 0 0 0-.697.588l-.149.928s-3.499-3.794-9.694-1.23c-3.554 1.468-5.26 4.501-5.986 6.723 0 0-2.304 6.753 2.907 10.47 0 0 4.832 3.575 10.273-.22l-.094.592a.644.644 0 0 0 .37.686c.085.04.178.06.272.06h4.508a.692.692 0 0 0 .698-.589l2.742-17.262a.632.632 0 0 0-.149-.521.643.643 0 0 0-.496-.226zm-6.629 9.54a5.005 5.005 0 0 1-1.715 3.095 5.073 5.073 0 0 1-3.345 1.203 4.602 4.602 0 0 1-1.416-.206c-1.945-.62-3.055-2.474-2.736-4.484a5.01 5.01 0 0 1 1.717-3.093 5.08 5.08 0 0 1 3.343-1.207 4.6 4.6 0 0 1 1.416.208c1.957.616 3.062 2.473 2.741 4.485h-.005zm-24.056.477c2.443 0 4.806-.868 6.662-2.446a10.147 10.147 0 0 0 3.456-6.158c.789-4.993-3.14-9.351-8.71-9.351h-8.973a.699.699 0 0 0-.697.589L115.98 36.66a.644.644 0 0 0 .37.686c.086.04.178.06.272.06h4.751a.699.699 0 0 0 .697-.589l1.178-7.402a.692.692 0 0 1 .698-.59l4.309-.006zm3.974-8.831c-.293 1.846-1.731 3.205-4.482 3.205h-3.517l1.068-6.713h3.454c2.844.005 3.77 1.67 3.477 3.513v-.005z"/><path fill="#003087" d="M110.567 19.23l-5.434 9.105-2.758-9.038a.694.694 0 0 0-.672-.495h-4.904a.526.526 0 0 0-.527.446.515.515 0 0 0 .025.247l4.942 15.224-4.47 7.174a.516.516 0 0 0 .18.728.527.527 0 0 0 .269.07h5.282a.876.876 0 0 0 .751-.42l13.804-22.667a.512.512 0 0 0 .011-.53.524.524 0 0 0-.463-.263h-5.28a.877.877 0 0 0-.756.419zm-16.548-.428H89.51a.7.7 0 0 0-.698.59l-.146.927s-3.502-3.794-9.697-1.23c-3.553 1.468-5.26 4.501-5.983 6.723 0 0-2.306 6.753 2.904 10.47 0 0 4.833 3.575 10.274-.22l-.094.592a.642.642 0 0 0 .37.686c.085.04.178.06.272.06h4.508a.701.701 0 0 0 .697-.589l2.743-17.262a.642.642 0 0 0-.37-.687.655.655 0 0 0-.272-.06zm-6.63 9.542a5.011 5.011 0 0 1-1.716 3.091 5.082 5.082 0 0 1-3.343 1.206 4.605 4.605 0 0 1-1.414-.206c-1.944-.62-3.053-2.474-2.734-4.485a5.011 5.011 0 0 1 1.723-3.098 5.082 5.082 0 0 1 3.353-1.201c.48-.005.959.065 1.417.208 1.937.616 3.04 2.472 2.72 4.485h-.005zm-24.055.476a10.284 10.284 0 0 0 6.656-2.449 10.144 10.144 0 0 0 3.452-6.156c.79-4.992-3.14-9.35-8.708-9.35H55.76a.7.7 0 0 0-.698.588l-4 25.2a.642.642 0 0 0 .37.687c.085.039.178.06.272.06h4.748a.7.7 0 0 0 .698-.59l1.176-7.402a.692.692 0 0 1 .698-.589h4.31zm3.974-8.832c-.293 1.846-1.73 3.205-4.481 3.205H59.31l1.066-6.713h3.454c2.845.005 3.77 1.671 3.478 3.513v-.005z"/><path fill="#001C64" d="M32.639 12.16c.107-5.566-4.484-9.836-10.797-9.836H8.784a1.277 1.277 0 0 0-1.262 1.078L2.29 36.095a1.038 1.038 0 0 0 1.025 1.2h7.736l-1.209 7.57a1.038 1.038 0 0 0 1.025 1.2h6.302c.304 0 .575-.109.807-.306.23-.198.268-.471.316-.772l1.85-10.884c.047-.3.2-.69.431-.888.231-.198.433-.306.738-.306h3.856c6.183 0 11.428-4.395 12.387-10.507.679-4.338-1.181-8.286-4.915-10.243z"/><path fill="#0070E0" d="M12.725 25.238l-1.927 12.218-1.21 7.664a1.038 1.038 0 0 0 1.026 1.199h6.67a1.276 1.276 0 0 0 1.26-1.078l1.758-11.139a1.277 1.277 0 0 1 1.261-1.078h3.926c6.183 0 11.428-4.51 12.388-10.622.68-4.338-1.504-8.286-5.238-10.243-.01.462-.05.923-.121 1.38-.959 6.11-6.206 10.621-12.387 10.621h-6.145a1.278 1.278 0 0 0-1.261 1.079"/><path fill="#003087" d="M10.797 37.456h-7.76a1.037 1.037 0 0 1-1.024-1.2L7.245 3.078A1.277 1.277 0 0 1 8.506 2h13.336c6.313 0 10.904 4.594 10.797 10.159-1.571-.824-3.417-1.295-5.439-1.295H16.082a1.277 1.277 0 0 0-1.262 1.078l-2.094 13.296-1.93 12.218z"/></svg>
\ No newline at end of file
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="Magento\Cookie\Block\RequireCookie" name="require-cookie" template="Magento_Cookie::require_cookie.phtml">
<arguments>
<argument name="triggers" xsi:type="array">
<item name="addToCartLink" xsi:type="string">.action.tocart</item>
</argument>
</arguments>
</block>
</referenceContainer>
</body>
</page>
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="Magento\Cookie\Block\RequireCookie" name="require-cookie" template="Magento_Cookie::require_cookie.phtml">
<arguments>
<argument name="triggers" xsi:type="array">
<item name="addToCartLink" xsi:type="string">.action.tocart</item>
</argument>
</arguments>
</block>
</referenceContainer>
</body>
</page>
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<link src="Magento_Checkout::js/view/configure/product-customer-data.js"/>
</head>
<update handle="catalog_product_view"/>
<body>
<referenceBlock name="head.components">
<block class="Magento\Framework\View\Element\Js\Components" name="checkout_cart_configure_head_components" template="Magento_Checkout::js/components.phtml"/>
</referenceBlock>
<referenceBlock name="product.info">
<block class="Magento\Checkout\Block\Cart\Item\Configure" name="checkout.cart.item.configure.block"/>
</referenceBlock>
<referenceBlock name="product.info.addtocart">
<action method="setTemplate">
<argument name="template" xsi:type="string">Magento_Checkout::cart/item/configure/updatecart.phtml</argument>
</action>
</referenceBlock>
<referenceBlock name="product.info.addtocart.additional">
<action method="setTemplate">
<argument name="template" xsi:type="string">Magento_Checkout::cart/item/configure/updatecart.phtml</argument>
</action>
</referenceBlock>
</body>
</page>
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="catalog_product_view_type_simple"/>
<body/>
</page>
......@@ -8,8 +8,6 @@
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="checkout_cart_item_renderers"/>
<body>
<referenceBlock name="page.main.title" remove="true"/>
<referenceBlock name="checkout.cart.addtocart" remove="true" />
<referenceContainer name="page.messages">
<block class="Magento\Checkout\Block\Cart\ValidationMessages" name="checkout.cart.validationmessages"/>
</referenceContainer>
......
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="checkout_item_price_renderers"/>
<body>
<referenceBlock name="checkout.cart.item.renderers">
<block class="Magento\Checkout\Block\Cart\Item\Renderer" name="checkout.cart.item.renderers.default" as="default" template="Magento_Checkout::cart/item/default.phtml">
<block class="Magento\Checkout\Block\Cart\Item\Renderer\Actions" name="checkout.cart.item.renderers.default.actions" as="actions">
<block class="Magento\Checkout\Block\Cart\Item\Renderer\Actions\Edit" name="checkout.cart.item.renderers.default.actions.edit" template="Magento_Checkout::cart/item/renderer/actions/edit.phtml"/>
<block class="Magento\Checkout\Block\Cart\Item\Renderer\Actions\Remove" name="checkout.cart.item.renderers.default.actions.remove" template="Magento_Checkout::cart/item/renderer/actions/remove.phtml"/>
</block>
</block>
<block class="Magento\Checkout\Block\Cart\Item\Renderer" name="checkout.cart.item.renderers.simple" as="simple" template="Magento_Checkout::cart/item/default.phtml">
<block class="Magento\Checkout\Block\Cart\Item\Renderer\Actions" name="checkout.cart.item.renderers.simple.actions" as="actions">
<block class="Magento\Checkout\Block\Cart\Item\Renderer\Actions\Edit" name="checkout.cart.item.renderers.simple.actions.edit" template="Magento_Checkout::cart/item/renderer/actions/edit.phtml"/>
<block class="Magento\Checkout\Block\Cart\Item\Renderer\Actions\Remove" name="checkout.cart.item.renderers.simple.actions.remove" template="Magento_Checkout::cart/item/renderer/actions/remove.phtml"/>
</block>
</block>
</referenceBlock>
</body>
</page>
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="minicart">
<block class="Magento\Checkout\Block\Item\Price\Renderer" name="checkout.cart.item.price.sidebar" template="Magento_Checkout::cart/item/price/sidebar.phtml"/>
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="minicart_content" xsi:type="array">
<item name="children" xsi:type="array">
<item name="item.renderer" xsi:type="array">
<item name="children" xsi:type="array">
<item name="checkout.cart.item.price.sidebar" xsi:type="array">
<item name="component" xsi:type="string">uiComponent</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">Magento_Checkout/minicart/item/price</item>
<item name="displayArea" xsi:type="string">priceSidebar</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</argument>
</arguments>
</referenceBlock>
</body>
</page>
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="minicart">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="minicart_content" xsi:type="array">
<item name="config" xsi:type="array">
<item name="itemRenderer" xsi:type="array">
<item name="default" xsi:type="string">defaultRenderer</item>
<item name="simple" xsi:type="string">defaultRenderer</item>
<item name="virtual" xsi:type="string">defaultRenderer</item>
</item>
</item>
<item name="children" xsi:type="array">
<item name="item.renderer" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/cart-item-renderer</item>
<item name="config" xsi:type="array">
<item name="displayArea" xsi:type="string">defaultRenderer</item>
<item name="template" xsi:type="string">Magento_Checkout/minicart/item/default</item>
</item>
<item name="children" xsi:type="array">
<item name="item.image" xsi:type="array">
<item name="component" xsi:type="string">Magento_Catalog/js/view/image</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">Magento_Catalog/product/image</item>
<item name="displayArea" xsi:type="string">itemImage</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</argument>
</arguments>
</referenceBlock>
</body>
</page>
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="minicart">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="minicart_content" xsi:type="array">
<item name="children" xsi:type="array">
<item name="subtotal.container" xsi:type="array">
<item name="children" xsi:type="array">
<item name="subtotal" xsi:type="array">
<item name="children" xsi:type="array">
<item name="subtotal.totals" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/checkout/minicart/subtotal/totals</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">Magento_Checkout/minicart/subtotal/totals</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</argument>
</arguments>
</referenceBlock>
</body>
</page>
......@@ -7,7 +7,6 @@
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="checkout" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="page.bottom.container" remove="true"/>
<referenceContainer name="content">
<block class="Magento\Checkout\Block\Onepage" name="checkout.root" template="Magento_Checkout::onepage.phtml" cacheable="false">
<arguments>
......@@ -210,7 +209,6 @@
</item>
</item>
<item name="company" xsi:type="array">
<item name="visible" xsi:type="boolean">false</item>
<item name="validation" xsi:type="array">
<item name="min_text_length" xsi:type="number">0</item>
</item>
......
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<block class="Magento\Checkout\Block\Item\Price\Renderer" name="checkout.item.price.unit" template="Magento_Checkout::item/price/unit.phtml"/>
<block class="Magento\Checkout\Block\Item\Price\Renderer" name="checkout.item.price.row" template="Magento_Checkout::item/price/row.phtml"/>
<block class="Magento\Checkout\Block\Item\Price\Renderer" name="checkout.onepage.review.item.price.unit.excl" template="Magento_Checkout::onepage/review/item/price/unit_excl_tax.phtml"/>
<block class="Magento\Checkout\Block\Item\Price\Renderer" name="checkout.onepage.review.item.price.unit.incl" template="Magento_Checkout::onepage/review/item/price/unit_incl_tax.phtml"/>
<block class="Magento\Checkout\Block\Item\Price\Renderer" name="checkout.onepage.review.item.price.rowtotal.excl" template="Magento_Checkout::onepage/review/item/price/row_excl_tax.phtml"/>
<block class="Magento\Checkout\Block\Item\Price\Renderer" name="checkout.onepage.review.item.price.rowtotal.incl" template="Magento_Checkout::onepage/review/item/price/row_incl_tax.phtml"/>
</body>
</page>
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="page.main.title">
<action method="setPageTitle">
<argument translate="true" name="title" xsi:type="string">The order was not successful!</argument>
</action>
</referenceBlock>
<referenceContainer name="content">
<block class="Magento\Checkout\Block\Onepage\Failure" name="checkout.failure" template="Magento_Checkout::onepage/failure.phtml"/>
</referenceContainer>
</body>
</page>
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="checkout_item_price_renderers"/>
<body>
<referenceBlock name="checkout.onepage.review.item.renderers">
<block class="Magento\Checkout\Block\Cart\Item\Renderer" name="checkout.onepage.review.item.renderers.default" as="default" template="Magento_Checkout::onepage/review/item.phtml"/>
</referenceBlock>
</body>
</page>
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<title>Success Page</title>
</head>
<body>
<referenceBlock name="page.main.title">
<block class="Magento\Checkout\Block\Onepage\Success" name="checkout.success.print.button" template="Magento_Checkout::button.phtml"/>
<action method="setPageTitle">
<argument translate="true" name="title" xsi:type="string">Thank you for your purchase!</argument>
</action>
</referenceBlock>
<referenceContainer name="content">
<block class="Magento\Checkout\Block\Onepage\Success" name="checkout.success" template="Magento_Checkout::success.phtml" cacheable="false">
<container name="order.success.additional.info" label="Order Success Additional Info"/>
</block>
<block class="Magento\Checkout\Block\Registration" name="checkout.registration" template="Magento_Checkout::registration.phtml" cacheable="false"/>
</referenceContainer>
</body>
</page>
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="checkout_cart_sidebar_item_renderers"/>
<update handle="checkout_cart_sidebar_item_price_renderers"/>
<update handle="checkout_cart_sidebar_total_renderers"/>
<body>
<referenceBlock name="head.components">
<block class="Magento\Framework\View\Element\Js\Components" name="checkout_page_head_components" template="Magento_Checkout::js/components.phtml"/>
</referenceBlock>
<referenceContainer name="header-wrapper">
<block class="Magento\Checkout\Block\Cart\Sidebar" name="minicart" as="minicart" after="logo" template="Magento_Checkout::cart/minicart.phtml">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="types" xsi:type="array"/>
<item name="components" xsi:type="array">
<item name="minicart_content" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/minicart</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">Magento_Checkout/minicart/content</item>
</item>
<item name="children" xsi:type="array">
<item name="subtotal.container" xsi:type="array">
<item name="component" xsi:type="string">uiComponent</item>
<item name="config" xsi:type="array">
<item name="displayArea" xsi:type="string">subtotalContainer</item>
</item>
<item name="children" xsi:type="array">
<item name="subtotal" xsi:type="array">
<item name="component" xsi:type="string">uiComponent</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">Magento_Checkout/minicart/subtotal</item>
</item>
</item>
</item>
</item>
<item name="extra_info" xsi:type="array">
<item name="component" xsi:type="string">uiComponent</item>
<item name="config" xsi:type="array">
<item name="displayArea" xsi:type="string">extraInfo</item>
</item>
</item>
<item name="promotion" xsi:type="array">
<item name="component" xsi:type="string">uiComponent</item>
<item name="config" xsi:type="array">
<item name="displayArea" xsi:type="string">promotion</item>
</item>
</item>
</item>
</item>
</item>
</argument>
</arguments>
<container name="minicart.addons" label="Mini-cart promotion block"/>
</block>
</referenceContainer>
</body>
</page>
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
?>
<?php /** @var $block \Magento\Checkout\Block\Onepage\Success */ ?>
<?php if ($block->getCanViewOrder() && $block->getCanPrintOrder()) :?>
<a href="<?= $block->escapeUrl($block->getPrintUrl()) ?>"
class="action print"
target="_blank"
rel="noopener">
<?= $block->escapeHtml(__('Print receipt')) ?>
</a>
<?= $block->getChildHtml() ?>
<?php endif;?>
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
?>
<?php
/**
* Shopping cart template
*
* @var $block \Magento\Checkout\Block\Cart
*/
if ($block->getItemsCount()) {
// phpcs:ignore Magento2.Security.LanguageConstruct.DirectOutput
echo $block->getChildHtml('with-items');
} else {
// phpcs:ignore Magento2.Security.LanguageConstruct.DirectOutput
echo $block->getChildHtml('no-items');
}
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
?>
<?php
/**
* Shopping cart additional info
* @var $block \Magento\Framework\View\Element\Template
*/
?>
<?php
$name = $block->getNameInLayout();
foreach ($block->getChildNames($name) as $childName) {
// phpcs:ignore Magento2.Security.LanguageConstruct.DirectOutput
echo $block->getChildBlock($childName)->setItem($block->getItem())->toHtml();
}
?>
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* @var \Magento\Framework\View\Element\AbstractBlock $block
*/
// We should use strlen function because coupon code could be "0", converted to bool will lead to false
$hasCouponCode = (bool) strlen($block->getCouponCode());
?>
<div class="block discount"
id="block-discount"
data-mage-init='{"collapsible":{"active": <?= $hasCouponCode ? 'true' : 'false' ?>, "openedState": "active", "saveState": false}}'
>
<div class="title" data-role="title">
<strong id="block-discount-heading" role="heading" aria-level="2"><?= $block->escapeHtml(__('Apply Discount Code')) ?></strong>
</div>
<div class="content" data-role="content" aria-labelledby="block-discount-heading">
<form id="discount-coupon-form"
action="<?= $block->escapeUrl($block->getUrl('checkout/cart/couponPost')) ?>"
method="post"
data-mage-init='{"discountCode":{"couponCodeSelector": "#coupon_code",
"removeCouponSelector": "#remove-coupon",
"applyButton": "button.action.apply",
"cancelButton": "button.action.cancel"}}'>
<div class="fieldset coupon<?= $hasCouponCode ? ' applied' : '' ?>">
<input type="hidden" name="remove" id="remove-coupon" value="0" />
<div class="field">
<label for="coupon_code" class="label"><span><?= $block->escapeHtml(__('Enter discount code')) ?></span></label>
<div class="control">
<input type="text"
class="input-text"
id="coupon_code"
name="coupon_code"
value="<?= $block->escapeHtmlAttr($block->getCouponCode()) ?>"
placeholder="<?= $block->escapeHtmlAttr(__('Enter discount code')) ?>"
<?php if ($hasCouponCode) :?>
disabled="disabled"
<?php endif; ?>
/>
</div>
</div>
<div class="actions-toolbar">
<?php if (!$hasCouponCode) :?>
<div class="primary">
<button class="action apply primary" type="button" value="<?= $block->escapeHtmlAttr(__('Apply Discount')) ?>">
<span><?= $block->escapeHtml(__('Apply Discount')) ?></span>
</button>
</div>
<?php else :?>
<div class="primary">
<button type="button" class="action cancel primary" value="<?= $block->escapeHtmlAttr(__('Cancel Coupon')) ?>"><span><?= $block->escapeHtml(__('Cancel Coupon')) ?></span></button>
</div>
<?php endif; ?>
</div>
</div>
<?php if (!$hasCouponCode) : ?>
<?= /* @noEscape */ $block->getChildHtml('captcha') ?>
<?php endif; ?>
</form>
</div>
</div>
......@@ -25,11 +25,6 @@
data-attribute="cart-products-toolbar-top"><?= $block->getPagerHtml() ?>
</div>
<?php endif ?>
<div class="page-title-wrapper">
<h2 class="page-title">
<?= $block->escapeHtml(__('Shopping Cart Items')) ?>
</h2>
</div>
<table id="shopping-cart-table"
class="cart items data table"
data-mage-init='{"shoppingCart":{"emptyCartButton": ".action.clear",
......
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/** @var $block \Magento\Catalog\Block\Product\View */
?>
<?php $_product = $block->getProduct(); ?>
<?php $buttonTitle = __('Update Cart'); ?>
<?php if ($_product->isSaleable()) :?>
<div class="box-tocart update">
<fieldset class="fieldset">
<?php if ($block->shouldRenderQuantity()) :?>
<div class="field qty">
<label class="label" for="qty"><span><?= $block->escapeHtml(__('Qty')) ?></span></label>
<div class="control">
<input type="number"
name="qty"
id="qty"
min="0"
value=""
title="<?= $block->escapeHtmlAttr(__('Qty')) ?>"
class="input-text qty"
data-validate="<?= $block->escapeHtml(json_encode($block->getQuantityValidators())) ?>"/>
</div>
</div>
<?php endif; ?>
<div class="actions">
<button type="submit"
title="<?= $block->escapeHtmlAttr($buttonTitle) ?>"
class="action primary tocart"
id="product-updatecart-button">
<span><?= $block->escapeHtml($buttonTitle) ?></span>
</button>
<?= $block->getChildHtml('', true) ?>
</div>
</fieldset>
</div>
<script type="text/x-magento-init">
{
"#product_addtocart_form": {
"validation": {},
"addToCart": {
"cartButtonId": "#product-updatecart-button",
"cartForm": "#product_addtocart_form"
}
}
}
</script>
<?php endif; ?>
......@@ -42,21 +42,19 @@ $canApplyMsrp = $helper->isShowBeforeOrderConfirm($product) && $helper->isMinima
<?php endif; ?>
</strong>
<?php if ($_options = $block->getOptionList()) :?>
<div class="item-options">
<?php
foreach ($_options as $k=>$_option) :
?>
<dl class="item-options">
<?php foreach ($_options as $_option) :?>
<?php $_formatedOptionValue = $block->getFormatedOptionValue($_option) ?>
<div>
<?= $block->escapeHtml($_option['label']) ?>:
<dt><?= $block->escapeHtml($_option['label']) ?></dt>
<dd>
<?php if (isset($_formatedOptionValue['full_view'])) :?>
<?= $block->escapeHtml($_formatedOptionValue['full_view']) ?>
<?php else :?>
<?= $block->escapeHtml($_formatedOptionValue['full_view']) ?>
<?php else :?>
<?= $block->escapeHtml($_formatedOptionValue['value'], ['span', 'a']) ?>
<?php endif; ?>
</div>
</dd>
<?php endforeach; ?>
</div>
</dl>
<?php endif;?>
<?php if ($messages = $block->getMessages()) :?>
<?php foreach ($messages as $message) :?>
......
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// phpcs:disable Magento2.Templates.ThisInTemplate
/** @var $block \Magento\Checkout\Block\Item\Price\Renderer */
?>
<?php $_item = $block->getItem() ?>
<div class="price-container">
<span class="price-label"><?= $block->escapeHtml(__('Price')) ?></span>
<span class="price-wrapper">
<?= $block->escapeHtml(
$this->helper(Magento\Checkout\Helper\Data::class)->formatPrice($_item->getCalculationPrice()),
['span']
) ?>
</span>
</div>
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/** @var $block \Magento\Checkout\Block\Cart\Item\Renderer\Actions\Edit */
?>
<?php if ($block->isProductVisibleInSiteVisibility()) :?>
<a class="action action-edit"
href="<?= $block->escapeUrl($block->getConfigureUrl()) ?>"
title="<?= $block->escapeHtmlAttr(__('Edit item parameters')) ?>">
<span><?= $block->escapeHtml(__('Edit')) ?></span>
</a>
<?php endif ?>
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/** @var $block \Magento\Checkout\Block\Cart\Item\Renderer\Actions\Remove */
?>
<a href="#"
title="<?= $block->escapeHtml(__('Remove item')) ?>"
class="action action-delete"
data-post='<?= /* @noEscape */ $block->getDeletePostJson() ?>'>
<span>
<?= $block->escapeHtml(__('Remove item')) ?>
</span>
</a>
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
?>
<?php
/** @var $block \Magento\Checkout\Block\Cart */
?>
<?php if (!$block->hasError()) :?>
<?php $methods = $block->getMethods('methods') ?: $block->getMethods('top_methods') ?>
<ul class="checkout methods items checkout-methods-items">
<?php foreach ($methods as $method) :?>
<?php $methodHtml = $block->getMethodHtml($method); ?>
<?php if (trim($methodHtml) !== '') :?>
<li class="item"><?= /* @noEscape */ $methodHtml ?></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/** @var $block \Magento\Checkout\Block\Cart\Sidebar */
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
?>
<div data-block="minicart" class="minicart-wrapper">
<a class="action showcart" href="<?= $block->escapeUrl($block->getShoppingCartUrl()) ?>"
data-bind="scope: 'minicart_content'">
<span class="text"><?= $block->escapeHtml(__('My Cart')) ?></span>
<span class="counter qty empty"
data-bind="css: { empty: !!getCartParam('summary_count') == false && !isLoading() },
blockLoader: isLoading">
<span class="counter-number"><!-- ko text: getCartParam('summary_count') --><!-- /ko --></span>
<span class="counter-label">
<!-- ko if: getCartParam('summary_count') -->
<!-- ko text: getCartParam('summary_count') --><!-- /ko -->
<!-- ko i18n: 'items' --><!-- /ko -->
<!-- /ko -->
</span>
</span>
</a>
<?php if ($block->getIsNeedToDisplaySideBar()):?>
<div class="block block-minicart"
data-role="dropdownDialog"
data-mage-init='{"dropdownDialog":{
"appendTo":"[data-block=minicart]",
"triggerTarget":".showcart",
"timeout": "2000",
"closeOnMouseLeave": false,
"closeOnEscape": true,
"triggerClass":"active",
"parentClass":"active",
"buttons":[]}}'>
<div id="minicart-content-wrapper" data-bind="scope: 'minicart_content'">
<!-- ko template: getTemplate() --><!-- /ko -->
</div>
<?= $block->getChildHtml('minicart.addons') ?>
</div>
<?php else: ?>
<?php $scriptString = <<<script
require(['jquery'], function ($) {
$('a.action.showcart').click(function() {
$(document.body).trigger('processStart');
});
});
script;
?>
<?= /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false); ?>
<?php endif ?>
<?= /* @noEscape */ $secureRenderer->renderTag('script', [], 'window.checkout = ' .
/* @noEscape */ $block->getSerializedConfig(), false); ?>
<script type="text/x-magento-init">
{
"[data-block='minicart']": {
"Magento_Ui/js/core/app": <?= /* @noEscape */ $block->getJsLayout() ?>
},
"*": {
"Magento_Ui/js/block-loader": "<?= $block->escapeJs(
$block->escapeUrl($block->getViewFileUrl('images/loader-1.gif'))
) ?>"
}
}
</script>
</div>
......@@ -8,9 +8,14 @@
?>
<div class="cart-empty">
<?= $block->getChildHtml('checkout_cart_empty_widget') ?>
<div class="empty-img"><img src="<?= $block->getViewFileUrl('Magento_Checkout::images/empty-cart.svg');?>" /></div>
<p><?= $block->escapeHtml(__('You have no items in your shopping cart.')) ?></p>
<p><a href="<?= $block->escapeUrl($block->getContinueShoppingUrl());?>">continue shopping>></a>
<p><?= $block->escapeHtml(
__(
'Click <a href="%1">here</a> to continue shopping.',
$block->escapeUrl($block->getContinueShoppingUrl())
),
['a']
) ?>
</p>
<?= $block->getChildHtml('shopping.cart.table.after') ?>
</div>
......
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
?>
<?php /** @var $block \Magento\Checkout\Block\Cart\Shipping */ ?>
<?php /** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */ ?>
<div id="block-shipping"
class="block shipping"
data-mage-init='{"collapsible":{"openedState": "active", "saveState": true}}'
>
<div class="title" data-role="title">
<strong id="block-shipping-heading" role="heading" aria-level="2">
<?= $block->getQuote()->isVirtual()
? $block->escapeHtml(__('Estimate Tax'))
: $block->escapeHtml(__('Estimate Shipping and Tax'))
?>
</strong>
</div>
<div id="block-summary"
data-bind="scope:'block-summary'"
class="content"
data-role="content"
aria-labelledby="block-shipping-heading"
>
<!-- ko template: getTemplate() --><!-- /ko -->
<script type="text/x-magento-init">
{
"#block-summary": {
"Magento_Ui/js/core/app": <?= /* @noEscape */ $block->getJsLayout() ?>
}
}
</script>
<?php $serializedCheckoutConfig = /* @noEscape */ $block->getSerializedCheckoutConfig();
$scriptString = <<<script
window.checkoutConfig = {$serializedCheckoutConfig};
window.customerData = window.checkoutConfig.customerData;
window.isCustomerLoggedIn = window.checkoutConfig.isCustomerLoggedIn;
require([
'mage/url',
'Magento_Ui/js/block-loader'
], function(url, blockLoader) {
blockLoader(
"{$block->escapeJs($block->escapeUrl($block->getViewFileUrl('images/loader-1.gif')))}"
);
return url.setBaseUrl('{$block->escapeJs($block->escapeUrl($block->getBaseUrl()))}');
})
script;
?>
<?= /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false) ?>
</div>
</div>
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
?>
<?php
/**
* Shopping cart totals template
* @var $block \Magento\Checkout\Block\Cart\Totals
*/
?>
<div id="cart-totals" class="cart-totals" data-bind="scope:'block-totals'">
<!-- ko template: getTemplate() --><!-- /ko -->
<script type="text/x-magento-init">
{
"#cart-totals": {
"Magento_Ui/js/core/app": <?= /* @noEscape */ $block->getJsLayout() ?>
}
}
</script>
</div>
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// phpcs:disable Magento2.Templates.ThisInTemplate
/** @var $block \Magento\Checkout\Block\Item\Price\Renderer */
$_item = $block->getItem();
?>
<span class="price-excluding-tax" data-label="<?= $block->escapeHtml(__('Excl. Tax')) ?>">
<span class="cart-price">
<?= $block->escapeHtml(
$this->helper(Magento\Checkout\Helper\Data::class)->formatPrice($_item->getRowTotal()),
['span']
) ?>
</span>
</span>
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// phpcs:disable Magento2.Templates.ThisInTemplate
/** @var $block \Magento\Checkout\Block\Item\Price\Renderer */
$_item = $block->getItem();
?>
<span class="price-including-tax" data-label="<?= $block->escapeHtml(__('Excl. Tax')) ?>">
<span class="cart-price">
<?= $block->escapeHtml(
$this->helper(Magento\Checkout\Helper\Data::class)->formatPrice($_item->getCalculationPrice()),
['span']
) ?>
</span>
</span>
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
?>
<?= $block->getChildHtml() ?>
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/** @var \Magento\Framework\View\Element\Template $block */
?>
<?= $block->escapeHtml(__(
'You added %1 to your <a href="%2">shopping cart</a>.',
$block->getData('product_name'),
$block->getData('cart_url')
), ['a']);
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<!-- ko foreach: getRegion('progressBar') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
<!-- ko foreach: getRegion('authentication') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
<!-- ko foreach: getRegion('estimation') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
<!-- ko foreach: getRegion('messages') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
<div class="opc-wrapper">
<ol class="opc" id="checkoutSteps">
<!-- ko foreach: getRegion('steps') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</ol>
</div>
<!-- ko foreach: getRegion('sidebar') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/** @var $block \Magento\Checkout\Block\Onepage\Failure */
?>
<?php if ($block->getRealOrderId()) :?>
<p><?= $block->escapeHtml(__('Order #') . $block->getRealOrderId()) ?></p>
<?php endif ?>
<?php if ($error = $block->getErrorMessage()) :?>
<p><?= $block->escapeHtml($error) ?></p>
<?php endif ?>
<p><?= $block->escapeHtml(
__('Click <a href="%1">here</a> to continue shopping.', $block->escapeUrl($block->getContinueShoppingUrl())),
['a']
) ?>
</p>
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Checkout\Block\Onepage\Link;
use Magento\Framework\Escaper;
/**
* @var Link $block
* @var Escaper $escaper
*/
?>
<?php if ($block->isPossibleOnepageCheckout()): ?>
<button type="button"
data-role="proceed-to-checkout"
title="<?= $escaper->escapeHtmlAttr(__('Proceed to Checkout')) ?>"
data-mage-init='{
"Magento_Checkout/js/proceed-to-checkout":{
"checkoutUrl":"<?= $escaper->escapeJs($block->getCheckoutUrl()) ?>"
}
}'
class="action primary checkout<?= ($block->isDisabled()) ? ' disabled' : '' ?>"
<?php if ($block->isDisabled()): ?>
disabled="disabled"
<?php endif; ?>>
<span><?= $escaper->escapeHtml(__('Proceed to Checkout')) ?></span>
</button>
<?php endif?>
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// phpcs:disable Magento2.Templates.ThisInTemplate
/** @var $block Magento\Checkout\Block\Cart\Item\Renderer */
$_item = $block->getItem();
$taxDataHelper = $this->helper(Magento\Tax\Helper\Data::class);
?>
<tbody class="cart item">
<tr>
<td class="col item" data-th="<?= $block->escapeHtml(__('Product Name')) ?>">
<span class="product-item-photo">
<?= $block->getImage($block->getProductForThumbnail(), 'cart_page_product_thumbnail')->toHtml() ?>
</span>
<div class="product-item-details">
<strong class="product name product-item-name">
<?= $block->escapeHtml($block->getProductName()) ?>
</strong>
<?php if ($_options = $block->getOptionList()) :?>
<dl class="item-options">
<?php foreach ($_options as $_option) :?>
<?php $_formatedOptionValue = $block->getFormatedOptionValue($_option) ?>
<dt><?= $block->escapeHtml($_option['label']) ?></dt>
<dd>
<?php if (isset($_formatedOptionValue['full_view'])) :?>
<?= /* @noEscape */ $_formatedOptionValue['full_view'] ?>
<?php else :?>
<?= /* @noEscape */ $_formatedOptionValue['value'] ?>
<?php endif; ?>
</dd>
<?php endforeach; ?>
</dl>
<?php endif;?>
<?php if ($addtInfoBlock = $block->getProductAdditionalInformationBlock()) :?>
<?= $addtInfoBlock->setItem($_item)->toHtml() ?>
<?php endif;?>
</div>
</td>
<td class="col price" data-th="<?= $block->escapeHtml(__('Price')) ?>">
<?php if ($taxDataHelper->displayCartPriceInclTax() || $taxDataHelper->displayCartBothPrices()) :?>
<span class="price-including-tax" data-label="<?= $block->escapeHtml(__('Incl. Tax')) ?>">
<?= $block->getUnitPriceInclTaxHtml($_item) ?>
</span>
<?php endif; ?>
<?php if ($taxDataHelper->displayCartPriceExclTax() || $taxDataHelper->displayCartBothPrices()) :?>
<span class="price-excluding-tax" data-label="<?= $block->escapeHtml(__('Excl. Tax')) ?>">
<?= $block->getUnitPriceExclTaxHtml($_item) ?>
</span>
<?php endif; ?>
</td>
<td class="col qty"
data-th="<?= $block->escapeHtml(__('Qty')) ?>"
>
<span class="qty"><?= $block->escapeHtml($_item->getQty()) ?></span>
</td>
<td class="col subtotal" data-th="<?= $block->escapeHtml(__('Subtotal')) ?>">
<?php if ($taxDataHelper->displayCartPriceInclTax() || $taxDataHelper->displayCartBothPrices()) :?>
<span class="price-including-tax" data-label="<?= $block->escapeHtml(__('Incl. Tax')) ?>">
<?= $block->getRowTotalInclTaxHtml($_item) ?>
</span>
<?php endif; ?>
<?php if ($taxDataHelper->displayCartPriceExclTax() || $taxDataHelper->displayCartBothPrices()) :?>
<span class="price-excluding-tax" data-label="<?= $block->escapeHtml(__('Excl. Tax')) ?>">
<?= $block->getRowTotalExclTaxHtml($_item) ?>
</span>
<?php endif; ?>
</td>
</tr>
</tbody>
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// phpcs:disable Magento2.Templates.ThisInTemplate
/** @var $block \Magento\Checkout\Block\Item\Price\Renderer */
$_item = $block->getItem();
?>
<span class="cart-price">
<?= $block->escapeHtml(
$this->helper(Magento\Checkout\Helper\Data::class)->formatPrice($_item->getRowTotal()),
['span']
) ?>
</span>
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// phpcs:disable Magento2.Templates.ThisInTemplate
/** @var $block \Magento\Checkout\Block\Item\Price\Renderer */
$_item = $block->getItem();
?>
<?php $_incl = $this->helper(Magento\Checkout\Helper\Data::class)->getSubtotalInclTax($_item); ?>
<span class="cart-price">
<?= $block->escapeHtml(
$this->helper(Magento\Checkout\Helper\Data::class)->formatPrice($_incl),
['span']
) ?>
</span>
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// phpcs:disable Magento2.Templates.ThisInTemplate.FoundThis
/** @var $block \Magento\Checkout\Block\Item\Price\Renderer */
$_item = $block->getItem();
?>
<span class="cart-price">
<?= $block->escapeHtml(
$this->helper(Magento\Checkout\Helper\Data::class)->formatPrice($_item->getCalculationPrice()),
['span']
) ?>
</span>
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// phpcs:disable Magento2.Templates.ThisInTemplate
/** @var $block \Magento\Checkout\Block\Item\Price\Renderer */
$_item = $block->getItem();
?>
<?php $_incl = $this->helper(Magento\Checkout\Helper\Data::class)->getPriceInclTax($_item); ?>
<span class="cart-price">
<?= $block->escapeHtml(
$this->helper(Magento\Checkout\Helper\Data::class)->formatPrice($_incl),
['span']
) ?>
</span>
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/** @var $block \Magento\Checkout\Block\Registration */
?>
<div id="registration" data-bind="scope:'registration'">
<br />
<!-- ko template: getTemplate() --><!-- /ko -->
<script type="text/x-magento-init">
{
"#registration": {
"Magento_Ui/js/core/app": {
"components": {
"registration": {
"component": "Magento_Checkout/js/view/registration",
"config": {
"registrationUrl":
"<?= $block->escapeJs($block->escapeUrl($block->getCreateAccountUrl())) ?>",
"email": "<?= $block->escapeJs($block->getEmailAddress()) ?>"
},
"children": {
"errors": {
"component": "Magento_Ui/js/view/messages",
"sortOrder": 0,
"displayArea": "messages",
"config": {
"autoHideTimeOut": -1
}
}
}
}
}
}
}
}
</script>
</div>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<li id="shipping" class="checkout-shipping-address" data-bind="fadeVisible: visible()">
<div class="step-title" translate="'Shipping Address'" data-role="title" />
<div id="checkout-step-shipping"
class="step-content"
data-role="content">
<each if="!quoteIsVirtual" args="getRegion('customer-email')" render="" />
<each args="getRegion('address-list')" render="" />
<each args="getRegion('address-list-additional-addresses')" render="" />
<!-- Address form pop up -->
<if args="!isFormInline">
<div class="new-address-popup">
<button type="button"
class="action action-show-popup"
click="showFormPopUp"
visible="!isNewAddressAdded()">
<span translate="'New Address'" />
</button>
</div>
<div id="opc-new-shipping-address"
visible="isFormPopUpVisible()"
render="shippingFormTemplate" />
</if>
<each args="getRegion('before-form')" render="" />
<!-- Inline address form -->
<render if="isFormInline" args="shippingFormTemplate" />
</div>
</li>
<!--Shipping method template-->
<li id="opc-shipping_method"
class="checkout-shipping-method"
data-bind="fadeVisible: visible(), blockLoader: isLoading"
role="presentation">
<div class="checkout-shipping-method">
<div class="step-title"
translate="'Shipping Methods'"
data-role="title" />
<each args="getRegion('before-shipping-method-form')" render="" />
<div id="checkout-step-shipping_method"
class="step-content"
data-role="content"
role="tabpanel"
aria-hidden="false">
<form id="co-shipping-method-form"
class="form methods-shipping"
if="rates().length"
submit="setShippingInformation"
novalidate="novalidate">
<render args="shippingMethodListTemplate"/>
<div id="onepage-checkout-shipping-method-additional-load">
<each args="getRegion('shippingAdditional')" render="" />
</div>
<div role="alert"
if="errorValidationMessage().length"
class="message notice">
<span text="errorValidationMessage()" />
</div>
<div class="actions-toolbar" id="shipping-method-buttons-container">
<div class="primary">
<button data-role="opc-continue" type="submit" class="button action continue primary">
<span translate="'Next'" />
</button>
</div>
</div>
</form>
<div class="no-quotes-block"
ifnot="rates().length > 0"
translate="'Sorry, no quotes are available for this order at this time'" />
</div>
</div>
</li>
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
?>
<?php /** @var $block \Magento\Checkout\Block\Shipping\Price */ ?>
<?php $shippingPrice = $block->getShippingPrice(); ?>
<?= $block->escapeHtml($shippingPrice) ?>
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
?>
<?php /** @var $block \Magento\Checkout\Block\Onepage\Success */ ?>
<div class="checkout-success">
<?php if ($block->getOrderId()) :?>
<?php if ($block->getCanViewOrder()) :?>
<p><?= $block->escapeHtml(__('Your order number is: %1.', sprintf('<a href="%s" class="order-number"><strong>%s</strong></a>', $block->escapeUrl($block->getViewOrderUrl()), $block->getOrderId())), ['a', 'strong']) ?></p>
<?php else :?>
<p><?= $block->escapeHtml(__('Your order # is: <span>%1</span>.', $block->getOrderId()), ['span']) ?></p>
<?php endif;?>
<p><?= $block->escapeHtml(__('We\'ll email you an order confirmation with details and tracking info.')) ?></p>
<?php endif;?>
<?= $block->getAdditionalInfoHtml() ?>
<div class="actions-toolbar">
<div class="primary">
<a class="action primary continue" href="<?= $block->escapeUrl($block->getContinueUrl()) ?>"><span><?= $block->escapeHtml(__('Continue Shopping')) ?></span></a>
</div>
</div>
</div>
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/** @var $block \Magento\Checkout\Block\Total\DefaultTotal */
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
?>
<?php
/** @var \Magento\Checkout\Helper\Data $checkoutHelper */
$checkoutHelper = $block->getData('checkoutHelper');
?>
<tr class="totals">
<th colspan="<?= $block->escapeHtmlAttr($block->getColspan()) ?>"
class="mark" scope="row">
<?php if ($block->getRenderingArea() == $block->getTotal()->getArea()):?>
<strong>
<?php endif; ?>
<?= $block->escapeHtml($block->getTotal()->getTitle()) ?>
<?php if ($block->getRenderingArea() == $block->getTotal()->getArea()):?>
</strong>
<?php endif; ?>
</th>
<td class="amount"
data-th="<?= $block->escapeHtmlAttr($block->getTotal()->getTitle()) ?>">
<?php if ($block->getRenderingArea() == $block->getTotal()->getArea()):?>
<strong>
<?php endif; ?>
<span>
<?= $block->escapeHtml(
$checkoutHelper->formatPrice($block->getTotal()->getValue()),
['span']
) ?>
</span>
<?php if ($block->getRenderingArea() == $block->getTotal()->getArea()):?>
</strong>
<?php endif; ?>
</td>
</tr>
<?php if ($block->getTotal()->getStyle()): ?>
<?= /* @noEscape */ $secureRenderer->renderStyleAsTag($block->getTotal()->getStyle(), 'tr.totals th.mark') ?>
<?= /* @noEscape */ $secureRenderer->renderStyleAsTag($block->getTotal()->getStyle(), 'tr.totals td.amount') ?>
<?php endif; ?>
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* @api
*/
define([
'Magento_Checkout/js/model/address-converter'
], function (addressConverter) {
'use strict';
return function (addressData) {
var address = addressConverter.formAddressDataToQuoteAddress(addressData);
/**
* Returns new customer billing address type.
*
* @returns {String}
*/
address.getType = function () {
return 'new-customer-billing-address';
};
return address;
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* @api
*/
define([
'Magento_Customer/js/model/address-list',
'Magento_Checkout/js/model/address-converter'
], function (addressList, addressConverter) {
'use strict';
return function (addressData) {
var address = addressConverter.formAddressDataToQuoteAddress(addressData),
isAddressUpdated = addressList().some(function (currentAddress, index, addresses) {
if (currentAddress.getKey() == address.getKey()) { //eslint-disable-line eqeqeq
addresses[index] = address;
return true;
}
return false;
});
if (!isAddressUpdated) {
addressList.push(address);
} else {
addressList.valueHasMutated();
}
return address;
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* @api
*/
define([
'jquery',
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/url-builder',
'mage/storage',
'Magento_Checkout/js/model/error-processor',
'Magento_Customer/js/model/customer',
'Magento_Checkout/js/model/payment/method-converter',
'Magento_Checkout/js/model/payment-service'
], function ($, quote, urlBuilder, storage, errorProcessor, customer, methodConverter, paymentService) {
'use strict';
return function (deferred, messageContainer) {
var serviceUrl;
deferred = deferred || $.Deferred();
/**
* Checkout for guest and registered customer.
*/
if (!customer.isLoggedIn()) {
serviceUrl = urlBuilder.createUrl('/guest-carts/:cartId/payment-information', {
cartId: quote.getQuoteId()
});
} else {
serviceUrl = urlBuilder.createUrl('/carts/mine/payment-information', {});
}
return storage.get(
serviceUrl, false
).done(function (response) {
quote.setTotals(response.totals);
paymentService.setPaymentMethods(methodConverter(response['payment_methods']));
deferred.resolve();
}).fail(function (response) {
errorProcessor.process(response, messageContainer);
deferred.reject();
});
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* @api
*/
define([
'jquery',
'../model/quote',
'Magento_Checkout/js/model/resource-url-manager',
'Magento_Checkout/js/model/error-processor',
'mage/storage',
'Magento_Checkout/js/model/totals'
], function ($, quote, resourceUrlManager, errorProcessor, storage, totals) {
'use strict';
return function (callbacks, deferred) {
deferred = deferred || $.Deferred();
totals.isLoading(true);
return storage.get(
resourceUrlManager.getUrlForCartTotals(quote),
false
).done(function (response) {
var proceed = true;
totals.isLoading(false);
if (callbacks.length > 0) {
$.each(callbacks, function (index, callback) {
proceed = proceed && callback();
});
}
if (proceed) {
quote.setTotals(response);
deferred.resolve();
}
}).fail(function (response) {
totals.isLoading(false);
deferred.reject();
errorProcessor.process(response);
}).always(function () {
totals.isLoading(false);
});
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* @api
*/
define([
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/url-builder',
'Magento_Customer/js/model/customer',
'Magento_Checkout/js/model/place-order'
], function (quote, urlBuilder, customer, placeOrderService) {
'use strict';
return function (paymentData, messageContainer) {
var serviceUrl, payload;
payload = {
cartId: quote.getQuoteId(),
billingAddress: quote.billingAddress(),
paymentMethod: paymentData
};
if (customer.isLoggedIn()) {
serviceUrl = urlBuilder.createUrl('/carts/mine/payment-information', {});
} else {
serviceUrl = urlBuilder.createUrl('/guest-carts/:quoteId/payment-information', {
quoteId: quote.getQuoteId()
});
payload.email = quote.guestEmail;
}
return placeOrderService(serviceUrl, payload, messageContainer);
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* @api
*/
define([
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/action/select-shipping-address',
'Magento_Checkout/js/model/shipping-rate-registry'
], function (quote, selectShippingAddress, rateRegistry) {
'use strict';
return function () {
var shippingAddress = null;
if (!quote.isVirtual()) {
shippingAddress = quote.shippingAddress();
rateRegistry.set(shippingAddress.getCacheKey(), null);
selectShippingAddress(shippingAddress);
}
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* @api
*/
define(
[
'mage/url',
'Magento_Checkout/js/model/full-screen-loader'
],
function (url, fullScreenLoader) {
'use strict';
return {
redirectUrl: window.checkoutConfig.defaultSuccessPageUrl,
/**
* Provide redirect to page
*/
execute: function () {
fullScreenLoader.startLoader();
window.location.replace(url.build(this.redirectUrl));
}
};
}
);
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* @api
*/
define([
'jquery',
'../model/quote'
], function ($, quote) {
'use strict';
return function (billingAddress) {
var address = null;
if (quote.shippingAddress() && billingAddress.getCacheKey() == //eslint-disable-line eqeqeq
quote.shippingAddress().getCacheKey()
) {
address = $.extend(true, {}, billingAddress);
address.saveInAddressBook = null;
} else {
address = billingAddress;
}
quote.billingAddress(address);
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* @api
*/
define([
'Magento_Checkout/js/model/quote'
], function (quote) {
'use strict';
return function (paymentMethod) {
if (paymentMethod) {
paymentMethod.__disableTmpl = {
title: true
};
}
quote.paymentMethod(paymentMethod);
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* @api
*/
define([
'Magento_Checkout/js/model/quote'
], function (quote) {
'use strict';
return function (shippingAddress) {
quote.shippingAddress(shippingAddress);
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* @api
*/
define([
'../model/quote'
], function (quote) {
'use strict';
return function (shippingMethod) {
quote.shippingMethod(shippingMethod);
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* @api
*/
define(
[
'jquery',
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/url-builder',
'mage/storage',
'Magento_Checkout/js/model/error-processor',
'Magento_Customer/js/model/customer',
'Magento_Checkout/js/model/full-screen-loader',
'Magento_Checkout/js/action/get-payment-information'
],
function ($,
quote,
urlBuilder,
storage,
errorProcessor,
customer,
fullScreenLoader,
getPaymentInformationAction
) {
'use strict';
return function (messageContainer) {
var serviceUrl,
payload;
/**
* Checkout for guest and registered customer.
*/
if (!customer.isLoggedIn()) {
serviceUrl = urlBuilder.createUrl('/guest-carts/:cartId/billing-address', {
cartId: quote.getQuoteId()
});
payload = {
cartId: quote.getQuoteId(),
address: quote.billingAddress()
};
} else {
serviceUrl = urlBuilder.createUrl('/carts/mine/billing-address', {});
payload = {
cartId: quote.getQuoteId(),
address: quote.billingAddress()
};
}
fullScreenLoader.startLoader();
return storage.post(
serviceUrl, JSON.stringify(payload)
).done(
function () {
var deferred = $.Deferred();
getPaymentInformationAction(deferred);
$.when(deferred).done(function () {
fullScreenLoader.stopLoader();
});
}
).fail(
function (response) {
errorProcessor.process(response, messageContainer);
fullScreenLoader.stopLoader();
}
);
};
}
);
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* @api
*/
define([
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/url-builder',
'mage/storage',
'Magento_Checkout/js/model/error-processor',
'Magento_Customer/js/model/customer',
'Magento_Checkout/js/action/get-totals',
'Magento_Checkout/js/model/full-screen-loader',
'underscore',
'Magento_Checkout/js/model/payment/place-order-hooks'
], function (quote, urlBuilder, storage, errorProcessor, customer, getTotalsAction, fullScreenLoader, _, hooks) {
'use strict';
/**
* Filter template data.
*
* @param {Object|Array} data
*/
var filterTemplateData = function (data) {
return _.each(data, function (value, key, list) {
if (_.isArray(value) || _.isObject(value)) {
list[key] = filterTemplateData(value);
}
if (key === '__disableTmpl' || key === 'title') {
delete list[key];
}
});
};
return function (messageContainer, paymentData, skipBilling) {
var serviceUrl,
payload,
headers = {};
paymentData = filterTemplateData(paymentData);
skipBilling = skipBilling || false;
payload = {
cartId: quote.getQuoteId(),
paymentMethod: paymentData
};
/**
* Checkout for guest and registered customer.
*/
if (!customer.isLoggedIn()) {
serviceUrl = urlBuilder.createUrl('/guest-carts/:cartId/set-payment-information', {
cartId: quote.getQuoteId()
});
payload.email = quote.guestEmail;
} else {
serviceUrl = urlBuilder.createUrl('/carts/mine/set-payment-information', {});
}
if (skipBilling === false) {
payload.billingAddress = quote.billingAddress();
}
fullScreenLoader.startLoader();
_.each(hooks.requestModifiers, function (modifier) {
modifier(headers, payload);
});
return storage.post(
serviceUrl, JSON.stringify(payload), true, 'application/json', headers
).fail(
function (response) {
errorProcessor.process(response, messageContainer);
}
).always(
function () {
fullScreenLoader.stopLoader();
_.each(hooks.afterRequestListeners, function (listener) {
listener();
});
}
);
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* @api
*/
define([
'Magento_Checkout/js/action/set-payment-information-extended'
], function (setPaymentInformationExtended) {
'use strict';
return function (messageContainer, paymentData) {
return setPaymentInformationExtended(messageContainer, paymentData, false);
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* @api
*/
define([
'../model/quote',
'Magento_Checkout/js/model/shipping-save-processor'
], function (quote, shippingSaveProcessor) {
'use strict';
return function () {
return shippingSaveProcessor.saveShippingInformation(quote.shippingAddress().getType());
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'Magento_Ui/js/modal/alert',
'jquery',
'jquery-ui-modules/widget',
'mage/validation'
], function (alert, $) {
'use strict';
$.widget('mage.updateShoppingCart', {
options: {
validationURL: '',
eventName: 'updateCartItemQty',
updateCartActionContainer: ''
},
/** @inheritdoc */
_create: function () {
this._on(this.element, {
'submit': this.onSubmit
});
},
/**
* Prevents default submit action and calls form validator.
*
* @param {Event} event
* @return {Boolean}
*/
onSubmit: function (event) {
var action = this.element.find(this.options.updateCartActionContainer).val();
if (!this.options.validationURL || action === 'empty_cart') {
return true;
}
if (this.isValid()) {
event.preventDefault();
this.validateItems(this.options.validationURL, this.element.serialize());
}
return false;
},
/**
* Validates requested form.
*
* @return {Boolean}
*/
isValid: function () {
return this.element.validation() && this.element.validation('isValid');
},
/**
* Validates updated shopping cart data.
*
* @param {String} url - request url
* @param {Object} data - post data for ajax call
*/
validateItems: function (url, data) {
$.extend(data, {
'form_key': $.mage.cookies.get('form_key')
});
$.ajax({
url: url,
data: data,
type: 'post',
dataType: 'json',
context: this,
/** @inheritdoc */
beforeSend: function () {
$(document.body).trigger('processStart');
},
/** @inheritdoc */
complete: function () {
$(document.body).trigger('processStop');
}
})
.done(function (response) {
if (response.success) {
this.onSuccess();
} else {
this.onError(response);
}
})
.fail(function () {
this.submitForm();
});
},
/**
* Form validation succeed.
*/
onSuccess: function () {
$(document).trigger('ajax:' + this.options.eventName);
this.submitForm();
},
/**
* Form validation failed.
*/
onError: function (response) {
if (response['error_message']) {
alert({
content: response['error_message']
});
} else {
this.submitForm();
}
},
/**
* Real submit of validated form.
*/
submitForm: function () {
this.element
.off('submit', this.onSubmit)
.on('submit', function () {
$(document.body).trigger('processStart');
})
.trigger('submit');
}
});
return $.mage.updateShoppingCart;
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* Checkout adapter for customer data storage
*
* @api
*/
define([
'jquery',
'Magento_Customer/js/customer-data',
'mageUtils',
'jquery/jquery-storageapi'
], function ($, storage, utils) {
'use strict';
var cacheKey = 'checkout-data',
/**
* @param {Object} data
*/
saveData = function (data) {
storage.set(cacheKey, data);
},
/**
* @return {*}
*/
initData = function () {
return {
'selectedShippingAddress': null, //Selected shipping address pulled from persistence storage
'shippingAddressFromData': null, //Shipping address pulled from persistence storage
'newCustomerShippingAddress': null, //Shipping address pulled from persistence storage for customer
'selectedShippingRate': null, //Shipping rate pulled from persistence storage
'selectedPaymentMethod': null, //Payment method pulled from persistence storage
'selectedBillingAddress': null, //Selected billing address pulled from persistence storage
'billingAddressFromData': null, //Billing address pulled from persistence storage
'newCustomerBillingAddress': null //Billing address pulled from persistence storage for new customer
};
},
/**
* @return {*}
*/
getData = function () {
var data = storage.get(cacheKey)();
if ($.isEmptyObject(data)) {
data = $.initNamespaceStorage('mage-cache-storage').localStorage.get(cacheKey);
if ($.isEmptyObject(data)) {
data = initData();
saveData(data);
}
}
return data;
};
return {
/**
* Setting the selected shipping address pulled from persistence storage
*
* @param {Object} data
*/
setSelectedShippingAddress: function (data) {
var obj = getData();
obj.selectedShippingAddress = data;
saveData(obj);
},
/**
* Pulling the selected shipping address from persistence storage
*
* @return {*}
*/
getSelectedShippingAddress: function () {
return getData().selectedShippingAddress;
},
/**
* Setting the shipping address pulled from persistence storage
*
* @param {Object} data
*/
setShippingAddressFromData: function (data) {
var obj = getData();
obj.shippingAddressFromData = utils.filterFormData(data);
saveData(obj);
},
/**
* Pulling the shipping address from persistence storage
*
* @return {*}
*/
getShippingAddressFromData: function () {
return getData().shippingAddressFromData;
},
/**
* Setting the shipping address pulled from persistence storage for new customer
*
* @param {Object} data
*/
setNewCustomerShippingAddress: function (data) {
var obj = getData();
obj.newCustomerShippingAddress = data;
saveData(obj);
},
/**
* Pulling the shipping address from persistence storage for new customer
*
* @return {*}
*/
getNewCustomerShippingAddress: function () {
return getData().newCustomerShippingAddress;
},
/**
* Setting the selected shipping rate pulled from persistence storage
*
* @param {Object} data
*/
setSelectedShippingRate: function (data) {
var obj = getData();
obj.selectedShippingRate = data;
saveData(obj);
},
/**
* Pulling the selected shipping rate from local storage
*
* @return {*}
*/
getSelectedShippingRate: function () {
return getData().selectedShippingRate;
},
/**
* Setting the selected payment method pulled from persistence storage
*
* @param {Object} data
*/
setSelectedPaymentMethod: function (data) {
var obj = getData();
obj.selectedPaymentMethod = data;
saveData(obj);
},
/**
* Pulling the payment method from persistence storage
*
* @return {*}
*/
getSelectedPaymentMethod: function () {
return getData().selectedPaymentMethod;
},
/**
* Setting the selected billing address pulled from persistence storage
*
* @param {Object} data
*/
setSelectedBillingAddress: function (data) {
var obj = getData();
obj.selectedBillingAddress = data;
saveData(obj);
},
/**
* Pulling the selected billing address from persistence storage
*
* @return {*}
*/
getSelectedBillingAddress: function () {
return getData().selectedBillingAddress;
},
/**
* Setting the billing address pulled from persistence storage
*
* @param {Object} data
*/
setBillingAddressFromData: function (data) {
var obj = getData();
obj.billingAddressFromData = utils.filterFormData(data);
saveData(obj);
},
/**
* Pulling the billing address from persistence storage
*
* @return {*}
*/
getBillingAddressFromData: function () {
return getData().billingAddressFromData;
},
/**
* Setting the billing address pulled from persistence storage for new customer
*
* @param {Object} data
*/
setNewCustomerBillingAddress: function (data) {
var obj = getData();
obj.newCustomerBillingAddress = data;
saveData(obj);
},
/**
* Pulling the billing address from persistence storage for new customer
*
* @return {*}
*/
getNewCustomerBillingAddress: function () {
return getData().newCustomerBillingAddress;
},
/**
* Pulling the email address from persistence storage
*
* @return {*}
*/
getValidatedEmailValue: function () {
var obj = getData();
return obj.validatedEmailValue ? obj.validatedEmailValue : '';
},
/**
* Setting the email address pulled from persistence storage
*
* @param {String} email
*/
setValidatedEmailValue: function (email) {
var obj = getData();
obj.validatedEmailValue = email;
saveData(obj);
},
/**
* Pulling the email input field value from persistence storage
*
* @return {*}
*/
getInputFieldEmailValue: function () {
var obj = getData();
return obj.inputFieldEmailValue ? obj.inputFieldEmailValue : '';
},
/**
* Setting the email input field value pulled from persistence storage
*
* @param {String} email
*/
setInputFieldEmailValue: function (email) {
var obj = getData();
obj.inputFieldEmailValue = email;
saveData(obj);
},
/**
* Pulling the checked email value from persistence storage
*
* @return {*}
*/
getCheckedEmailValue: function () {
var obj = getData();
return obj.checkedEmailValue ? obj.checkedEmailValue : '';
},
/**
* Setting the checked email value pulled from persistence storage
*
* @param {String} email
*/
setCheckedEmailValue: function (email) {
var obj = getData();
obj.checkedEmailValue = email;
saveData(obj);
}
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'rjsResolver'
], function (resolver) {
'use strict';
/**
* Removes provided loader element from DOM.
*
* @param {HTMLElement} $loader - Loader DOM element.
*/
function hideLoader($loader) {
$loader.parentNode.removeChild($loader);
}
/**
* Initializes assets loading process listener.
*
* @param {Object} config - Optional configuration
* @param {HTMLElement} $loader - Loader DOM element.
*/
function init(config, $loader) {
resolver(hideLoader.bind(null, $loader));
}
return init;
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'jquery',
'jquery-ui-modules/widget'
], function ($) {
'use strict';
$.widget('mage.discountCode', {
options: {
},
/** @inheritdoc */
_create: function () {
this.couponCode = $(this.options.couponCodeSelector);
this.removeCoupon = $(this.options.removeCouponSelector);
$(this.options.applyButton).on('click', $.proxy(function () {
this.couponCode.attr('data-validate', '{required:true}');
this.removeCoupon.attr('value', '0');
$(this.element).validation().trigger('submit');
}, this));
$(this.options.cancelButton).on('click', $.proxy(function () {
this.couponCode.removeAttr('data-validate');
this.removeCoupon.attr('value', '1');
this.element.trigger('submit');
}, this));
}
});
return $.mage.discountCode;
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define(['Magento_Customer/js/customer-data'], function (customerData) {
'use strict';
return function () {
var cartData = customerData.get('cart');
customerData.getInitCustomerData().done(function () {
if (cartData().items && cartData().items.length !== 0) {
customerData.reload(['cart'], false);
}
});
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* @api
*/
define([
'jquery',
'Magento_Checkout/js/model/new-customer-address',
'Magento_Customer/js/customer-data',
'mage/utils/objects',
'underscore'
], function ($, address, customerData, mageUtils, _) {
'use strict';
var countryData = customerData.get('directory-data');
return {
/**
* Convert address form data to Address object
*
* @param {Object} formData
* @returns {Object}
*/
formAddressDataToQuoteAddress: function (formData) {
// clone address form data to new object
var addressData = $.extend(true, {}, formData),
region,
regionName = addressData.region,
customAttributes;
if (mageUtils.isObject(addressData.street)) {
addressData.street = this.objectToArray(addressData.street);
}
addressData.region = {
'region_id': addressData['region_id'],
'region_code': addressData['region_code'],
region: regionName
};
if (addressData['region_id'] &&
countryData()[addressData['country_id']] &&
countryData()[addressData['country_id']].regions
) {
region = countryData()[addressData['country_id']].regions[addressData['region_id']];
if (region) {
addressData.region['region_id'] = addressData['region_id'];
addressData.region['region_code'] = region.code;
addressData.region.region = region.name;
}
} else if (
!addressData['region_id'] &&
countryData()[addressData['country_id']] &&
countryData()[addressData['country_id']].regions
) {
addressData.region['region_code'] = '';
addressData.region.region = '';
}
delete addressData['region_id'];
if (addressData['custom_attributes']) {
addressData['custom_attributes'] = _.map(
addressData['custom_attributes'],
function (value, key) {
customAttributes = {
'attribute_code': key,
'value': value
};
if (typeof value === 'boolean') {
customAttributes = {
'attribute_code': key,
'value': value,
'label': value === true ? 'Yes' : 'No'
};
}
return customAttributes;
}
);
}
return address(addressData);
},
/**
* Convert Address object to address form data.
*
* @param {Object} addrs
* @returns {Object}
*/
quoteAddressToFormAddressData: function (addrs) {
var self = this,
output = {},
streetObject,
customAttributesObject;
$.each(addrs, function (key) {
if (addrs.hasOwnProperty(key) && !$.isFunction(addrs[key])) {
output[self.toUnderscore(key)] = addrs[key];
}
});
if ($.isArray(addrs.street)) {
streetObject = {};
addrs.street.forEach(function (value, index) {
streetObject[index] = value;
});
output.street = streetObject;
}
//jscs:disable requireCamelCaseOrUpperCaseIdentifiers
if ($.isArray(addrs.customAttributes)) {
customAttributesObject = {};
addrs.customAttributes.forEach(function (value) {
customAttributesObject[value.attribute_code] = value.value;
});
output.custom_attributes = customAttributesObject;
}
//jscs:enable requireCamelCaseOrUpperCaseIdentifiers
return output;
},
/**
* @param {String} string
*/
toUnderscore: function (string) {
return string.replace(/([A-Z])/g, function ($1) {
return '_' + $1.toLowerCase();
});
},
/**
* @param {Object} formProviderData
* @param {String} formIndex
* @return {Object}
*/
formDataProviderToFlatData: function (formProviderData, formIndex) {
var addressData = {};
$.each(formProviderData, function (path, value) {
var pathComponents = path.split('.'),
dataObject = {};
pathComponents.splice(pathComponents.indexOf(formIndex), 1);
pathComponents.reverse();
$.each(pathComponents, function (index, pathPart) {
var parent = {};
if (index == 0) { //eslint-disable-line eqeqeq
dataObject[pathPart] = value;
} else {
parent[pathPart] = dataObject;
dataObject = parent;
}
});
$.extend(true, addressData, dataObject);
});
return addressData;
},
/**
* Convert object to array
* @param {Object} object
* @returns {Array}
*/
objectToArray: function (object) {
var convertedArray = [];
$.each(object, function (key) {
return typeof object[key] === 'string' ? convertedArray.push(object[key]) : false;
});
return convertedArray.slice(0);
},
/**
* @param {Object} addrs
* @return {*|Object}
*/
addressToEstimationAddress: function (addrs) {
var self = this,
estimatedAddressData = {};
$.each(addrs, function (key) {
estimatedAddressData[self.toUnderscore(key)] = addrs[key];
});
return this.formAddressDataToQuoteAddress(estimatedAddressData);
}
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'ko',
'Magento_Ui/js/model/messages'
], function (ko, Messages) {
'use strict';
return new Messages();
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'jquery',
'Magento_Checkout/js/model/postcode-validator',
'mage/translate',
'uiRegistry'
], function (
$,
postcodeValidator,
$t,
uiRegistry
) {
'use strict';
var postcodeElementName = 'postcode';
return {
validateZipCodeTimeout: 0,
validateDelay: 2000,
/**
* Perform postponed binding for fieldset elements
*
* @param {String} formPath
*/
initFields: function (formPath) {
var self = this;
uiRegistry.async(formPath + '.' + postcodeElementName)(self.bindHandler.bind(self));
},
/**
* @param {Object} element
* @param {Number} delay
*/
bindHandler: function (element, delay) {
var self = this;
delay = typeof delay === 'undefined' ? self.validateDelay : delay;
element.on('value', function () {
clearTimeout(self.validateZipCodeTimeout);
self.validateZipCodeTimeout = setTimeout(function () {
self.postcodeValidation(element);
}, delay);
});
},
/**
* @param {Object} postcodeElement
* @return {*}
*/
postcodeValidation: function (postcodeElement) {
var countryId = $('select[name="country_id"]:visible').val(),
validationResult,
warnMessage;
if (postcodeElement == null || postcodeElement.value() == null) {
return true;
}
postcodeElement.warn(null);
validationResult = postcodeValidator.validate(postcodeElement.value(), countryId);
if (!validationResult) {
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;
}
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* Cart adapter for customer data storage.
* It stores cart data in customer data(localStorage) without saving on server.
* Adapter is created for shipping rates and totals data caching. It eliminates unneeded calculations requests.
*/
define([
'underscore',
'Magento_Customer/js/customer-data',
'mageUtils'
], function (_, storage, utils) {
'use strict';
var cacheKey = 'cart-data',
cartData = {
totals: null,
address: null,
cartVersion: null,
shippingMethodCode: null,
shippingCarrierCode: null,
rates: null
},
/**
* Set data to local storage.
*
* @param {Object} checkoutData
*/
setData = function (checkoutData) {
storage.set(cacheKey, checkoutData);
},
/**
* Get data from local storage.
*
* @param {String} [key]
* @returns {*}
*/
getData = function (key) {
var data = key ? storage.get(cacheKey)()[key] : storage.get(cacheKey)();
if (_.isEmpty(storage.get(cacheKey)())) {
setData(utils.copy(cartData));
}
return data;
},
/**
* Build method name base on name, prefix and suffix.
*
* @param {String} name
* @param {String} prefix
* @param {String} suffix
* @return {String}
*/
getMethodName = function (name, prefix, suffix) {
prefix = prefix || '';
suffix = suffix || '';
return prefix + name.charAt(0).toUpperCase() + name.slice(1) + suffix;
};
/**
* Provides get/set/isChanged/clear methods for work with cart data.
* Can be customized via mixin functionality.
*/
return {
cartData: cartData,
/**
* Array of required address fields
*/
requiredFields: ['countryId', 'region', 'regionId', 'postcode'],
/**
* Get data from customer data.
* Concatenate provided key with method name and call method if it exist or makes get by key.
*
* @param {String} key
* @return {*}
*/
get: function (key) {
var methodName = getMethodName(key, '_get');
if (key === cacheKey) {
return getData();
}
if (this[methodName]) {
return this[methodName]();
}
return getData(key);
},
/**
* Set data to customer data.
* Concatenate provided key with method name and call method if it exist or makes set by key.
* @example _setCustomAddress method will be called, if it exists.
* set('address', customAddressValue)
* @example Will set value by provided key.
* set('rates', ratesToCompare)
*
* @param {String} key
* @param {*} value
*/
set: function (key, value) {
var methodName = getMethodName(key, '_set'),
obj;
if (key === cacheKey) {
_.each(value, function (val, k) {
this.set(k, val);
}, this);
return;
}
if (this[methodName]) {
this[methodName](value);
} else {
obj = getData();
obj[key] = value;
setData(obj);
}
},
/**
* Clear data in cache.
* Concatenate provided key with method name and call method if it exist or clear by key.
* @example _clearCustomAddress method will be called, if it exist.
* clear('customAddress')
* @example Will clear data by provided key.
* clear('rates')
*
* @param {String} key
*/
clear: function (key) {
var methodName = getMethodName(key, '_clear');
if (key === cacheKey) {
setData(this.cartData);
return;
}
if (this[methodName]) {
this[methodName]();
} else {
this.set(key, null);
}
},
/**
* Check if provided data has difference with cached data.
* Concatenate provided key with method name and call method if it exist or makes strict equality.
* @example Will call existing _isAddressChanged.
* isChanged('address', addressToCompare)
* @example Will get data by provided key and make strict equality with provided value.
* isChanged('rates', ratesToCompare)
*
* @param {String} key
* @param {*} value
* @return {Boolean}
*/
isChanged: function (key, value) {
var methodName = getMethodName(key, '_is', 'Changed');
if (this[methodName]) {
return this[methodName](value);
}
return this.get(key) !== value;
},
/**
* Compare cached address with provided.
* Custom method for check object equality.
*
* @param {Object} address
* @returns {Boolean}
*/
_isAddressChanged: function (address) {
return JSON.stringify(_.pick(this.get('address'), this.requiredFields)) !==
JSON.stringify(_.pick(address, this.requiredFields));
},
/**
* Compare cached subtotal with provided.
* Custom method for check object equality.
*
* @param {float} subtotal
* @returns {Boolean}
*/
_isSubtotalChanged: function (subtotal) {
var cached = parseFloat(this.get('totals').subtotal);
return subtotal !== cached;
}
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/shipping-rate-processor/new-address',
'Magento_Checkout/js/model/cart/totals-processor/default',
'Magento_Checkout/js/model/shipping-service',
'Magento_Checkout/js/model/cart/cache',
'Magento_Customer/js/customer-data'
], function (quote, defaultProcessor, totalsDefaultProvider, shippingService, cartCache, customerData) {
'use strict';
var rateProcessors = {},
totalsProcessors = {},
/**
* Estimate totals for shipping address and update shipping rates.
*/
estimateTotalsAndUpdateRates = function () {
var type = quote.shippingAddress().getType();
if (
quote.isVirtual() ||
window.checkoutConfig.activeCarriers && window.checkoutConfig.activeCarriers.length === 0
) {
// update totals block when estimated address was set
totalsProcessors['default'] = totalsDefaultProvider;
totalsProcessors[type] ?
totalsProcessors[type].estimateTotals(quote.shippingAddress()) :
totalsProcessors['default'].estimateTotals(quote.shippingAddress());
} else {
// check if user data not changed -> load rates from cache
if (!cartCache.isChanged('address', quote.shippingAddress()) &&
!cartCache.isChanged('cartVersion', customerData.get('cart')()['data_id']) &&
cartCache.get('rates')
) {
shippingService.setShippingRates(cartCache.get('rates'));
return;
}
// update rates list when estimated address was set
rateProcessors['default'] = defaultProcessor;
rateProcessors[type] ?
rateProcessors[type].getRates(quote.shippingAddress()) :
rateProcessors['default'].getRates(quote.shippingAddress());
// save rates to cache after load
shippingService.getShippingRates().subscribe(function (rates) {
cartCache.set('rates', rates);
});
}
},
/**
* Estimate totals for shipping address.
*/
estimateTotalsShipping = function () {
totalsDefaultProvider.estimateTotals(quote.shippingAddress());
},
/**
* Estimate totals for billing address.
*/
estimateTotalsBilling = function () {
var type = quote.billingAddress().getType();
if (quote.isVirtual()) {
// update totals block when estimated address was set
totalsProcessors['default'] = totalsDefaultProvider;
totalsProcessors[type] ?
totalsProcessors[type].estimateTotals(quote.billingAddress()) :
totalsProcessors['default'].estimateTotals(quote.billingAddress());
}
};
quote.shippingAddress.subscribe(estimateTotalsAndUpdateRates);
quote.shippingMethod.subscribe(estimateTotalsShipping);
quote.billingAddress.subscribe(estimateTotalsBilling);
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'underscore',
'Magento_Checkout/js/model/resource-url-manager',
'Magento_Checkout/js/model/quote',
'mage/storage',
'Magento_Checkout/js/model/totals',
'Magento_Checkout/js/model/error-processor',
'Magento_Checkout/js/model/cart/cache',
'Magento_Customer/js/customer-data'
], function (_, resourceUrlManager, quote, storage, totalsService, errorProcessor, cartCache, customerData) {
'use strict';
/**
* Load data from server.
*
* @param {Object} address
*/
var loadFromServer = function (address) {
var serviceUrl,
payload;
// Start loader for totals block
totalsService.isLoading(true);
serviceUrl = resourceUrlManager.getUrlForTotalsEstimationForNewAddress(quote);
payload = {
addressInformation: {
address: _.pick(address, cartCache.requiredFields)
}
};
if (quote.shippingMethod() && quote.shippingMethod()['method_code']) {
payload.addressInformation['shipping_method_code'] = quote.shippingMethod()['method_code'];
payload.addressInformation['shipping_carrier_code'] = quote.shippingMethod()['carrier_code'];
}
return storage.post(
serviceUrl, JSON.stringify(payload), false
).done(function (result) {
var data = {
totals: result,
address: address,
cartVersion: customerData.get('cart')()['data_id'],
shippingMethodCode: null,
shippingCarrierCode: null
};
if (quote.shippingMethod() && quote.shippingMethod()['method_code']) {
data.shippingMethodCode = quote.shippingMethod()['method_code'];
data.shippingCarrierCode = quote.shippingMethod()['carrier_code'];
}
quote.setTotals(result);
cartCache.set('cart-data', data);
}).fail(function (response) {
errorProcessor.process(response);
}).always(function () {
// Stop loader for totals block
totalsService.isLoading(false);
});
};
return {
/**
* Array of required address fields.
* @property {Array.String} requiredFields
* @deprecated Use cart cache.
*/
requiredFields: cartCache.requiredFields,
/**
* Get shipping rates for specified address.
* @param {Object} address
*/
estimateTotals: function (address) {
var data = {
shippingMethodCode: null,
shippingCarrierCode: null
};
if (quote.shippingMethod() && quote.shippingMethod()['method_code']) {
data.shippingMethodCode = quote.shippingMethod()['method_code'];
data.shippingCarrierCode = quote.shippingMethod()['carrier_code'];
}
return loadFromServer(address);
}
};
});
......@@ -130,14 +130,6 @@ define([
return;
}
if (ratesData.length >= 1) {
//set shipping rate if we have only one available shipping rate
if(!selectedShippingRate) {
selectShippingMethodAction(ratesData[0]);
}
console.log(selectedShippingRate)
}
if (quote.shippingMethod()) {
availableRate = _.find(ratesData, function (rate) {
return rate['carrier_code'] == quote.shippingMethod()['carrier_code'] && //eslint-disable-line
......
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'jquery',
'Magento_Customer/js/model/customer',
'mage/validation'
], function ($, customer) {
'use strict';
return {
/**
* Validate checkout agreements
*
* @returns {Boolean}
*/
validate: function () {
var emailValidationResult = customer.isLoggedIn(),
loginFormSelector = 'form[data-role=email-with-possible-login]';
if (!customer.isLoggedIn()) {
$(loginFormSelector).validation();
emailValidationResult = Boolean($(loginFormSelector + ' input[name=username]').valid());
}
return emailValidationResult;
}
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([], function () {
'use strict';
return {
/**
* @return {Object}
*/
getRules: function () {
return {
'country_id': {
'required': true
}
};
}
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'jquery',
'mageUtils',
'./default-validation-rules',
'mage/translate'
], function ($, utils, validationRules, $t) {
'use strict';
return {
validationErrors: [],
/**
* @param {Object} address
* @return {Boolean}
*/
validate: function (address) {
var self = this;
this.validationErrors = [];
$.each(validationRules.getRules(), function (field, rule) {
var message;
if (rule.required && utils.isEmpty(address[field])) {
message = $t('Field ') + field + $t(' is required.');
self.validationErrors.push(message);
}
});
return !this.validationErrors.length;
}
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* @api
*/
define([
'mage/url',
'Magento_Ui/js/model/messageList',
'mage/translate'
], function (url, globalMessageList, $t) {
'use strict';
return {
/**
* @param {Object} response
* @param {Object} messageContainer
*/
process: function (response, messageContainer) {
var error;
messageContainer = messageContainer || globalMessageList;
if (response.status == 401) { //eslint-disable-line eqeqeq
window.location.replace(url.build('customer/account/login/'));
} else {
try {
error = JSON.parse(response.responseText);
} catch (exception) {
error = {
message: $t('Something went wrong with your request. Please try again later.')
};
}
messageContainer.addErrorMessage(error);
}
}
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'jquery',
'rjsResolver'
], function ($, resolver) {
'use strict';
var containerId = '#checkout';
return {
/**
* Start full page loader action
*/
startLoader: function () {
$(containerId).trigger('processStart');
},
/**
* Stop full page loader action
*
* @param {Boolean} [forceStop]
*/
stopLoader: function (forceStop) {
var $elem = $(containerId),
stop = $elem.trigger.bind($elem, 'processStop');
forceStop ? stop() : resolver(stop);
}
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* @api
*/
define([
'underscore',
'Magento_Checkout/js/model/default-post-code-resolver'
], function (_, DefaultPostCodeResolver) {
'use strict';
/**
* @param {Object} addressData
* Returns new address object
*/
return function (addressData) {
var identifier = Date.now(),
countryId = addressData['country_id'] || addressData.countryId || window.checkoutConfig.defaultCountryId,
regionId;
if (addressData.region && addressData.region['region_id']) {
regionId = addressData.region['region_id'];
} else if (!addressData['region_id']) {
regionId = undefined;
} else if (
/* eslint-disable */
addressData['country_id'] && addressData['country_id'] == window.checkoutConfig.defaultCountryId ||
!addressData['country_id'] && countryId == window.checkoutConfig.defaultCountryId
/* eslint-enable */
) {
regionId = window.checkoutConfig.defaultRegionId || undefined;
}
return {
email: addressData.email,
countryId: countryId,
regionId: regionId || addressData.regionId,
regionCode: addressData.region ? addressData.region['region_code'] : null,
region: addressData.region ? addressData.region.region : null,
customerId: addressData['customer_id'] || addressData.customerId,
street: addressData.street ? _.compact(addressData.street) : addressData.street,
company: addressData.company,
telephone: addressData.telephone,
fax: addressData.fax,
postcode: addressData.postcode ? addressData.postcode : DefaultPostCodeResolver.resolve(),
city: addressData.city,
firstname: addressData.firstname,
lastname: addressData.lastname,
middlename: addressData.middlename,
prefix: addressData.prefix,
suffix: addressData.suffix,
vatId: addressData['vat_id'],
saveInAddressBook: addressData['save_in_address_book'],
customAttributes: addressData['custom_attributes'],
extensionAttributes: addressData['extension_attributes'],
/**
* @return {*}
*/
isDefaultShipping: function () {
return addressData['default_shipping'];
},
/**
* @return {*}
*/
isDefaultBilling: function () {
return addressData['default_billing'];
},
/**
* @return {String}
*/
getType: function () {
return 'new-customer-address';
},
/**
* @return {String}
*/
getKey: function () {
return this.getType();
},
/**
* @return {String}
*/
getCacheKey: function () {
return this.getType() + identifier;
},
/**
* @return {Boolean}
*/
isEditable: function () {
return true;
},
/**
* @return {Boolean}
*/
canUseForBilling: function () {
return true;
}
};
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'underscore',
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/payment/method-list',
'Magento_Checkout/js/action/select-payment-method'
], function (_, quote, methodList, selectPaymentMethod) {
'use strict';
/**
* Free method filter
* @param {Object} paymentMethod
* @return {Boolean}
*/
var isFreePaymentMethod = function (paymentMethod) {
return paymentMethod.method === 'free';
},
/**
* Grabs the grand total from quote
* @return {Number}
*/
getGrandTotal = function () {
return quote.totals()['grand_total'];
};
return {
isFreeAvailable: false,
/**
* Populate the list of payment methods
* @param {Array} methods
*/
setPaymentMethods: function (methods) {
var freeMethod,
filteredMethods,
methodIsAvailable,
methodNames;
freeMethod = _.find(methods, isFreePaymentMethod);
this.isFreeAvailable = !!freeMethod;
if (freeMethod && getGrandTotal() <= 0) {
methods.splice(0, methods.length, freeMethod);
selectPaymentMethod(freeMethod);
}
filteredMethods = _.without(methods, freeMethod);
if (filteredMethods.length === 1) {
selectPaymentMethod(filteredMethods[0]);
} else if (quote.paymentMethod()) {
methodIsAvailable = methods.some(function (item) {
return item.method === quote.paymentMethod().method;
});
//Unset selected payment method if not available
if (!methodIsAvailable) {
selectPaymentMethod(null);
}
}
/**
* Overwrite methods with existing methods to preserve ko array references.
* This prevent ko from re-rendering those methods.
*/
methodNames = _.pluck(methods, 'method');
_.map(methodList(), function (existingMethod) {
var existingMethodIndex = methodNames.indexOf(existingMethod.method);
if (existingMethodIndex !== -1) {
methods[existingMethodIndex] = existingMethod;
}
});
methodList(methods);
},
/**
* Get the list of available payment methods.
* @return {Array}
*/
getAvailablePaymentMethods: function () {
var allMethods = methodList().slice(),
grandTotalOverZero = getGrandTotal() > 0;
if (!this.isFreeAvailable) {
return allMethods;
}
if (grandTotalOverZero) {
return _.reject(allMethods, isFreePaymentMethod);
}
return _.filter(allMethods, isFreePaymentMethod);
}
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* @api
*/
define([], function () {
'use strict';
var validators = [];
return {
/**
* Register unique validator
*
* @param {*} validator
*/
registerValidator: function (validator) {
validators.push(validator);
},
/**
* Returns array of registered validators
*
* @returns {Array}
*/
getValidators: function () {
return validators;
},
/**
* Process validators
*
* @returns {Boolean}
*/
validate: function (hideError) {
var validationResult = true;
hideError = hideError || false;
if (validators.length <= 0) {
return validationResult;
}
validators.forEach(function (item) {
if (item.validate(hideError) == false) { //eslint-disable-line eqeqeq
validationResult = false;
return false;
}
});
return validationResult;
}
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'underscore'
], function (_) {
'use strict';
return function (methods) {
_.each(methods, function (method) {
if (method.hasOwnProperty('code')) {
method.method = method.code;
delete method.code;
}
});
return methods;
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'uiElement',
'mage/translate'
], function (Element, $t) {
'use strict';
var DEFAULT_GROUP_ALIAS = 'default';
return Element.extend({
defaults: {
alias: DEFAULT_GROUP_ALIAS,
title: $t('Payment Method'),
sortOrder: 100,
displayArea: 'payment-methods-items-${ $.alias }'
},
/**
* Checks if group instance is default
*
* @returns {Boolean}
*/
isDefault: function () {
return this.alias === DEFAULT_GROUP_ALIAS;
}
});
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'ko'
], function (ko) {
'use strict';
return ko.observableArray([]);
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([], function () {
'use strict';
return {
requestModifiers: [],
afterRequestListeners: []
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'ko'
], function (ko) {
'use strict';
return ko.observableArray([]);
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* @api
*/
define(
[
'mage/storage',
'Magento_Checkout/js/model/error-processor',
'Magento_Checkout/js/model/full-screen-loader',
'Magento_Customer/js/customer-data',
'Magento_Checkout/js/model/payment/place-order-hooks',
'underscore'
],
function (storage, errorProcessor, fullScreenLoader, customerData, hooks, _) {
'use strict';
return function (serviceUrl, payload, messageContainer) {
var headers = {};
fullScreenLoader.startLoader();
_.each(hooks.requestModifiers, function (modifier) {
modifier(headers, payload);
});
return storage.post(
serviceUrl, JSON.stringify(payload), true, 'application/json', headers
).fail(
function (response) {
errorProcessor.process(response, messageContainer);
}
).done(
function (response) {
var clearData = {
'selectedShippingAddress': null,
'shippingAddressFromData': null,
'newCustomerShippingAddress': null,
'selectedShippingRate': null,
'selectedPaymentMethod': null,
'selectedBillingAddress': null,
'billingAddressFromData': null,
'newCustomerBillingAddress': null
};
if (response.responseType !== 'error') {
customerData.set('checkout-data', clearData);
}
}
).always(
function () {
fullScreenLoader.stopLoader();
_.each(hooks.afterRequestListeners, function (listener) {
listener();
});
}
);
};
}
);
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'mageUtils'
], function (utils) {
'use strict';
return {
validatedPostCodeExample: [],
/**
* @param {*} postCode
* @param {*} countryId
* @param {Array} postCodesPatterns
* @return {Boolean}
*/
validate: function (postCode, countryId, postCodesPatterns) {
var pattern, regex,
patterns = postCodesPatterns ? postCodesPatterns[countryId] :
window.checkoutConfig.postCodes[countryId];
this.validatedPostCodeExample = [];
if (!utils.isEmpty(postCode) && !utils.isEmpty(patterns)) {
for (pattern in patterns) {
if (patterns.hasOwnProperty(pattern)) { //eslint-disable-line max-depth
this.validatedPostCodeExample.push(patterns[pattern].example);
regex = new RegExp(patterns[pattern].pattern);
if (regex.test(postCode)) { //eslint-disable-line max-depth
return true;
}
}
}
return false;
}
return true;
}
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* @api
*/
define([
'ko',
'underscore',
'domReady!'
], function (ko, _) {
'use strict';
/**
* Get totals data from the extension attributes.
* @param {*} data
* @returns {*}
*/
var proceedTotalsData = function (data) {
if (_.isObject(data) && _.isObject(data['extension_attributes'])) {
_.each(data['extension_attributes'], function (element, index) {
data[index] = element;
});
}
return data;
},
billingAddress = ko.observable(null),
shippingAddress = ko.observable(null),
shippingMethod = ko.observable(null),
paymentMethod = ko.observable(null),
quoteData = window.checkoutConfig.quoteData,
basePriceFormat = window.checkoutConfig.basePriceFormat,
priceFormat = window.checkoutConfig.priceFormat,
storeCode = window.checkoutConfig.storeCode,
totalsData = proceedTotalsData(window.checkoutConfig.totalsData),
totals = ko.observable(totalsData),
collectedTotals = ko.observable({});
return {
totals: totals,
shippingAddress: shippingAddress,
shippingMethod: shippingMethod,
billingAddress: billingAddress,
paymentMethod: paymentMethod,
guestEmail: null,
/**
* @return {*}
*/
getQuoteId: function () {
return quoteData['entity_id'];
},
/**
* @return {Boolean}
*/
isVirtual: function () {
return !!Number(quoteData['is_virtual']);
},
/**
* @return {*}
*/
getPriceFormat: function () {
return priceFormat;
},
/**
* @return {*}
*/
getBasePriceFormat: function () {
return basePriceFormat;
},
/**
* @return {*}
*/
getItems: function () {
return window.checkoutConfig.quoteItemData;
},
/**
*
* @return {*}
*/
getTotals: function () {
return totals;
},
/**
* @param {Object} data
*/
setTotals: function (data) {
data = proceedTotalsData(data);
totals(data);
this.setCollectedTotals('subtotal_with_discount', parseFloat(data['subtotal_with_discount']));
},
/**
* @param {*} paymentMethodCode
*/
setPaymentMethod: function (paymentMethodCode) {
paymentMethod(paymentMethodCode);
},
/**
* @return {*}
*/
getPaymentMethod: function () {
return paymentMethod;
},
/**
* @return {*}
*/
getStoreCode: function () {
return storeCode;
},
/**
* @param {String} code
* @param {*} value
*/
setCollectedTotals: function (code, value) {
var colTotals = collectedTotals();
colTotals[code] = value;
collectedTotals(colTotals);
},
/**
* @return {Number}
*/
getCalculatedTotal: function () {
var total = 0.; //eslint-disable-line no-floating-decimal
_.each(collectedTotals(), function (value) {
total += value;
});
return total;
}
};
});
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* @api
*/
define([
'Magento_Customer/js/model/customer',
'Magento_Checkout/js/model/url-builder',
'mageUtils'
], function (customer, urlBuilder, utils) {
'use strict';
return {
/**
* @param {Object} quote
* @return {*}
*/
getUrlForTotalsEstimationForNewAddress: function (quote) {
var params = this.getCheckoutMethod() == 'guest' ? //eslint-disable-line eqeqeq
{
cartId: quote.getQuoteId()
} : {},
urls = {
'guest': '/guest-carts/:cartId/totals-information',
'customer': '/carts/mine/totals-information'
};
return this.getUrl(urls, params);
},
/**
* @param {Object} quote
* @return {*}
*/
getUrlForEstimationShippingMethodsForNewAddress: function (quote) {
var params = this.getCheckoutMethod() == 'guest' ? //eslint-disable-line eqeqeq
{
quoteId: quote.getQuoteId()
} : {},
urls = {
'guest': '/guest-carts/:quoteId/estimate-shipping-methods',
'customer': '/carts/mine/estimate-shipping-methods'
};
return this.getUrl(urls, params);
},
/**
* @param {Object} quote
* @return {*}
*/
getUrlForEstimationShippingMethodsByAddressId: function (quote) {
var params = this.getCheckoutMethod() == 'guest' ? //eslint-disable-line eqeqeq
{
quoteId: quote.getQuoteId()
} : {},
urls = {
'default': '/carts/mine/estimate-shipping-methods-by-address-id'
};
return this.getUrl(urls, params);
},
/**
* @param {String} couponCode
* @param {String} quoteId
* @return {*}
*/
getApplyCouponUrl: function (couponCode, quoteId) {
var params = this.getCheckoutMethod() == 'guest' ? //eslint-disable-line eqeqeq
{
quoteId: quoteId
} : {},
urls = {
'guest': '/guest-carts/' + quoteId + '/coupons/' + encodeURIComponent(couponCode),
'customer': '/carts/mine/coupons/' + encodeURIComponent(couponCode)
};
return this.getUrl(urls, params);
},
/**
* @param {String} quoteId
* @return {*}
*/
getCancelCouponUrl: function (quoteId) {
var params = this.getCheckoutMethod() == 'guest' ? //eslint-disable-line eqeqeq
{
quoteId: quoteId
} : {},
urls = {
'guest': '/guest-carts/' + quoteId + '/coupons/',
'customer': '/carts/mine/coupons/'
};
return this.getUrl(urls, params);
},
/**
* @param {Object} quote
* @return {*}
*/
getUrlForCartTotals: function (quote) {
var params = this.getCheckoutMethod() == 'guest' ? //eslint-disable-line eqeqeq
{
quoteId: quote.getQuoteId()
} : {},
urls = {
'guest': '/guest-carts/:quoteId/totals',
'customer': '/carts/mine/totals'
};
return this.getUrl(urls, params);
},
/**
* @param {Object} quote
* @return {*}
*/
getUrlForSetShippingInformation: function (quote) {
var params = this.getCheckoutMethod() == 'guest' ? //eslint-disable-line eqeqeq
{
cartId: quote.getQuoteId()
} : {},
urls = {
'guest': '/guest-carts/:cartId/shipping-information',
'customer': '/carts/mine/shipping-information'
};
return this.getUrl(urls, params);
},
/**
* Get url for service.
*
* @param {*} urls
* @param {*} urlParams
* @return {String|*}
*/
getUrl: function (urls, urlParams) {
var url;
if (utils.isEmpty(urls)) {
return 'Provided service call does not exist.';
}
if (!utils.isEmpty(urls['default'])) {
url = urls['default'];
} else {
url = urls[this.getCheckoutMethod()];
}
return urlBuilder.createUrl(url, urlParams);
},
/**
* @return {String}
*/
getCheckoutMethod: function () {
return customer.isLoggedIn() ? 'customer' : 'guest';
}
};
}
);
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'ko'
], function (ko) {
'use strict';
return {
isVisible: ko.observable(false)
};
});
Markdown is supported
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