archproject Posted December 30, 2010 Share Posted December 30, 2010 Hi all, when we transform the loyalty ;points to a voucher how can I set the default to have the voucher only valid for 30 daysand it's not cumulativeArchprojectEDITED :go to modules/loyalty/loyalty-program.phpand change the below code accordingly (the once with excessive *****************) /* voucher creation and add to customer */ $voucher = new Discount(); $voucher->name = $voucherCode; $voucher->id_discount_type = 2; // Discount on order (amount) $voucher->id_customer = intval($cookie->id_customer); $voucher->id_currency = intval($cookie->id_currency); $voucher->value = LoyaltyModule::getVoucherValue($customerPoints); $voucher->quantity = 1; $voucher->quantity_per_user = 1; *****************$voucher->cumulable = 0; $voucher->cumulable_reduction = 1; $dateFrom = time(); if (Configuration::get('PS_ORDER_RETURN')) $dateFrom = $dateFrom + (60 * 60 * 24 * intval(Configuration::get('PS_ORDER_RETURN_NB_DAYS'))); $voucher->date_from = date('Y-m-d H:i:s', $dateFrom); /*$voucher->date_to = date('Y-m-d H:i:s', $dateFrom + 31536000);*/ // + 1 year *****************$voucher->date_to = date('Y-m-d H:i:s', $dateFrom + 2592000); // 30 days $voucher->minimal = 5; $voucher->active = 1; $languages = Language::getLanguages(true); $default_text = Configuration::get('PS_LOYALTY_VOUCHER_DETAILS', intval(Configuration::get('PS_LANG_DEFAULT'))); foreach ($languages as $language) { $text = Configuration::get('PS_LOYALTY_VOUCHER_DETAILS', intval($language['id_lang'])); $voucher->description[intval($language['id_lang'])] = $text ? strval($text) : strval($default_text); } $voucher->save(); Link to comment Share on other sites More sharing options...
TWDesign Posted July 10, 2012 Share Posted July 10, 2012 (edited) I've noticed there is a problem with the loyalty program in so much as. a) Customers can earn loyalty points immediately. b ) They can redeem those points for a voucher code immediately c) They have to wait a minimum 24 hours before they can "use" the voucher. I understand the thinking behind it. The Prestashop developers don't want customers to buy goods, instantly earn points, use those points for a second purchase then, return the original goods on some bogus pretense, thereby scamming the system. However, what about the (in my opinion fairly typical) user who accrues points, then at some LATER date, wants to convert those points into a voucher. If he/she does so and THEN tries to process a second order, they are hit with the disappointing (and confusing) error message, "voucher not valid yet". My reaction when this happened to me was "WTF"? It would seem more logical for the original "points" to be held in limbo for some predetermined period before they are turned into "real" points. Does anyone know an easy way to do that? Failing that, if you have enough convidence that you won't be the victim of scammers and you would like customers to be able to use their points right away, rather than twiddling their thumbs for 24 hours (good grief!), then you can try this. Find the "loyalty-program.php" file in the loyalty program module. Find this line (about line 73) $dateFrom += 60 * 60 * 24 * (int)Configuration::get('PS_ORDER_RETURN_NB_DAYS'); Comment it out and create the new line immediately below. //$dateFrom += 60 * 60 * 24 * (int)Configuration::get('PS_ORDER_RETURN_NB_DAYS'); $dateFrom = $dateFrom; Haven't tested it yet, but it should work I think. btw running PS 1.4.7.3 Also see this thread for additional reference http://www.prestasho...-not-yet-valid/ Edited July 10, 2012 by TWDesign (see edit history) Link to comment Share on other sites More sharing options...
TWDesign Posted July 13, 2012 Share Posted July 13, 2012 UPDATE: For some reason I can't fathom, the above did NOT work. But there is an alternative solution as suggested here http://www.prestashop.com/forums/topic/14162-loyalty-voucher-points/ I think it's a bit less robust because it presumes that the "returns" period will not change and so it's OK to hard code that into the system. So in my case I changed line 76 (or thereabouts) from $voucher->date_from = date('Y-m-d H:i:s', $dateFrom); to $voucher->date_from = date('Y-m-d H:i:s', $dateFrom - 86400); // dont wait for one day Link to comment Share on other sites More sharing options...
winthur Posted September 26, 2012 Share Posted September 26, 2012 Hi all, when we transform the loyalty ;points to a voucher how can I set the default to have the voucher only valid for 30 days and it's not cumulative Archproject EDITED : go to modules/loyalty/loyalty-program.php and change the below code accordingly (the once with excessive *****************) /* voucher creation and add to customer */ $voucher = new Discount(); $voucher->name = $voucherCode; $voucher->id_discount_type = 2; // Discount on order (amount) $voucher->id_customer = intval($cookie->id_customer); $voucher->id_currency = intval($cookie->id_currency); $voucher->value = LoyaltyModule::getVoucherValue($customerPoints); $voucher->quantity = 1; $voucher->quantity_per_user = 1; *****************$voucher->cumulable = 0; $voucher->cumulable_reduction = 1; $dateFrom = time(); if (Configuration::get('PS_ORDER_RETURN')) $dateFrom = $dateFrom + (60 * 60 * 24 * intval(Configuration::get('PS_ORDER_RETURN_NB_DAYS'))); $voucher->date_from = date('Y-m-d H:i:s', $dateFrom); /*$voucher->date_to = date('Y-m-d H:i:s', $dateFrom + 31536000);*/ // + 1 year *****************$voucher->date_to = date('Y-m-d H:i:s', $dateFrom + 2592000); // 30 days $voucher->minimal = 5; $voucher->active = 1; $languages = Language::getLanguages(true); $default_text = Configuration::get('PS_LOYALTY_VOUCHER_DETAILS', intval(Configuration::get('PS_LANG_DEFAULT'))); foreach ($languages as $language) { $text = Configuration::get('PS_LOYALTY_VOUCHER_DETAILS', intval($language['id_lang'])); $voucher->description[intval($language['id_lang'])] = $text ? strval($text) : strval($default_text); } $voucher->save(); Is there a method like the one above for rprestashop 1.5? i tried but not working. not for the cumulative as well as the year to month. am not a programmer will appreciate if you could shed some light Link to comment Share on other sites More sharing options...
Kt Posted October 10, 2012 Share Posted October 10, 2012 Hi! How can you do this: After ordering the buyer accumulate points. Only after 5 orders points can be converted into a voucher. 1 Link to comment Share on other sites More sharing options...
winthur Posted October 11, 2012 Share Posted October 11, 2012 Hi! How can you do this: After ordering the buyer accumulate points. Only after 5 orders points can be converted into a voucher. Hi Kt, Thanks for your responds. and how/where can i configure that? Kindly let me know and further understand. how it work. Thank you for the time. Reg Winthur Link to comment Share on other sites More sharing options...
Pippo3000 Posted October 11, 2012 Share Posted October 11, 2012 go to modules/loyalty/loyalty-program.php and change the below code accordingly (the once with excessive *****************) hi. thanks. would the same above also apply to referral program vouchers? Realized that those are also valid 1 year when an existing customer refers a new customer Link to comment Share on other sites More sharing options...
winthur Posted October 14, 2012 Share Posted October 14, 2012 (edited) Hi, Update for 1.5.1 users to change voucher validity period. Besides changing the number to 2592000 in loyalty-program.php. You will also need to go to modules/loyalty/controllers/front/default.php and change 1 year to 1 month. then your voucher will auto generate 1 month period everytime a customer transform points to voucher. Winthur This however dont work for referral program. Edited October 14, 2012 by winthur (see edit history) 1 Link to comment Share on other sites More sharing options...
xenontj Posted August 11, 2013 Share Posted August 11, 2013 Hi all, when we transform the loyalty ;points to a voucher how can I set the default to have the voucher only valid for 30 days and it's not cumulative Archproject EDITED : go to modules/loyalty/loyalty-program.php and change the below code accordingly (the once with excessive *****************) /* voucher creation and add to customer */ $voucher = new Discount(); $voucher->name = $voucherCode; $voucher->id_discount_type = 2; // Discount on order (amount) $voucher->id_customer = intval($cookie->id_customer); $voucher->id_currency = intval($cookie->id_currency); $voucher->value = LoyaltyModule::getVoucherValue($customerPoints); $voucher->quantity = 1; $voucher->quantity_per_user = 1; *****************$voucher->cumulable = 0; $voucher->cumulable_reduction = 1; $dateFrom = time(); if (Configuration::get('PS_ORDER_RETURN')) $dateFrom = $dateFrom + (60 * 60 * 24 * intval(Configuration::get('PS_ORDER_RETURN_NB_DAYS'))); $voucher->date_from = date('Y-m-d H:i:s', $dateFrom); /*$voucher->date_to = date('Y-m-d H:i:s', $dateFrom + 31536000);*/ // + 1 year *****************$voucher->date_to = date('Y-m-d H:i:s', $dateFrom + 2592000); // 30 days $voucher->minimal = 5; $voucher->active = 1; $languages = Language::getLanguages(true); $default_text = Configuration::get('PS_LOYALTY_VOUCHER_DETAILS', intval(Configuration::get('PS_LANG_DEFAULT'))); foreach ($languages as $language) { $text = Configuration::get('PS_LOYALTY_VOUCHER_DETAILS', intval($language['id_lang'])); $voucher->description[intval($language['id_lang'])] = $text ? strval($text) : strval($default_text); } $voucher->save(); thanks, works perfectly in prestashop 1.5.3.1 Link to comment Share on other sites More sharing options...
kelvz Posted August 12, 2013 Share Posted August 12, 2013 Hi! is there a configuration for this? Do not let customer to use voucher if the total order is less than the value of voucher. Do not create a new voucher with the remaining amount. Thanks! Link to comment Share on other sites More sharing options...
silentRun Posted August 31, 2013 Share Posted August 31, 2013 Hello, I know that my question is not exactly related with the thread. But I am modifying the prestashop referral module a bit, in order to make the vouchers generated by referral system, "incompatible"with some other defaults voucher code I have... But looking on the cartRule class, I don't see any rule to find out how to do this .... any idea ? Thanks a lot in advance Link to comment Share on other sites More sharing options...
hermit75 Posted February 14, 2014 Share Posted February 14, 2014 Also, don't forget the following situation, for both of these scenarios, based on whether you have modified core code or not: The situation outlined below applies to both of these scenarios: Scenario 1. voucher is available immediately after conversion (perhaps you hacked code to allow this) Scenario 2. voucher use is delayed for a time period, after conversion The situation: 1. Customer buys something and pays. Merchants accepts payment. 2. Customer now has the loyalty points. 3. Customer converts points to a voucher. 4. Customer returns merchandise within RMA period (for example, within 14 days) 5. The merchant must remember to disable that voucher. You must remember to disable the voucher that was created. - This is because the loyalty points were already converted to a voucher. Even though you did a Refund and wiped out any trace of the voucher from the customer's Loyalty Point area of his account, the voucher has already been created, and it exists -- and is 'available' -- in the Voucher area of the customer's account. In Scenario 1, a dishonest customer could use the voucher immediately. In fact, he could use the voucher even before the RMA return. This is the risk, albeit an understandable risk, of allowing use of vouchers immediately after conversion. In Scenario 2, a dishonest customer could use the voucher after the waiting period. As others have said, the correct way for PrestaShop to code this, would be to force a time delay period (matching the RMA period) for converting the Loyalty Points to a Voucher. And allowing immediate use of the Voucher whenever a customer is able to accomplish a conversion. This would solve all problems. When merchandise gets returned within RMA period, loyalty points get wiped out, no voucher has been created, and the universe would be perfect. If customer remembers six months after a purchase, that he can make a conversion from points to voucher, then in that case, voucher would be immediately available for use, and the universe would be perfect. Link to comment Share on other sites More sharing options...
Sam Minerve Posted July 31, 2014 Share Posted July 31, 2014 Hi, I think the solution suggested by hermit75 in Scenario 2 is the best. Indeed, if the customer is allowed to convert the loyalty points into a voucher only after the RMA period, then, many problems would be avoided. But how do you code this ? I think you have to add the RMA period (for example 14 days) to the order status corresponding to the points conversion but I can't find out how to do this. Any idea, please ? Thanks in advance. Link to comment Share on other sites More sharing options...
hermit75 Posted July 31, 2014 Share Posted July 31, 2014 (edited) Sam, Scenario number 2 is already in place as the default PS code. The problem with it: - RMA period is 14 days. - at 21 days, an honest customer decides to convert loyalty points to a voucher - the current PS problem: customer is then forced to wait 14 days to use the voucher. If the customer had converted LP to voucher immediately when LP were earned, then RMA period and voucher-use wait period would coincide, but customers cannot be expected to be that much on top of things. My post was meant to illustrate the inadequacies of both Scenarios, and to identify the correct scenario of coding that simply establishes a wait period on the act of conversion that is identical to the RMA period (with NO wait period on voucher use after conversion is successfully accomplished). I have hacked my code to allow immediate use of the voucher after conversion, so that the customer who converts six months after a purchase, does not have to wait to use the voucher. I just keep an eye on things for dishonest customers, and with my low sales volume, I don't have any troubles. A seller with larger sales volume could see problems, but even then, checking the vouchers that are being used against the customers who did RMAs, might still be a manageable solution to avoid theft. I have not tackled the problem of developing the correct code. I don't need it in my store, so I have decided not to spend the time on it. PS does need to spend the time on it, if they haven't done so yet. I don't know what the code looks like in 1.6. Edited July 31, 2014 by hermit75 (see edit history) Link to comment Share on other sites More sharing options...
Sam Minerve Posted July 31, 2014 Share Posted July 31, 2014 Hi hermit75, Thank you for your reply. Sorry, I forgot to mention that I use Prestashop 1.6 and version 1.15 of Loyalty module. In the current version of this module, the voucher is valid from the date on which the order was placed, no matter when the LP were converted. To give an example : You place an order on July 10. The RMA period is 14 days. So the voucher is valid from July 24. You can convert your LP on July 13 or July 30, or whenever you want, it doesn't matter, the voucher would still be available for use from July 24. BUT the issue is that by default, the LP are transformable into vouchers when the order is shipped. Ok, you can choose the possibility of converting LP when the order is paid but in all cases the problem is that LP can be converted into vouchers BEFORE the RMA period. Which doesn't make sense since the voucher is only available after the RMA period. Moreover, things get complicated in case of merchandise returns. That's why, the solution of allowing LP conversion only after the RMA period would be appropriate. So I thought to solve the issue by adding 14 days to the order delivery state but maybe there's a better way to do this. In "loyalty.php" file, I found this line (l.191) : $this->loyaltyStateValidation->id_order_state = (int)(Tools::getValue('id_order_state_validation')); I think it corresponds to the order state allowing LP conversion but how to add 14 days to it ? P.S. : Sorry for the mistakes, English is not my native language. Link to comment Share on other sites More sharing options...
hermit75 Posted August 1, 2014 Share Posted August 1, 2014 (edited) No worries. Your English is very good. The vouchers are not tied directly to individual transactions (other than summing the LPs), so "adding 14 days" to the voucher "date the conversion is allowed" (to delay the conversion action) would not be appropriate. For example, a customer can have 10 transactions that earned LPs, and then the customer does the conversion-to-voucher of all the LPs at once. It would be way too complicated to determine if one or more of the transactions is still in the RMA period, and, if so, then "forward date" the allowed conversion date by 14 days, from the date of the most recent transaction that is still in the RMA period. Sounds complicated, huh? OK, let's forget about that. I have a better solution for you below. First, though, I need to say something about the voucher "usability" date. I use PS 1.4.11.0 with Loyalty module 1.8. I have not seen a version LP module 1.15 that is newer than mine, so I am not sure what you mean. However, the loyalty module that came with PS 1.6.0.1 also contains the same feature/problem that I described earlier. Namely, when the customer performs the conversion (no matter when the conversion occurs), he must wait the RMA-period (for example, 14 days) from the time that the conversion occurs, no matter when the conversion occurred. PS long ago chose to add the RMA-time-period wait to a newly-created voucher, from the moment the voucher was created, to prevent customers from quickly converting and using a voucher, before the RMA period had elapsed. This was a bad way to handle it, because the customer might wait 6 months after the last of those 10 transactions, to create the voucher. Then, the customer has to wait an additional 14 days, even though the RMA periods ended 5.5 months ago! I believe all Loyalty modules after PS 1.4.11.0 are still coded this way. This problem is why I chose to remove the amount of RMA wait period that was being added to the voucher "date_from" parameter. If your "date_from" parameter is behaving like this, then you should consider this fix also, so that customers who convert 6 months down the road, do not have to wait an additional 14 days in order to use their voucher. This is my modified code from loyalty-program.php (approx. line 72): if (Configuration::get('PS_ORDER_RETURN')) $dateFrom += 60 * 60 * 24 * (int)Configuration::get('PS_ORDER_RETURN_NB_DAYS'); $voucher->date_from = date('Y-m-d H:i:s', $dateFrom - 1209600); // back off 14 days for immediate use of voucher -hermit75 $voucher->date_to = date('Y-m-d H:i:s', $dateFrom + 31536000); // + 1 year [] This modification solves the waiting problem for the customer who creates the voucher six months after the transactions, but this modification also introduces the new problem, that a dishonest customer could quickly create and use a voucher, and then send the original merchandise back for a refund. I just have to keep my eye on things, and I have low sales volume, so it is not a problem.The proper way to handle this whole situation: prevent loyalty point conversion -- of individual transactions -- until after RMA for that transaction ends. By controlling per individual transaction, then the only Points that will be converted (included in the summation of points for conversion), will be Points from transactions that were paid for more than 14 days in the past.The following code accomplishes this. In LoyaltyModule.php, in the getPointsByCustomer function: change this: $a = Db::getInstance()->getValue(' SELECT SUM(f.points) points FROM `'._DB_PREFIX_.'loyalty` f WHERE f.id_customer = '.(int)($id_customer).' AND f.id_loyalty_state IN ('.(int)(LoyaltyStateModule::getValidationId()).', '.(int)(LoyaltyStateModule::getNoneAwardId()).')'); [] to this: $a = Db::getInstance()->getValue(' SELECT SUM(f.points) points FROM `'._DB_PREFIX_.'loyalty` f WHERE f.id_customer = '.(int)($id_customer).' AND f.id_loyalty_state IN ('.(int)(LoyaltyStateModule::getValidationId()).', '.(int)(LoyaltyStateModule::getNoneAwardId()).') AND UNIX_TIMESTAMP(f.date_add) < '.((int)(time()) - (1209600)).''); [] You should also place a message in the customer's Loyalty points account area, saying for example, "Available loyalty points for specific transactions can be converted to a voucher after 14 days have elapsed from the transaction date when the points were awarded."NOTE: all code here is for PS 1.4.11.0 and LPs module 1.8. You may or may not see slight differences in syntax when working in PS 1.5 or PS 1.6. If so, adjust as necessary. Edited August 1, 2014 by hermit75 (see edit history) Link to comment Share on other sites More sharing options...
Sam Minerve Posted August 1, 2014 Share Posted August 1, 2014 Thanks a lot for your detailed answer. Hmmm... Yet, I do have Loyalty module v1.15. (Gosh, I made a screen capture to show you but I don't know how to paste it in my post...) Well, in the version I have, the behavior is a bit different : the customer doesn’t necessarily have to wait 14 days after the LP conversion because, in any case, the voucher is available for use from the date on which the order was placed. However, the solution of preventing LP conversion until the end of the RMA period is still interesting. That's exactly what I was looking for. Now, I have to test your code. I hope it'll work because the "getPointsByCustomer" function has slightly changed in the current version. I'll let you know. Thanks again for your help. Link to comment Share on other sites More sharing options...
hermit75 Posted August 1, 2014 Share Posted August 1, 2014 Thanks, Sam. Please let me know -- I am curious, as well. Link to comment Share on other sites More sharing options...
Sam Minerve Posted August 3, 2014 Share Posted August 3, 2014 Hi Hermit75, So I've tested your code and it works very well. But there are two little problems though: Suppose the customer placed an order on August 1rst at 18:10 PM. The LPs should logically be transformable into vouchers on August 15 (= 1 + 14 days of RMA period). Now what if on August 15 at 10:30 AM, the customer converts his LPs ? Well, he cannot because he has to wait until after 18:10 PM. In my view, the date (and not the time) should be the only element to take into account. What do you think? I spent a long time trying to modify some codes in order to have such a behavior but nothing seemed to work (but well, I'm worthless in PHP, lol). 2. We know that the LPs status is related to the order status. For example, when an order switches to the "shipped" status, the corresponding LPs status changes over to "available" even though the LPs are not transformable-to-voucher yet. Likewise, suppose a customer has 3 transactions, 2 of them have already earned transformable LPs. The third one has the "shipped" status but is still in the RMA period so its LPs are "available" but not "transformable" yet. Ok, guess what happens if the customer does the conversion-to-voucher. Well, all the 3 LPs status changes over to "already used" while, in fact, the LPs of the third transaction haven’t been used. Did you encounter this issue too ? And how did you manage to handle it ? Link to comment Share on other sites More sharing options...
hermit75 Posted August 3, 2014 Share Posted August 3, 2014 (edited) Hi Sam: Thank you for your thorough testing! Excellent points. You have discovered a couple of important issues, especially your item #2. Regarding item #1: Let's discuss this in more detail. Are you sure that you want to attempt this type of coding (using only dates, not the full 14 days)? I, personally, think that time-stamp to time-stamp is the correct way to handle this (the full entire 14 days). For example (if we change it to your suggestion), if a customer purchases at 11:59PM on Aug 1st, then he would be able to do a LP conversion on Aug 15th at 12:01AM. You have made him wait only 13 days + 2 minutes! I think it is more prudent to go the full 14 days. Moreover, though I don't want to dig into the RMA code right now, it is possible and likely (again, I don't know for sure) that the RMA period includes all days, hours, minutes and seconds -- the full 14 days. In your example above, a customer could steal from you, by converting LPs at 12:01AM on August 15th, and then doing an RMA later that afternoon. This could result in theft. Again, I think the full 14 days is the better way to handle this. Let me know your thoughts on this issue. Regarding item #2: Good catch! I failed to address this issue, and it is significant as you pointed out, because not only does order #3 change to "Already Converted" in the customer's account, but the LPs for order #3 will also be lost forever -- the database tables think they actually did get converted, but they did not get converted because they were not included in the LP summation. The code below will prevent conversion from being reflected in both database tables (loyalty and loyalty_history). This means that your order number 3 (in your example above) will not change to "Already Converted," and its LPs will remain ready to convert after 14 days have passed. I have tested this code and it seems to work correctly. In function getAllByIdCustomer, change: if ($onlyValidate === true) $query .= ' AND f.id_loyalty_state = '.(int)LoyaltyStateModule::getValidationId(); [] to: if ($onlyValidate === true) $query .= ' AND f.id_loyalty_state = '.(int)LoyaltyStateModule::getValidationId().' AND UNIX_TIMESTAMP(f.date_add) < '.((int)(time()) - (1209600)).''; // added by hermit75 Edited August 3, 2014 by hermit75 (see edit history) Link to comment Share on other sites More sharing options...
Sam Minerve Posted August 5, 2014 Share Posted August 5, 2014 Thank you hermit75 for your quick reply. I really appreciate sharing with you ! Sorry, it took me a little time to answer because I wanted to know for sure if the RMA period is a "date to date" period or a "time-stamp to time-stamp" period, so I had to carry out some tests. I will talk about this but, first, thank you very much for the code of item #2. It works perfectly ! Now, regarding item #1, according to the tests I've done, it seems that, surprisingly, the RMA period only considers the dates and not the time. So now, let's focus on the period of LPs conversion. In your example mentioning a risk of theft, the solution can be as simple as taking a 15-day period instead of a 14-day period. After all, the LPs conversion period is just an estimate since it runs from the date when the order is placed (it would be more appropriate if it were from the order delivery date but PS chose to do things differently). This means that you have to include in the LPs conversion period not only the RMA period but the order processing time and the order delivery time as well. For simplicity, I mentioned a 14-day period (which is the minimum legal RMA period in France) but a period of approximately 20 days would be more relevant. So, basically, you can decide on a longer or a shorter LPs conversion period according to what you think is best for you and the customer. And it is best when things are clear. With a "date to date" period, the customers only needs to know he can convert his LPs on August 15, no matter what time it is. I, personally, think that a "time-stamp to time-stamp" period would add to further confusion. And as merchant, I honestly don't see myself answering the customer: "The reason why you cannot convert your LPs yet is because your order was placed at 18:58 PM, so you have to wait till 18:59 PM to be allowed to do the conversion." Link to comment Share on other sites More sharing options...
hermit75 Posted August 5, 2014 Share Posted August 5, 2014 Hi Sam, Sounds good! I understand your reasoning. I will put together some code that allows date-to-date LP conversion. Give me a few days. have a good week! Link to comment Share on other sites More sharing options...
Sam Minerve Posted August 5, 2014 Share Posted August 5, 2014 No problem, take your time. Thanks a lot in advance ! P.S. : If you ever want to compare my Loyalty module v1.15 to the version you have, just let know and I'll send you the file. Link to comment Share on other sites More sharing options...
Sam Minerve Posted August 5, 2014 Share Posted August 5, 2014 Gosh, I've just realized that there's something wrong when the customer returns merchandise. So, here's the scenario: The customer places an order, the order is delivered, so the LPs are "available" but not transformable yet because the RMA period has not expired yet. Then, the customer returns merchandise. The LPs are cancelled. Ok, so far, so good. But once the RMA period has expired, the cancelled LPs can still be transformed to voucher! Moreover, there's another issue: for example, the customer earned 5 LPs with his order that contains 3 products. If he returns just one product, all the 5 LPs are cancelled. Arf, so many troubles with this module! Link to comment Share on other sites More sharing options...
hermit75 Posted August 5, 2014 Share Posted August 5, 2014 (edited) ughhh. Disappointing to hear this news, but thank you for sharing with me. I am surprised that LPs in a "cancelled" status can still be converted to a voucher. Our changes did not affect that, but I believe that your testing is good. ughhh, Yes, I agree. I think we should stop working on this module. Too many problems. It is sad. We had so much time and effort in this, but this is symbolic of much of PS code. Edited August 6, 2014 by hermit75 (see edit history) Link to comment Share on other sites More sharing options...
Sam Minerve Posted August 6, 2014 Share Posted August 6, 2014 Hi hermit75, I was disgusted too and about to give but, then, I found solutions that will help! So, first, you can prevent the cancelled LPs to be transformable into vouchers just by changing the order status to "cancelled" (according to the default configuration in the Loyalty module). Moreover, I've found a module that can handle a few issues. In short, it's a module (complementary to the basic loyalty module) that allows you to manually change the amount of the LPs as well as the LPs status. I've tested it and it works. Here's the link for download (go to askinjew's post and choose the module's version according to your PS version): http://www.prestashop.com/forums/topic/77209-module-administrateur-des-points-de-fidelite/page-11 I don't know if it's translated in English in your back-office but if not, you will find the module under the name "Module d'administration des points de fidelité". And if it's well set up, you will see a tab called "Admin Bons de reduction" in the customer's part. We've spent so much time on the loyalty module that it would be too bad if we didn't get anything from it. I hope though that we won't have any unpleasant surprises from now on. Link to comment Share on other sites More sharing options...
hermit75 Posted August 6, 2014 Share Posted August 6, 2014 Thanks, Sam. It is interesting that status Refund (as opposed to Cancelled) does not take the LPs "off the table" so to speak. It seemed obvious that it would -- should -- do so, but you uncovered this flaw. Good job! Thanks for the link to the other module that can be used to "fix" things as needed. I hope with everything you have now, that LPs will finally be manageable. Good working with you. You are an excellent tester and thinker! Link to comment Share on other sites More sharing options...
Sam Minerve Posted August 7, 2014 Share Posted August 7, 2014 Thank you, it's good working with you too. In fact, status Refund can also take the LPs "off the table" but you have first to do the appropriate settings in the loyalty module for it to behave that way. In your back-office (in the loyalty module), you should see the option "points cancelled at the following status" (not sure about the English translation). Well, just select "refund". But in my opinion, the disadvantage of this method is that you have to make sure that refund occurs before the end of the RMA period. Suppose the customer requests for refund on the last day of the RMA period. Will you change the order status to "Refund" immediately, that is to say before you receive the merchandise? It wouldn't be prudent. But if you wait, the RMA period will have elapsed and, then, what happens? The LPs will be transformable to vouchers. Not very convenient, huh? And it's getting more complicated if you deal with a "time-stamp to time-stamp" RMA period. I think, in all cases, the best way to handle merchandise return's issue is to change the amount of LPs, for example to zero. You can do this with the module I introduced in my previous post. P.S.: Let me know if you need some help with this module's translation. Link to comment Share on other sites More sharing options...
vitoch Posted June 20, 2015 Share Posted June 20, 2015 UPDATE: For some reason I can't fathom, the above did NOT work. But there is an alternative solution as suggested here http://www.prestashop.com/forums/topic/14162-loyalty-voucher-points/ I think it's a bit less robust because it presumes that the "returns" period will not change and so it's OK to hard code that into the system. So in my case I changed line 76 (or thereabouts) from $voucher->date_from = date('Y-m-d H:i:s', $dateFrom);to $voucher->date_from = date('Y-m-d H:i:s', $dateFrom - 86400); // dont wait for one day The explanation of this delay is very simple Depending on which hosting you are using in a code $dateFrom = Db::getInstance()->getValue('SELECT UNIX_TIMESTAMP(date_add) n Time getting which is actual for the servers system which is mostly the time of country where actually server is! Solution Step 1 ensure How many days you have configure ORDERS--->MERCHANDISE RETURNS Step 2 $voucher->date_from = date('Y-m-d H:i:s', $dateFrom - hours or days in seconds); // dont wait for your time And this is not a bag it's just the way system works Kind regards to all Link to comment Share on other sites More sharing options...
LarryLarryLarry Posted November 15, 2016 Share Posted November 15, 2016 Does any of the codes here work for 1.6.0? Link to comment Share on other sites More sharing options...
ZoXx Posted January 23, 2017 Share Posted January 23, 2017 another question.our customer should ge the points with status for example "a".we set order status to "a" and at customer backend is status "waiting for acceptance".Why?We cant accept the points. It should be done by changing status or? Link to comment Share on other sites More sharing options...
sitte Posted March 28, 2017 Share Posted March 28, 2017 I'm trying to implement this module in Prestashop 1.6.1.11 but when I generate voucher as customer then it has start date set as 2019-12-23 16:48:54 (2 years, 8 months and 25 days) . I found no "$voucher->date_from" so I edited modules/loyalty/loyalty-program.php and set $cartRule->date_from = date('Y-m-d H:i:s', $dateFrom - 157680000); but no change. Can anyone help with this? Link to comment Share on other sites More sharing options...
sitte Posted April 13, 2017 Share Posted April 13, 2017 The only way to fix it was to use trigger in Mysql database that sets start date on every update. Link to comment Share on other sites More sharing options...
Loe- Posted May 19, 2017 Share Posted May 19, 2017 Hope some one can help me out i want my customers being able to use their voucher right after they have turn their LP in. Used the code if (Configuration::get('PS_ORDER_RETURN')) $dateFrom += 60 * 60 * 24 * (int)Configuration::get('PS_ORDER_RETURN_NB_DAYS');$voucher->date_from = date('Y-m-d H:i:s', $dateFrom - 1209600); // back off 14 days for immediate use of voucher -hermit75$voucher->date_to = date('Y-m-d H:i:s', $dateFrom + 31536000); // + 1 year but doesnt works. Turned of the RMA, but no the voucher is only valid for one day, and not the given 365 days / 1 year. Can someone tell the code i need for letting the customers use their voucher right away, making them valid for 365 days AND still being able to use the RMA? thanx! using PS 1.6.1.8 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now