Commit 21209fab by dhn

优化购物车2

parent 61bab73c
......@@ -7,32 +7,21 @@
?>
<?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 id="block-shipping" class="block shipping">
<div id="block-summary" style="display: none;">
<form method="post" id="shipping-zip-form">
<fieldset class="fieldset estimate">
<div class="field" name="shippingAddress.country_id">
<label class="label" for="shipping_country_id">
<span><?= __('Country')?></span>
</label>
<div class="control">
<?= $block->getCountryHtmlSelect(null, 'country_id', 'shipping_country_id')?>
</div>
</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>
</fieldset>
</form>
<?php $serializedCheckoutConfig = /* @noEscape */ $block->getSerializedCheckoutConfig();
$scriptString = <<<script
......
......@@ -29,6 +29,7 @@ define([
billingAddress = ko.observable(null),
shippingAddress = ko.observable(null),
shippingMethod = ko.observable(null),
shippingSaveMethod = ko.observable(null),
paymentMethod = ko.observable(null),
paymentMethodlist = ko.observable(null),
quoteData = window.checkoutConfig.quoteData,
......@@ -43,6 +44,7 @@ define([
totals: totals,
shippingAddress: shippingAddress,
shippingMethod: shippingMethod,
shippingSaveMethod:shippingSaveMethod,
billingAddress: billingAddress,
paymentMethod: paymentMethod,
paymentMethodlist:paymentMethodlist,
......@@ -113,12 +115,20 @@ define([
getPaymentMethod: function () {
return paymentMethod;
},
setShippingSaveMethod: function (Method) {
shippingSaveMethod(Method);
},
getShippingSaveMethod: function () {
return shippingSaveMethod;
},
setPaymentMethodList: function (MethodList) {
paymentMethodlist(MethodList);
},
getPaymentMethodList: function () {
return paymentMethodlist;
},
/**
* @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([
if (!this.isCalculated()) {
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();
if (!_.isArray(shippingMethod) && !_.isObject(shippingMethod)) {
......@@ -78,7 +93,10 @@ define([
price = this.totals()['shipping_amount'];
if(price == 0)
{
return this.getFormattedPrice(6.99);
if(quote.shippingSaveMethod())
{
return this.getFormattedPrice(quote.shippingSaveMethod()['amount']);
}
}
return this.getFormattedPrice(price);
},
......@@ -91,7 +109,11 @@ define([
price = this.totals()['shipping_amount'];
if(price == 0)
{
return '-'+this.getFormattedPrice(6.99);
if(quote.shippingSaveMethod())
{
return '-'+this.getFormattedPrice(quote.shippingSaveMethod()['amount']);
}
return 0;
}
},
......
......@@ -51,7 +51,7 @@ define([
},
isSaveShowed: function () {
var price = this.totals()['shipping_amount'];
if(price)
if(price != 0)
{
return false;
}
......
......@@ -37,7 +37,7 @@
<referenceContainer name="content">
<block class="Magento\Framework\View\Element\Template" name="checkout.cart.footer" template="Magento_Checkout::footer.phtml" />
</referenceContainer>
<!--
<referenceBlock name="checkout.cart.totals">
<arguments>
<argument name="jsLayout" xsi:type="array">
......@@ -45,7 +45,7 @@
<item name="block-totals" xsi:type="array">
<item name="children" 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>
......@@ -53,6 +53,6 @@
</argument>
</arguments>
</referenceBlock>
-->
</body>
</page>
......@@ -67,6 +67,10 @@
<item name="component" xsi:type="string">Magento_Checkout/js/view/security</item>
<item name="displayArea" xsi:type="string">security</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>
......
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