Jump to content

[SOLVED]Birthday present: Problem using the voucher


Recommended Posts

Hello,

I have set up the Birthday present module, set up a cron and everything goes great. I receive the voucher code, but the problem comes when I enter the code. I get an error message that says:
1. this voucher can only be used in the following currency:

Any idea about this problem?

Thanks a lot in advance!

Link to comment
Share on other sites

The PrestaShop team did this on purpose to work around a bug in the voucher calculations. They decided that it is highly likely that customers will use vouchers in the same currency that they purchased in, so they thought it was acceptable to make it so that vouchers can't be used in a currency other than the one that was used in the purchase that generated the voucher.

Link to comment
Share on other sites

Thank you anyway.

I have checked the database and for the Birthday voucher the currency is 0. But it's 0 also for other vouchers manually generated. It's 1 for the Fidelity Vouchers.

I have also checked birthdaypresent.php, and I think that the voucher is generated here:

    public function createTodaysVouchers()
   {
       $users = Db::getInstance()->ExecuteS('
       SELECT DISTINCT c.id_customer, firstname, lastname, email
       FROM '._DB_PREFIX_.'customer c
       LEFT JOIN '._DB_PREFIX_.'orders o ON (c.id_customer = o.id_customer)
       WHERE o.valid = 1
       AND c.birthday LIKE \'%'.date('-m-d').'\'');

       foreach ($users as $user)
       {
           $voucher = new Discount();
           $voucher->id_customer = intval($user['id_customer']);
           $voucher->id_discount_type = intval(Configuration::get('BIRTHDAY_DISCOUNT_TYPE'));
           $voucher->name = 'CUMPLE-'.intval($voucher->id_customer).'-'.date('Y');
           $voucher->description[intval(Configuration::get('PS_LANG_DEFAULT'))] = $this->l('Your birthday present !');
           $voucher->value = Configuration::get('BIRTHDAY_DISCOUNT_VALUE');
           $voucher->quantity = 1;
           $voucher->quantity_per_user = 1;
           $voucher->cumulable = 1;
           $voucher->cumulable_reduction = 1;
           $voucher->date_from = date('Y-m-d');
           $voucher->date_to = strftime('%Y-%m-%d', strtotime('+1 month'));
           $voucher->minimal = Configuration::get('BIRTHDAY_MINIMAL_ORDER');
           $voucher->active = true;
           if ($voucher->add())
               Mail::Send(intval(Configuration::get('PS_LANG_DEFAULT')), 'birthday', $this->l('Happy birthday!'), array('{firstname}' => $user['firstname'], '{lastname}' => $user['lastname']), $user['email'], NULL, strval(Configuration::get('PS_SHOP_EMAIL')), strval(Configuration::get('PS_SHOP_NAME')), NULL, NULL, dirname(__FILE__).'/mails/');
           else
               echo Db::getInstance()->getMsgError();
       }
   }



But I don't see any reference to a currency here. If I go to Discount.php there it says that the currency type is only set for those Discounts type 2 (on quantity), so for the rest the currency type is not set.

I will try to set the Birthday discount on amount instead that setting it on % in order to see if it works.

Link to comment
Share on other sites

I changed the birdthay present from % to a fix amount (5€) and the problem remains.
I have checked the database and the voucher is saved with a currency_id of 0 (but the manually created ones are also saved as 0 and they don't give any problem)

If I manually change the currency_id from 0 to 1 (the id of Euro) the the birdthay voucher code gives no problem at all.

Any ideas about how to solve this problem?


Thank you in advance.

Link to comment
Share on other sites

  • 2 months later...

I have checked the database and the voucher is saved with a currency_id of 0 (but the manually created ones are also saved as 0 and they don't give any problem)

If I manually change the currency_id from 0 to 1 (the id of Euro) the the birdthay voucher code gives no problem at all.

Thank you in advance.


Hi Juandbbam,

Thanks for your help

I have the same problem as you had with the birthday voucher but I can't see any relations between my discount table and id_currency in my database.

Could you please tell me where I can modify it manually in the database?

thks
Link to comment
Share on other sites

  • 6 months later...

I have checked the database and the voucher is saved with a currency_id of 0 (but the manually created ones are also saved as 0 and they don't give any problem)

If I manually change the currency_id from 0 to 1 (the id of Euro) the the birdthay voucher code gives no problem at all.

Thank you in advance.


Hi Juandbbam,

Thanks for your help

I have the same problem as you had with the birthday voucher but I can't see any relations between my discount table and id_currency in my database.

Could you please tell me where I can modify it manually in the database?

thks


I am still having the same problem,
no clear solution for currency problem on vouchers by amount (not % percentage)
the error is: this voucher can only be used in the following currency

which part of db, i have to change id_currency from "0" to "1" ?
coz there is no dropdown menu to set the curreny while creating new voucher by amount, on PS version 1.3.1

thanks for your kindly help.
anyone help
Link to comment
Share on other sites

Finally i have solved the problem:

on classes folder - discount.php , i have changed (there are 2 lines including this code)
['id_currency'] = intval($this->id_currency); replaced
['id_currency'] = 1 /id number of your currency/

be sure that u type the correct currency id, check it on BO-payment-currencies

so now voucher by amount is working without getting the (this voucher can only be used in the following currency) error on PS 1.3.1

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...