我在OpenCart环境中有另一个页面,让我们说下面有这些表格的关于我们的页面,假设用户的购物车中有商品,这些表格应该可以使用,但他们不会: 在此输入您的优惠券代码: <form action="index.php?route=checkout/cart" method="post" enctype="multipart/form-data" id="basket">
<input typ
我在OpenCart环境中有另一个页面,让我们说下面有这些表格的关于我们的页面,假设用户的购物车中有商品,这些表格应该可以使用,但他们不会:
在此输入您的优惠券代码:
<form action="index.PHP?route=checkout/cart" 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>
在此输入您的礼券代码:
<form action="index.PHP?route=checkout/cart" method="post" enctype="multipart/form-data" id="basket">
<input type="text" value="" name="voucher"/>
<input type="hidden" value="voucher" name="next"/>
<input type="submit" class="button" value="Apply Voucher"/>
</form>
这是代金券代码系统,但它不起作用(此代码默认不编辑):
/catalog/controller/checkout/cart.PHP
// VOUCHER
// IF THE USER HAS ENTERED A VOUCHER
if (isset($this->request->post['voucher']) && $this->request->post['voucher']) {
foreach ($this->request->post['voucher'] as $key) {
if (isset($this->session->data['vouchers'][$key])) {
unset($this->session->data['vouchers'][$key]);
}
}
}
优惠券/凭证/运输
这三个系统块是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>
这就是这些文件的方式和位置,总数还有控制器和优惠券,所有其他模块都是控制器和标准的MVC驱动.
外部优惠券购物车表格
因此,如果您希望在外部页面上使用tpl文件以及$modules和$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>