Jump to content



Recommended Posts


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.

Edited by bsmither
Link to comment
Share on other sites

  • 5 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...