You are here:  » Voucher Codes for the whole merchant


Voucher Codes for the whole merchant

Submitted by McCloud on Wed, 2020-06-10 10:48 in

Hello David,

i tried out the voucher code and there i have following proplem. Many merchant have only offers, like: " Every new buyer will get 10% " or " 20% on every product. Use Code XXXxxxXXX "

Is it possible to show the merchant, the code and then the link direct to the merchants page?

Thank you very much, Peter

Submitted by support on Wed, 2020-06-10 11:20

Hi Peter,

You can enter a Minimum Spend of 0.00 for a voucher code to apply to all products and even though the Description box indicates "for discount type Other" you can still enter qualification text here e.g. "new customers only" and this will show up on the product page.

To add the description text to the main voucher codes page regardless of discount type, edit vouchers.php and look for the following code at line 64:

      $vouchers[$k]["text"] .= " ".translate("using voucher code")." <strong>".$voucher["code"]."</strong>";

...and REPLACE with:

      $vouchers[$k]["text"] .= " ".translate("using voucher code")." <strong>".$voucher["code"]."</strong>";
      if ($voucher["discount_text"])
      {
        $vouchers[$k]["text"] .= " (".$voucher["discount_text"].")";
      }

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by McCloud on Wed, 2020-06-10 14:17

Hello David,

if i dont choose a product it will show nothing from the merchant. Here you can see it if you click on the view products buttom: {link saved}

I would like it more, if the view products buttom will send me to the merchant shop with the affiliate link.

Is it possible too, to see the start and ending time in the description?

And i dont see the voucher code link on the home page. Where i can activate this?

Regards, Peter

Submitted by support on Wed, 2020-06-10 16:09

Hi Peter,

Whilst the admin area voucher codes interface and vouchers.php are active by default, the home page link and actual application of voucher codes to products (so they appear in search results) needs to be enabled by setting $config_useVoucherCodes in config.advanced.php at line 41.

There are 2 levels of support, check the documentation on this page to decide which will be best for you but for getting started and to see link / search results right away without having to re-import feeds you can use level 1 e.g.

  $config_useVoucherCodes = 1;

To add the valid until date, immediately following the modification described above to show the discount text, add the following code:

      if ($voucher["valid_to"])
      {
        $vouchers[$k]["text"] .= " Valid until ".date("Y-m-d",$voucher["valid_to"]);
      }

You can format the date however you like, check the PHP date() function documentation for the formatting codes here.

Regarding a direct link to the merchant, this has been requested a number of times so I am going to add support for this to the next distribution which I am currently preparing - watch this space...

Cheers,
David.
--
PriceTapestry.com

Submitted by McCloud on Thu, 2020-06-11 10:41

Hello David,

thank you very much for you time.

Where i can activate the Voucher Code - Link on the main page?

Regards, Peter

Submitted by support on Thu, 2020-06-11 11:09

Hi Peter,

Check your html/menu.php - it should have the following line;

        <?php if (isset($config_useVoucherCodes) && $config_useVoucherCodes): ?><li><a href='<?php print $config_baseHREF?>vouchers.php'><i class='fi-ticket'></i> <?php print translate("Voucher Codes"); ?></a></li><?php endif; ?>

...but if not in the template version you are using, look for the code that shows the Shopping List link...

        <?php if (isset($config_useShoppingList) && $config_useShoppingList): ?><li><a href='<?php print tapestry_shoppingListHREF(); ?>'><i class='fi-shopping-cart'></i> <?php print translate("My Shopping List"); ?> (<?php $menu_shoppingList tapestry_shoppingList(); print count($menu_shoppingList); ?>)</a></li><?php endif; ?>

...and then insert the line for the Voucher Codes link before or after that line as you prefer...

Cheers,
David.
--
PriceTapestry.com

Submitted by McCloud on Thu, 2020-06-11 11:26

Hello David,

i have only this code:

<?php
          $shoppingListCookie = "shoppingList".bin2hex($config_baseHREF);
          $shoppingListCount = (isset($_COOKIE[$shoppingListCookie])?count(unserialize($_COOKIE[$shoppingListCookie])):"0");
        ?>
        <li><a href='<?php print $config_baseHREF?>shoppingList.php'><i class='fi-shopping-cart'></i> <?php print translate("My Shopping List"); ?> (<?php print $shoppingListCount?>)</a>

and i wont make any mistake. Can you help me, where i put in the new code?

Regards, Peter

Submitted by support on Thu, 2020-06-11 11:39

Hi Peter,

For your template, REPLACE that code with

<?php if (isset($config_useVoucherCodes) && $config_useVoucherCodes): ?>
  <li><a href='<?php print $config_baseHREF?>vouchers.php'><i class='fi-ticket'></i> <?php print translate("Voucher Codes"); ?></a></li>
<?php endif; ?>
<?php
          $shoppingListCookie = "shoppingList".bin2hex($config_baseHREF);
          $shoppingListCount = (isset($_COOKIE[$shoppingListCookie])?count(unserialize($_COOKIE[$shoppingListCookie])):"0");
        ?>
        <li><a href='<?php print $config_baseHREF?>shoppingList.php'><i class='fi-shopping-cart'></i> <?php print translate("My Shopping List"); ?> (<?php print $shoppingListCount?>)</a>

Cheers,
David.
--
PriceTapestry.com

Submitted by McCloud on Sun, 2020-06-14 23:51

Hello David,

i tried everything, but on the voucher codes page {link saved} some links working well and at others i have a blank page. And i dont do other things at the codes who are working.

Is it very complicated to take a link direct to the merchant page (shop) with a Deeplink Tracking link which i get from awin?

Thank you very much and regards, Peter

Submitted by support on Mon, 2020-06-15 08:00

Hello Peter,

My apologies it should have occurred to me earlier that this is already documented on the forum - please see this comment / thread (I have just updated the line numbers for the latest distribution).

This will add a "link" field to the vouchers table, so you can enter a specific affiliate link to go direct to the merchant site from vouchers.php.

If you only wanted the functionality like this, you can "disable" voucher code integration by changing line 41 in config.advanced.php back to;

  $config_useVoucherCodes = 0;

And then in html/menu.php, after the changes described above where you have this line:

<?php if (isset($config_useVoucherCodes) && $config_useVoucherCodes): ?>

...REPLACE with:

<?php if (TRUE): ?>

...and then the link will always show.

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by McCloud on Mon, 2020-06-15 11:10

Hello David,

i did everything step by step, but if i whant to ad a new code it will dont save in the database.

Reagards, Peter

Submitted by McCloud on Mon, 2020-06-15 12:22

Sry David,

it was my fault, i forgott a , - but now i dont see the merchant banner on the left side.

And is it possible to insert the link automaticly at register the codes?

Regards Peter

Edit: I found the problem with the banner and fixed it.

Submitted by support on Mon, 2020-06-15 12:26

Hi Peter,

Regarding the merchant banner missing after the modification, can you check the following code is still in place, it should begin at line 12, immediately before the modification to vouchers.php. If this was accidentally deleted that would remove the banners...

      if (file_exists("logos/".$voucher["merchant"].$config_logoExtension))
      {
        $vouchers[$k]["logo"] = $config_baseHREF."logos/".str_replace(" ","%20",$voucher["merchant"]).$config_logoExtension;
      }

To insert the link automatically from a voucher codes feed, first run the following dbmod.php script in the top level folder of your Price Tapestry installation and then delete the file:

<?php
  
require("includes/common.php");
  
$sql "ALTER TABLE `".$config_databaseTablePrefix."voucherfeeds`
            ADD `field_link` VARCHAR(255) NOT NULL default ''"
;
  
database_queryModify($sql,$result);
  print 
"Done.";
?>

Edit config.advanced.php and look for the following code at line 64:

  $config_voucherCodesFieldSet["description"] = "Description";

...and REPLACE with:

  $config_voucherCodesFieldSet["description"] = "Description";
  $config_voucherCodesFieldSet["link"] = "link";

Edit admin/voucher_feeds_register_step2.php and look for the following code at line 146:

  $skipFields = array("valid_from","valid_to");

...and REPLACE with:

  $skipFields = array("valid_from","valid_to","link");

Edit admin/voucher_feeds_register_step3.php and look for the following code at line 50:

      field_description = '".database_safe($_POST["field_description"])."',

...and REPLACE with:

      field_description = '".database_safe($_POST["field_description"])."',
      field_link = '".database_safe($_POST["field_link"])."',

And finally edit admin/voucher_codes_edit.php and look for the following code at line 254:

      $description = $voucherRecord[$voucherfeed["field_description"]];

...and REPLACE with:

      if (isset($voucherRecord[$voucherfeed["field_link"]]))
      {
        $_POST["link"] = $voucherRecord[$voucherfeed["field_link"]];
      }
      $description = $voucherRecord[$voucherfeed["field_description"]];

Then re-register your voucher code feed(s) to map the link field and it will auto-populate like the other fields...

Cheers,
David.
--
PriceTapestry.com

Submitted by McCloud on Mon, 2020-06-15 12:39

Hello David,

you are a wizzard. Everything works perfect and i love the script and your support.

The only and i hope the last thing is, can you give me the code to open the merchant site in a new window?

Thank you very much, Peter

Submitted by support on Mon, 2020-06-15 12:49

Hi Peter,

Thank you for your comments!

To make the link open in new window, edit html/coupons.php and look for the following code at line 37:

  <a class='button tiny radius secondary' href='<?php print $voucher["href"]; ?>'><?php print translate("View Products"); ?></a>

...and REPLACE with;

  <a target='_blank' class='button tiny radius secondary' href='<?php print $voucher["href"]; ?>'><?php print translate("View Products"); ?></a>

Cheers,
David.
--
PriceTapestry.com

Submitted by McCloud on Mon, 2020-06-15 13:39

Hello David,

its me again. Is it possible too, to get the "description" during the register into "discount_text" automaticly?

thank you very much, Peter

Submitted by support on Mon, 2020-06-15 14:03

Hi Peter,

Sure - edit admin/voucher_codes_edit.php and look for the following code at line 259:

      $description = $voucherRecord[$voucherfeed["field_description"]];

...and REPLACE with:

      $description = $voucherRecord[$voucherfeed["field_description"]];
      $_POST["discount_text"] = $voucherRecord[$voucherfeed["field_description"]];

Cheers,
David.
--
PriceTapestry.com