manka Posted May 4, 2020 Share Posted May 4, 2020 Hello! We can't create new coupon for some months. The System doesn't save the name of new coupon and it doesn't work, because it doesn't exist. Why? Thanks! Link to comment Share on other sites More sharing options...
bsmither Posted May 4, 2020 Share Posted May 4, 2020 Just to make sure of something: there are no errors being reported in admin, System Error Log when you try to create a coupon? Link to comment Share on other sites More sharing options...
manka Posted May 6, 2020 Author Share Posted May 6, 2020 Quote Yesterday we made a test, there is one mistake: File: [products.coupons.inc.php] Line: [99] "INSERT INTO `CubeCart_coupons` (`code`,`product_id`,`expires`,`allowed_uses`,`min_subtotal`,`shipping`,`subtotal`,`description`,`free_shipping`,`discount_percent`,`discount_price`) VALUES ('','a:1:{i:0;s:7:"include";}','2020-06-08','0','','','','feri teszt 2','','2','0');" - Duplicate entry '' for key 'code' The system doesn't save the name of the coupon and we don't see why... Link to comment Share on other sites More sharing options...
bsmither Posted May 6, 2020 Share Posted May 6, 2020 There has been an issue reported that pertains to Gift Certificates. But this problem may be related. After the word VALUES, after the open parenthesis, there is supposed to be the name of the coupon. But right now, there are simply two apostrophes (or, 'single-quotes'). Meaning, CubeCart had a problem of some sort with the name of the coupon. As an experiment, and let us know if this has been what has been happening, make sure the name of the coupon starts with a letter -- not punctuation, not a math symbol, not a number. And, please use ASCII letters. There is a very real possibility that Unicode characters - anything not a to z, A to Z - such as foreign characters (such as 字-ま_۳) might get stripped out. The database table for coupons and gift certificates has a UNIQUE flag on the 'code' column. Since there is already a row that has no name, the database is rejecting any row inserts that also have no name for 'code'. Technically, in the PHP admin script /sources/products.coupons.inc.php: Near line 55, there is: 'code' => preg_replace('/[^\w\-\_]/', '', $_POST['coupon']['code']), Your line number may be different, and the statement may not look *exactly* like the above, depending on what version of CubeCart you are using. This statement says to remove any character that is not a dash, an underscore, or a 'word-type' character (letter,number,underscore). So, even though numbers are allowed in that statement, there may be problems down the road. If that statement looks slightly different in your file, then you may be using CC627 or earlier, and with PHP 7 or higher. You may wish to consult with your hosting provider to determine if they upgraded your site environment within the past few months. Link to comment Share on other sites More sharing options...
bsmither Posted May 6, 2020 Share Posted May 6, 2020 If using foreign characters (that is, UTF-8) is important to you, we may be able to develop a fix. Link to comment Share on other sites More sharing options...
manka Posted May 6, 2020 Author Share Posted May 6, 2020 Thank you for your help. We didn't use special character. Our version 6.2.9. We suppose preg_replace doesn't work good enough. We deleted it, the last row from the code and now it works. Link to comment Share on other sites More sharing options...
bsmither Posted October 17, 2020 Share Posted October 17, 2020 How can we help? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.