Commit 21209fab by dhn

优化购物车2

parent 61bab73c
...@@ -7,32 +7,21 @@ ...@@ -7,32 +7,21 @@
?> ?>
<?php /** @var $block \Magento\Checkout\Block\Cart\Shipping */ ?> <?php /** @var $block \Magento\Checkout\Block\Cart\Shipping */ ?>
<?php /** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */ ?> <?php /** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */ ?>
<div id="block-shipping"
class="block shipping" <div id="block-shipping" class="block shipping">
data-mage-init='{"collapsible":{"openedState": "active", "saveState": true}}' <div id="block-summary" style="display: none;">
> <form method="post" id="shipping-zip-form">
<div class="title" data-role="title"> <fieldset class="fieldset estimate">
<strong id="block-shipping-heading" role="heading" aria-level="2"> <div class="field" name="shippingAddress.country_id">
<?= $block->getQuote()->isVirtual() <label class="label" for="shipping_country_id">
? $block->escapeHtml(__('Estimate Tax')) <span><?= __('Country')?></span>
: $block->escapeHtml(__('Estimate Shipping and Tax')) </label>
?> <div class="control">
</strong> <?= $block->getCountryHtmlSelect(null, 'country_id', 'shipping_country_id')?>
</div> </div>
<div id="block-summary" </div>
data-bind="scope:'block-summary'" </fieldset>
class="content" </form>
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(); <?php $serializedCheckoutConfig = /* @noEscape */ $block->getSerializedCheckoutConfig();
$scriptString = <<<script $scriptString = <<<script
......
...@@ -29,6 +29,7 @@ define([ ...@@ -29,6 +29,7 @@ define([
billingAddress = ko.observable(null), billingAddress = ko.observable(null),
shippingAddress = ko.observable(null), shippingAddress = ko.observable(null),
shippingMethod = ko.observable(null), shippingMethod = ko.observable(null),
shippingSaveMethod = ko.observable(null),
paymentMethod = ko.observable(null), paymentMethod = ko.observable(null),
paymentMethodlist = ko.observable(null), paymentMethodlist = ko.observable(null),
quoteData = window.checkoutConfig.quoteData, quoteData = window.checkoutConfig.quoteData,
...@@ -43,6 +44,7 @@ define([ ...@@ -43,6 +44,7 @@ define([
totals: totals, totals: totals,
shippingAddress: shippingAddress, shippingAddress: shippingAddress,
shippingMethod: shippingMethod, shippingMethod: shippingMethod,
shippingSaveMethod:shippingSaveMethod,
billingAddress: billingAddress, billingAddress: billingAddress,
paymentMethod: paymentMethod, paymentMethod: paymentMethod,
paymentMethodlist:paymentMethodlist, paymentMethodlist:paymentMethodlist,
...@@ -113,12 +115,20 @@ define([ ...@@ -113,12 +115,20 @@ define([
getPaymentMethod: function () { getPaymentMethod: function () {
return paymentMethod; return paymentMethod;
}, },
setShippingSaveMethod: function (Method) {
shippingSaveMethod(Method);
},
getShippingSaveMethod: function () {
return shippingSaveMethod;
},
setPaymentMethodList: function (MethodList) { setPaymentMethodList: function (MethodList) {
paymentMethodlist(MethodList); paymentMethodlist(MethodList);
}, },
getPaymentMethodList: function () { getPaymentMethodList: function () {
return paymentMethodlist; return paymentMethodlist;
}, },
/** /**
* @return {*} * @return {*}
*/ */
......
define([
'uiComponent',
'uiRegistry',
'underscore',
'Magento_Checkout/js/model/shipping-rate-processor/get-address'
], function (
Component,
registry,
_,
getAddress
) {
'use strict';
return Component.extend({
/** @inheritdoc */
initialize: function () {
this._super();
var address={};
address.countryId = window.checkoutConfig.defaultCountryId;
getAddress.getRates(address);
}
});
});
...@@ -29,6 +29,21 @@ define([ ...@@ -29,6 +29,21 @@ define([
if (!this.isCalculated()) { if (!this.isCalculated()) {
return ''; return '';
} }
var price;
if (!this.isCalculated()) {
return this.notCalculatedMessage;
}
price = this.totals()['shipping_amount'];
if(price == 0)
{
if(quote.shippingSaveMethod())
{
return quote.shippingSaveMethod()['method_title'];
}
}
shippingMethod = quote.shippingMethod(); shippingMethod = quote.shippingMethod();
if (!_.isArray(shippingMethod) && !_.isObject(shippingMethod)) { if (!_.isArray(shippingMethod) && !_.isObject(shippingMethod)) {
...@@ -78,7 +93,10 @@ define([ ...@@ -78,7 +93,10 @@ define([
price = this.totals()['shipping_amount']; price = this.totals()['shipping_amount'];
if(price == 0) if(price == 0)
{ {
return this.getFormattedPrice(6.99); if(quote.shippingSaveMethod())
{
return this.getFormattedPrice(quote.shippingSaveMethod()['amount']);
}
} }
return this.getFormattedPrice(price); return this.getFormattedPrice(price);
}, },
...@@ -91,7 +109,11 @@ define([ ...@@ -91,7 +109,11 @@ define([
price = this.totals()['shipping_amount']; price = this.totals()['shipping_amount'];
if(price == 0) if(price == 0)
{ {
return '-'+this.getFormattedPrice(6.99); if(quote.shippingSaveMethod())
{
return '-'+this.getFormattedPrice(quote.shippingSaveMethod()['amount']);
}
return 0;
} }
}, },
......
...@@ -51,7 +51,7 @@ define([ ...@@ -51,7 +51,7 @@ define([
}, },
isSaveShowed: function () { isSaveShowed: function () {
var price = this.totals()['shipping_amount']; var price = this.totals()['shipping_amount'];
if(price) if(price != 0)
{ {
return false; return false;
} }
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<referenceContainer name="content"> <referenceContainer name="content">
<block class="Magento\Framework\View\Element\Template" name="checkout.cart.footer" template="Magento_Checkout::footer.phtml" /> <block class="Magento\Framework\View\Element\Template" name="checkout.cart.footer" template="Magento_Checkout::footer.phtml" />
</referenceContainer> </referenceContainer>
<!--
<referenceBlock name="checkout.cart.totals"> <referenceBlock name="checkout.cart.totals">
<arguments> <arguments>
<argument name="jsLayout" xsi:type="array"> <argument name="jsLayout" xsi:type="array">
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
<item name="block-totals" xsi:type="array"> <item name="block-totals" xsi:type="array">
<item name="children" xsi:type="array"> <item name="children" xsi:type="array">
<item name="shpping-get" xsi:type="array"> <item name="shpping-get" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/shipping-get</item> <item name="component" xsi:type="string">Magento_Checkout/js/view/address-get</item>
</item> </item>
</item> </item>
</item> </item>
...@@ -53,6 +53,6 @@ ...@@ -53,6 +53,6 @@
</argument> </argument>
</arguments> </arguments>
</referenceBlock> </referenceBlock>
-->
</body> </body>
</page> </page>
...@@ -67,6 +67,10 @@ ...@@ -67,6 +67,10 @@
<item name="component" xsi:type="string">Magento_Checkout/js/view/security</item> <item name="component" xsi:type="string">Magento_Checkout/js/view/security</item>
<item name="displayArea" xsi:type="string">security</item> <item name="displayArea" xsi:type="string">security</item>
</item> </item>
<item name="addressGet" xsi:type="array">
<item name="component" xsi:type="string">Magento_Checkout/js/view/address-get</item>
<item name="displayArea" xsi:type="string">addressGet</item>
</item>
</item> </item>
</item> </item>
</item> </item>
......
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