Coupons/Vouchers/Shipping
These three system blocks are modules in OpenCart. They are looped together, you can edit the files, example make some blank or use an if/else
statement to show only certain modules.
You cannot call the form itself in the cart.tpl
, it must be:
<div class="right">
<!-- eVoucher System -->
<?php foreach ($modules as $module) { ?>
<?=$module?>
<?php } ?>
<!-- eVoucher System -->
</div>
File locations of Shipping/Voucher and Coupon modules
This will loop and show the module tpl files, shipping, coupon and voucher. They are strangely located
/catalog/view/theme/default/total/coupon.tpl
/catalog/view/theme/default/total/shipping.tpl
/catalog/view/theme/default/total/voucher.tpl
We do not use them all so we have blanked the voucher and shipping. Coupon form looks like:
<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>
So that is how and where these files are, the total
also has a controller and coupon
and all the other modules are controller and standard MVC driven.
External Coupon Cart Form
So for usage on external pages as you wished, plucking for the tpl files and the $modules
and $module
loop, code should be:
(making sure "slash" index.php in case of SEO URI)
Sure, example, on your about us page:
<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>