Opencart 2.3x主题修改:添加免费送货预告片

时间:2017-08-27 16:17:28

标签: php opencart2.3

我是一个初学者。

我正在使用2.3.0.2 opencart

我想在我的商店中添加“免费送货预告片”,如链接中的图片所示

https://ibb.co/eeuE95

逻辑:

如果客户购买总价值等于或高于64美元的商品, 然后会在下拉菜单中显示一条消息“你有免费送货!” 否则会显示一条消息“您距离免费送货只需$ xx!”

以下是来自cart.tpl的代码

<div id="cart" class="clearfix pull-right dropdown">
<div data-toggle="dropdown" data-loading-text="<?php echo $text_loading; ?>" class="dropdown-toggle"> 
<div class="cart-inner">
<a href="">
<?php echo $objlang->get("text_heading_title"); ?>
<span id="cart-total" class="cart-total radius-6x "><?php echo     substr($text_items, 0, strpos($text_items, ' ')+1); ?></span>
<?php 
$res = explode("-", $text_items);
?>

</a>
</div>
</div>
<ul class="dropdown-menu pull-right">
<?php if ($products || $vouchers) { ?>
<li>
<table class="table first">
<?php foreach ($products as $product) { ?>
<tr>
<td class="text-left image"><?php if ($product['thumb']) { ?>
<a href="<?php echo $product['href']; ?>"><img src="<?php echo     $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" class="img-thumbnail" /></a>
<?php } ?></td>
<td class="text-left"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a>
<?php if ($product['option']) { ?>
<?php foreach ($product['option'] as $option) { ?>
<br />
- <small><?php echo $option['name']; ?> <?php echo $option['value']; ?>        </small>
<?php } ?>
<?php } ?>
<?php if ($product['recurring']) { ?>
<br />
- <small><?php echo $text_recurring; ?> <?php echo $product['recurring']; ?>        </small>
<?php } ?></td>
<td class="text-right">x <?php echo $product['quantity']; ?></td>
<td class="text-right"><?php echo $product['total']; ?></td>
<td class="text-right"><button type="button" onclick="cart.remove('<?php     echo $product['cart_id']; ?>');" title="<?php echo $button_remove; ?>" class="btn btn-danger btn-xs"><i class="fa fa-times"></i></button></td>
</tr>
<?php } ?>
<?php foreach ($vouchers as $voucher) { ?>
<tr>
<td class="text-center"></td>
<td class="text-left"><?php echo $voucher['description']; ?></td>
<td class="text-right">x&nbsp;1</td>
<td class="text-right"><?php echo $voucher['amount']; ?></td>
<td class="text-center text-danger"><button type="button"     onclick="voucher.remove('<?php echo $voucher['key']; ?>');" title="<?php echo     $button_remove; ?>" class="btn btn-danger btn-xs"><i class="fa fa-times"></i>        </button></td>
</tr>
<?php } ?>
</table>
</li>
<li>
<div>
<table class="table table-bordered">
<?php foreach ($totals as $total) { ?>
<tr>
<td class="text-right"><strong><?php echo $total['title']; ?></strong></td>
<td class="text-right"><?php echo $total['text']; ?></td>
</tr>
<?php } ?>
</table>
<p class="text-right"><a href="<?php echo $cart; ?>"><span class="btn btn-    primary"><?php echo $text_cart; ?></span></a>&nbsp;&nbsp;&nbsp;<a href="<?php     echo $checkout; ?>"><span class="btn btn-default"><?php echo $text_checkout; ?>    </span></a></p>
</div>
</li>
// Code for free shipping is inserted here //
<?php } else { ?>
<li>
<p class="text-center"><?php echo $text_empty; ?></p>
</li>
<?php } ?>
</ul>
</div>

我插入此代码但仍然出错。 一点也不运气。

   <li>
   <?php
   $t = 64;
   $free = $t - $total;

   if ($free > "0") {
   echo "You are ", $free['text'], "away from FREE SHIPPING!";
   } else {
   echo "You have free shipping!";
    }
    ?>
   </li>

请帮忙。 提前谢谢。

0 个答案:

没有答案