Jump to content

coupon


manka

Recommended Posts

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

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

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

  • 5 months later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...