You are here:  » Same voucher code with different MOV & Discount

Active Forum Topics


Same voucher code with different MOV & Discount

Submitted by sirmanu on Tue, 2019-09-24 13:57 in

Hi David.
I use voucher codes functionality quite often.

I was wondering if this feature can be implemented.

I have some merchants that, depending on how much you spend, you get some discount or other. The voucher code is the same.

For instance.
If you spend 75€, you get 10€ discount. If you spend 150€, 15€. If you spend 300€, 20€. Is a bit messy because I have to copy and paste.

Usually, I have to repeat this procedure three times and only modify minimum spent and discount.

Is any way we can modify the functionality so we can handle this situation in the same voucher_codes_edit.php? Maybe with some separator in the fields?

Best regards

Submitted by support on Wed, 2019-09-25 10:26

Hi,

It's straight forward to make a Duplicate function which will save having to copy and paste - to do this, create a new file admin/voucher_codes_duplicate.php containing:

<?php
  
require("../includes/common.php");
  
$admin_checkPassword TRUE;
  require(
"../includes/admin.php");
  
$sql "DESC `".$config_databaseTablePrefix."vouchers`";
  
database_querySelect($sql,$rows);
  
array_shift($rows);
  
$fields = array();
  foreach(
$rows as $row)
  {
      
$fields[] = $row["Field"];
  }
  
$fieldList implode(",",$fields);
  
$id $_GET["id"];
  
$sql "INSERT INTO `".$config_databaseTablePrefix."vouchers` (".$fieldList.") SELECT ".$fieldList." FROM `".$config_databaseTablePrefix."vouchers` WHERE id='".database_safe($id)."'";
  
database_queryModify($sql,$insertId);
  
header("Location: voucher_codes_edit.php?id=".$insertId);
  exit();
?>

Then edit admin/voucher_codes.php and look for the following code at line 234:

      admin_tool("Delete","voucher_codes_delete.php?id=".$voucher["id"],TRUE,FALSE);

...and REPLACE with:

      admin_tool("Delete","voucher_codes_delete.php?id=".$voucher["id"],TRUE,FALSE);
      admin_tool("Duplicate","voucher_codes_duplicate.php?id=".$voucher["id"],TRUE,FALSE);

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by sirmanu on Fri, 2019-09-27 09:40

This is awesome!!!
Thank you very much David