Hi Guys,
had a look through the forums and can't find this, I would have thought someone else might have had the same issue?
Using 1.5.2 and as it stands customers can only redeem one gift voucher per order, has anybody come up with a mod so customers can redeem as many gift vouchers as they happen to have? Would have thought the ability to redeem multiple gift vouchers would be standard functionality, understand that you want to limit coupons to just one per order just not gift vouchers or is it just me? Can see some customers potentially getting annoyed by this and what to have it sorted before going live.
Many Thanks
had a look through the forums and can't find this, I would have thought someone else might have had the same issue?
Using 1.5.2 and as it stands customers can only redeem one gift voucher per order, has anybody come up with a mod so customers can redeem as many gift vouchers as they happen to have? Would have thought the ability to redeem multiple gift vouchers would be standard functionality, understand that you want to limit coupons to just one per order just not gift vouchers or is it just me? Can see some customers potentially getting annoyed by this and what to have it sorted before going live.
Many Thanks
By default Opencart is using a single session variable voucher for calculating voucher so it will overwrite if you try to add more than one. The best way to customize this is by converting that variable into array and store each entered eligible voucher code into that array and instead of calculating single voucher code into shopping cart (catalog/module/total/vourcher.php) calculate all entered voucher codes discount.
Most Useful Extensions || Most Selling Extensions
Opencart Development || Opencart Designing || eCommerce Project
✔ Join more than 5000 Happy Opencart Store Owners enjoying the extensions designed and developed by Opcrat, Opencart Partner.
Hi,
It's reasonably simple.
Modify catalog/controller/checkout/cart.php
Find this code:
Replace with:
Then modify catalog/model/total/voucher.php
Find this code:
And replace with
Note the extra closed bracket to ensure the foreach works properly
You'll also need to go into the template for the checkout.cart.tpl (depending on if you are using a custom one or the default) and remove the echo $voucher code from the input field i.e.
becomes
Kind regards, Spencer
It's reasonably simple.
Modify catalog/controller/checkout/cart.php
Find this code:
Code: Select all
if (isset($this->request->post['voucher']) && $this->validateVoucher()) {
$this->session->data['voucher'] = $this->request->post['voucher'];
Code: Select all
if (isset($this->request->post['voucher']) && $this->validateVoucher()) {
$this->session->data['voucher'][$this->request->post['voucher']] = $this->request->post['voucher'];
Find this code:
Code: Select all
$this->load->model('checkout/voucher');
$voucher_info = $this->model_checkout_voucher->getVoucher($this->session->data['voucher']);
if ($voucher_info) {
if ($voucher_info['amount'] > $total) {
$amount = $total;
} else {
$amount = $voucher_info['amount'];
}
$total_data[] = array(
'code' => 'voucher',
'title' => sprintf($this->language->get('text_voucher'), $this->session->data['voucher']),
'text' => $this->currency->format(-$amount),
'value' => -$amount,
'sort_order' => $this->config->get('voucher_sort_order')
);
$total -= $amount;
Code: Select all
$this->load->model('checkout/voucher');
foreach (array_unique($this->session->data['voucher']) as $voucher) {
$voucher_info = $this->model_checkout_voucher->getVoucher($voucher);
if ($voucher_info) {
if ($voucher_info['amount'] > $total) {
$amount = $total;
} else {
$amount = $voucher_info['amount'];
}
$total_data[] = array(
'code' => 'voucher',
'title' => sprintf($this->language->get('text_voucher'), $voucher),
'text' => $this->currency->format(-$amount),
'value' => -$amount,
'sort_order' => $this->config->get('voucher_sort_order')
);
$total -= $amount;
}
You'll also need to go into the template for the checkout.cart.tpl (depending on if you are using a custom one or the default) and remove the echo $voucher code from the input field i.e.
Code: Select all
<input type="text" name="voucher" value="<?php echo $voucher; ?>" />
Code: Select all
<input type="text" name="voucher" value="<?php //echo $voucher; ?>" />
Hey Spencer,
many thanks for looking at this and providing a fix, website building has stalled for the moment as I'm prepping for a big assessment, but looking forward to getting back to work on the website with one less thing to sort : )
many thanks for looking at this and providing a fix, website building has stalled for the moment as I'm prepping for a big assessment, but looking forward to getting back to work on the website with one less thing to sort : )
Could the same process be applied to coupons instead of vouchers? The code looks very similar between them, but its also just enough off that I could not just replace the word Voucher with Coupon in all instances.spennyw wrote:Hi,
It's reasonably simple.
If you have the time to post the code to do it with coupons I would be grateful. If you are too busy, I would be willing to pay for your services.
Well, this not worked in my test Opencart 1.5.3 but I found working solution as well.spennyw wrote:...modify catalog/model/total/voucher.php
Kind regards, SpencerCode: Select all
$this->load->model('checkout/voucher'); foreach (array_unique($this->session->data['voucher']) as $voucher) { $voucher_info = $this->model_checkout_voucher->getVoucher($voucher); if ($voucher_info) { if ($voucher_info['amount'] > $total) { $amount = $total; } else { $amount = $voucher_info['amount']; } $total_data[] = array( 'code' => 'voucher', 'title' => sprintf($this->language->get('text_voucher'), $voucher), 'text' => $this->currency->format(-$amount), 'value' => -$amount, 'sort_order' => $this->config->get('voucher_sort_order') ); $total -= $amount; }
You need first set $voucher into array:
Code: Select all
$this->load->model('checkout/voucher');
$voucher = array();
foreach (array_unique($this->session->data['voucher']) as $voucher) {
$voucher_info = $this->model_checkout_voucher->getVoucher($voucher);
if ($voucher_info) {
if ($voucher_info['amount'] > $total) {
$amount = $total;
} else {
$amount = $voucher_info['amount'];
}
$total_data[] = array(
'code' => 'voucher',
'title' => sprintf($this->language->get('text_voucher'), $voucher),
'text' => $this->currency->format(-$amount),
'value' => -$amount,
'sort_order' => $this->config->get('voucher_sort_order')
);
$total -= $amount;
}
Hi I've been looking at extensions as I'm not familiar with coding. Can anyone suggest one that will allow the customer to enter 2 voucher codes in 1 order. Say 10% off one product group and 15% off another.
Who is online
Users browsing this forum: No registered users and 25 guests