优惠券/代金券/运费
这三个系统块是OpenCart中的模块。它们循环在一起,您可以编辑文件,例如将一些文件留空或使用if/else
语句仅显示某些模块。
您不能在cart.tpl
, 一定是:
<div class="right">
<!-- eVoucher System -->
<?php foreach ($modules as $module) { ?>
<?=$module?>
<?php } ?>
<!-- eVoucher System -->
</div>
运输/凭证和优惠券模块的文件位置
这将循环并显示模块 tpl 文件、运输、优惠券和凭证。他们的位置很奇怪
/catalog/view/theme/default/total/coupon.tpl
/catalog/view/theme/default/total/shipping.tpl
/catalog/view/theme/default/total/voucher.tpl
我们不会全部使用它们,因此我们已将优惠券和运费清空。优惠券形式如下:
<div>
<div class="cart-heading"><?php echo $heading_title; ?></div>
<div class="cart-content" id="coupon"><?php echo $entry_coupon; ?>
<input type="text" name="coupon" value="<?php echo $coupon; ?>" />
<a id="button-coupon" class="button"><span><?php echo $button_coupon; ?></span></a></div>
</div>
<script type="text/javascript">
<!--
//
// jQuery dependent based on .post so make sure
// your footer or header jQuery call is before this
//
$('#button-coupon').bind('click', function() {
$.ajax({
type: 'POST',
url: 'index.php?route=total/coupon/calculate',
data: $('#coupon :input'),
dataType: 'json',
beforeSend: function() {
$('.success, .warning').remove();
$('#button-coupon').attr('disabled', true);
$('#button-coupon').after('<span class="wait"> <img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
},
complete: function() {
$('#button-coupon').attr('disabled', false);
$('.wait').remove();
},
success: function(json) {
if (json['error']) {
$('#basket').before('<div class="warning">' + json['error'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
}
if (json['redirect']) {
location = json['redirect'];
}
}
});
});
//-->
</script>
这就是这些文件的位置和方式total
还有一个控制器和coupon
所有其他模块均由控制器和标准 MVC 驱动。
外部优惠券购物车表格
因此,为了按照您的意愿在外部页面上使用,请提取 tpl 文件和$modules
and $module
循环,代码应该是:
(在 SEO URI 的情况下确保“斜杠”index.php)
当然,例如,在您的“关于我们”页面上:
<strong>Please enter your coupon:</strong>
<form action="/index.php?route=total/coupon/calculate" method="post" enctype="multipart/form-data" id="basket">
<input type="text" value="" id="coupon" name="coupon"/>
<input type="hidden" value="coupon" name="next"/>
<input type="submit" class="button" value="Apply Coupon"/>
</form>