You are here:  » New tapestry function for voucher code

Active Forum Topics

New tapestry function for voucher code

Submitted by sirmanu on Wed, 2018-04-11 14:16 in

Hi David. I am looking for a small variation of tapestry_applyVoucherCodes function (using config_useVoucherCodes = 1).
I just want to know, if any voucher code exists and it is valid for a given normalised name.
So, for example, a function called tapestry_anyVoucherCodesForProductName($normalised_name) would return TRUE or FALSE if for that given name, there is any coupon code. It doesn't matter the price, or the merchant, just true or false.

Submitted by support on Wed, 2018-04-11 14:35


This function will do the trick..

  function anyVoucherCodesFor($normalised_name)
    global $config_databaseTablePrefix;
    $sql = "SELECT * FROM `".$config_databaseTablePrefix."products`
              WHERE normalised_name = '".database_safe($normalised_name)."'";
    if (database_querySelect($sql,$products))
      $products = tapestry_applyVoucherCodes($products);
      foreach($products as $product)
        if ($product["voucher_code"]) return TRUE;
    return FALSE;


Submitted by sirmanu on Thu, 2018-04-12 10:01

It works as expected, David.