【问题标题】:magento show free shipping textmagento 显示免费送货文本
【发布时间】:2013-09-25 21:48:52
【问题描述】:

我想将免费送货价格显示为文本,例如“免费送货”,但我无法使用它。在 app/code/core/Mage/Shipping/Model/Carrier/Freeshipping.php 我发现了这些行:

$method->setPrice('0.00');
$method->setCost('0.00');

但如果我将 0.00 更改为“免费送货”,则什么也不会发生。 我在互联网上做了很多研究,但没有任何效果。还有很多插件可以将价格设置为“免费”,但这仅适用于产品。

所以我很绝望,我希望有人可以在这里帮助我。 我正在使用 Magento 1.7.0.2。

非常感谢

【问题讨论】:

    标签: php magento


    【解决方案1】:
    1. app/design/frontend/base/default/template/checkout/onepage/shipping_method/available.phtml复制到您正在使用的相应主题文件夹中。

    2. available.phtml 文件中,查找以下代码(第 56 行附近):

      <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?>
      <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
      <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
      <?php echo $_excl; ?>
      <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
          (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
      <?php endif; ?>
      </label>
      
    3. 将其替换为以下内容:

      <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?>
      <?php if($_rate->getPrice() > 0) : ?>        
      <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
      <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
      <?php echo $_excl; ?>
      <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
          (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
      <?php endif; ?>
      <?php else : ?>
            (<?php echo $this->__('Free Shipping'); ?>)
      <?php endif; ?>
      </label>
      
    4. 保存available.phtml,并清除您的 Magento 缓存。现在,“免费送货”将出现在“一页结帐”送货部分中包含 0 美元金额的所有方法旁边。

    【讨论】:

    • 这对结帐页面非常有用,谢谢!但如果我用预估运费和税箱计算运费,它仍然显示 0.00。那么我应该编辑哪个文件来为那个盒子做同样的事情呢?再次感谢!
    • 计算运费块的文件是app/design/frontend/[theme_path]/template/checkout/cart/shipping.phtml。为了将来参考,您可以通过在 Magento 配置中启用 Template Path Hints 来确定加载到前端的确切模板路径。您可以在此处找到有关如何执行此操作的快速教程:support.sweettoothrewards.com/entries/…
    • 你是个好帮手!非常感谢