Coupon code lost unless checked out immediately

More
7 years 2 months ago #37090 by nordmograph
Very weird,

Here are the tables my Awocoupon installs:
Code:
CREATE TABLE IF NOT EXISTS #__awocoupon_vm ( `id` int(16) NOT NULL auto_increment, `coupon_code` varchar(32) NOT NULL default '', `num_of_uses` INT NOT NULL DEFAULT 0, `coupon_value_type` enum('percent','total') NOT NULL default 'percent', `coupon_value` decimal(12,2) NOT NULL default '0.00', `min_value` decimal(12,2), `discount_type` enum('specific','overall') NOT NULL DEFAULT 'overall', `function_type` enum('coupon','giftcert') NOT NULL DEFAULT 'coupon', `function_type2` enum('product','category'), `startdate` DATE, `expiration` DATE, `published` TINYINT NOT NULL DEFAULT 1, PRIMARY KEY (`id`) ); CREATE TABLE IF NOT EXISTS #__awocoupon_vm_product ( `id` int(16) NOT NULL auto_increment, `coupon_id` varchar(32) NOT NULL default '', `product_id` INT NOT NULL, PRIMARY KEY (`id`) ); CREATE TABLE IF NOT EXISTS #__awocoupon_vm_category ( `id` int(16) NOT NULL auto_increment, `coupon_id` varchar(32) NOT NULL default '', `category_id` INT NOT NULL, PRIMARY KEY (`id`) ); CREATE TABLE IF NOT EXISTS #__awocoupon_vm_user ( `id` int(16) NOT NULL auto_increment, `coupon_id` varchar(32) NOT NULL default '', `user_id` INT NOT NULL, PRIMARY KEY (`id`) ); CREATE TABLE IF NOT EXISTS #__awocoupon_vm_history ( `coupon_id` varchar(32) NOT NULL default '', `user_id` INT NOT NULL, `num` INT NOT NULL DEFAULT 0, PRIMARY KEY (`coupon_id`,`user_id`) );

Are you using an old version or is this a different extension ?

- Need help? Post the URL of the related page (eventualy as confidential info), it will help solve your issue faster.
- An error, notice or warning? report the exact message including the line number
- If you get a white page , enable error reporting and / or check your server error logs.

Please Log in or Create an account to join the conversation.

More
7 years 2 months ago #37091 by loppis
Yikes :S !

Yes, you are correct - those are the tables for the free version.

The paid version has much more :
Code:
CREATE TABLE IF NOT EXISTS #__awocoupon ( `id` int(16) NOT NULL auto_increment, `estore` enum('virtuemart','redshop','hikashop','virtuemart1','eshop') NOT NULL, `coupon_code` varchar(255) BINARY NOT NULL default '', `passcode` varchar(10), `upc` varchar(255), `parent_type` enum('first','lowest','highest','all','allonly') DEFAULT NULL, `coupon_value_type` enum('percent','amount','amount_per') DEFAULT NULL, `coupon_value` decimal(20,5), `coupon_value_def` TEXT, `function_type` enum('coupon','shipping','buy_x_get_y','parent','giftcert') NOT NULL DEFAULT 'coupon', `num_of_uses_total` INT, `num_of_uses_customer` INT, `min_value` decimal(20,5), `discount_type` enum('specific','overall'), `user_type` enum('user','usergroup'), `startdate` DATETIME, `expiration` DATETIME, `exclude_giftcert` TINYINT(1), `order_id` int(11), `template_id` int(11), `published` TINYINT NOT NULL DEFAULT 1, `note` TEXT, `params` TEXT, PRIMARY KEY (`id`), KEY coupon_code (coupon_code) ); CREATE TABLE IF NOT EXISTS #__awocoupon_config ( `id` int(16) NOT NULL auto_increment, `name` VARCHAR(255) NOT NULL, `is_json` TINYINT(1), `value` TEXT, PRIMARY KEY (`id`), UNIQUE (`name`) ); CREATE TABLE IF NOT EXISTS #__awocoupon_license ( `id` VARCHAR(100) NOT NULL, `value` TEXT, PRIMARY KEY (`id`) ); CREATE TABLE IF NOT EXISTS #__awocoupon_asset1 ( `id` int(16) NOT NULL auto_increment, `coupon_id` varchar(32) NOT NULL default '', `asset_type` enum('coupon','product','category','manufacturer','vendor','shipping','country','countrystate','paymentmethod') NOT NULL, `asset_id` INT NOT NULL, `order_by` INT NULL, PRIMARY KEY (`id`) ); CREATE TABLE IF NOT EXISTS #__awocoupon_asset2 ( `id` int(16) NOT NULL auto_increment, `coupon_id` varchar(32) NOT NULL default '', `asset_type` enum('coupon','product','category','manufacturer','vendor','shipping') NOT NULL, `asset_id` INT NOT NULL, `order_by` INT NULL, PRIMARY KEY (`id`) ); CREATE TABLE IF NOT EXISTS #__awocoupon_user ( `id` int(16) NOT NULL auto_increment, `coupon_id` varchar(32) NOT NULL default '', `user_id` INT NOT NULL, PRIMARY KEY (`id`) ); CREATE TABLE IF NOT EXISTS #__awocoupon_usergroup ( `id` int(16) NOT NULL auto_increment, `coupon_id` varchar(32) NOT NULL default '', `shopper_group_id` INT NOT NULL, PRIMARY KEY (`id`) ); CREATE TABLE IF NOT EXISTS #__awocoupon_history ( `id` INT NOT NULL auto_increment, `estore` enum('virtuemart','redshop','hikashop','virtuemart1','eshop') NOT NULL, `coupon_id` varchar(32) NOT NULL default '', `coupon_entered_id` varchar(32), `is_customer_balance` TINYINT(1), `user_id` INT NOT NULL, `user_email` varchar(255), `coupon_discount` DECIMAL(20,5) DEFAULT 0 NOT NULL, `shipping_discount` DECIMAL(20,5) DEFAULT 0 NOT NULL, `order_id` INT, `session_id` VARCHAR(200), `productids` TEXT, `details` TEXT, `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY coupon_id_user_id (coupon_id,user_email), KEY coupon_entered_id_user_id (coupon_entered_id,user_email), KEY order_id (order_id), KEY user_id (user_id), KEY session_id (session_id), KEY user_email (user_email) ); CREATE TABLE IF NOT EXISTS #__awocoupon_profile ( `id` int(16) NOT NULL auto_increment, `title` VARCHAR(255) NOT NULL, `is_default` TINYINT(1), `from_name` VARCHAR(255), `from_email` VARCHAR(255), `bcc_admin` TINYINT(1), `cc_purchaser` TINYINT(1), `idlang_email_subject` INT, `idlang_email_body` INT, `message_type` ENUM ('text','html') NOT NULL DEFAULT 'text', `image` VARCHAR(255), `coupon_code_config` TEXT, `coupon_value_config` TEXT, `idlang_voucher_text` INT, `idlang_voucher_text_exp` INT, `idlang_voucher_filename` INT, `expiration_config` TEXT, `freetext1_config` TEXT, `freetext2_config` TEXT, `freetext3_config` TEXT, `is_pdf` TINYINT(1), `idlang_pdf_header` INT, `idlang_pdf_body` INT, `idlang_pdf_footer` INT, `idlang_pdf_filename` INT, PRIMARY KEY (`id`) ); CREATE TABLE IF NOT EXISTS #__awocoupon_giftcert_product ( `id` int(16) NOT NULL auto_increment, `estore` enum('virtuemart','redshop','hikashop','virtuemart1','eshop') NOT NULL, `product_id` INT NOT NULL, `coupon_template_id` INT NOT NULL, `profile_id` INT, `price_calc_type` ENUM('product_price_notax','product_price') DEFAULT NULL, `expiration_number` INT, `expiration_type` ENUM('day','month','year'), `vendor_name` VARCHAR(255), `vendor_email` VARCHAR(255), `coupon_code_prefix` VARCHAR(255), `coupon_code_suffix` VARCHAR(255), `published` TINYINT NOT NULL DEFAULT 1, PRIMARY KEY (`id`) ); CREATE TABLE IF NOT EXISTS #__awocoupon_giftcert_code ( `id` int(16) NOT NULL auto_increment, `estore` enum('virtuemart','redshop','hikashop','virtuemart1','eshop') NOT NULL, `product_id` INT NOT NULL, `code` VARCHAR(255) BINARY NOT NULL default '', `status` ENUM('active','inactive','used') NOT NULL DEFAULT 'active', `note` TEXT, PRIMARY KEY (`id`) ); CREATE TABLE IF NOT EXISTS #__awocoupon_voucher_customer ( `id` int(16) NOT NULL auto_increment, `estore` enum('virtuemart','redshop','hikashop','virtuemart1','eshop') NOT NULL, `user_id` int(11) NOT NULL, `order_id` int(11), `codes` text, PRIMARY KEY (`id`) ); CREATE TABLE IF NOT EXISTS #__awocoupon_voucher_customer_code ( `id` int(16) NOT NULL auto_increment, `voucher_customer_id` int(16) NOT NULL, `coupon_id` int(16) NOT NULL, `code` VARCHAR(255) NOT NULL, `recipient_user_id` INT, `order_item_id` int(16) NOT NULL, `product_id` int(16) NOT NULL, PRIMARY KEY (`id`) ); CREATE TABLE IF NOT EXISTS #__awocoupon_auto ( `id` int(16) NOT NULL auto_increment, `coupon_id` INT NOT NULL, `ordering` INT NULL, `published` TINYINT NOT NULL DEFAULT 1, PRIMARY KEY (`id`) ); CREATE TABLE IF NOT EXISTS #__awocoupon_lang_text ( `id` int(16) NOT NULL auto_increment, `elem_id` int(16) NOT NULL, `lang` varchar(32) NOT NULL default '', `text` TEXT, PRIMARY KEY (`id`), UNIQUE KEY (elem_id,lang) ); CREATE TABLE IF NOT EXISTS #__awocoupon_image ( `coupon_id` INT NOT NULL, `user_id` INT NOT NULL, `filename` varchar(255), PRIMARY KEY (`coupon_id`,`user_id`) ); CREATE TABLE IF NOT EXISTS #__awocoupon_tag ( `coupon_id` int(16) NOT NULL, `tag` VARCHAR(255) NOT NULL, PRIMARY KEY (`coupon_id`,`tag`) ); CREATE TABLE IF NOT EXISTS #__awocoupon_customer_balance ( `id` int(16) NOT NULL auto_increment, `user_id` int(16) NOT NULL, `coupon_id` int(16) NOT NULL, `initial_balance` decimal(20,5) NOT NULL, `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY (`coupon_id`) ); CREATE TABLE IF NOT EXISTS #__awocoupon_cron ( `id` INT NOT NULL auto_increment, `coupon_id` varchar(32) NOT NULL default '', `user_id` INT NOT NULL, `type` varchar(255), `status` VARCHAR(200), `notes` TEXT, `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ); INSERT INTO #__awocoupon_profile (title,is_default,idlang_email_subject,message_type,idlang_email_body,idlang_voucher_text,idlang_voucher_text_exp) VALUES ("Profile 1",1,1,"text",2,3,4); INSERT INTO #__awocoupon_lang_text (elem_id,lang,text) VALUES (1,"en-GB","Ordered Gift Certificate(s)"), (2,"en-GB","Included is your gift certificate valid towards all products at {siteurl}.\r\nSimply enter the code from your gift certificate in the coupon code entry form during checkout. Enjoy shopping!\r\n\r\n{vouchers}\r\n\r\nThank you,\r\n{store_name}"), (3,"en-GB",'Gift Certificate: {voucher}\\nValue: {price}{expiration_text}\\n\\n'), (4,"en-GB",'\\nExpiration: {expiration}') ; INSERT INTO #__awocoupon_profile (title,idlang_email_subject,message_type,image,coupon_code_config,coupon_value_config,expiration_config,freetext1_config,freetext2_config,idlang_email_body,idlang_voucher_text,idlang_voucher_text_exp,idlang_voucher_filename) VALUES ("Christmas",6,"html","christmas.png", 'a:6:{s:5:"align";s:1:"R";s:3:"pad";s:2:"10";s:1:"y";s:2:"72";s:4:"font";s:11:"arialbd.ttf";s:4:"size";s:2:"16";s:5:"color";s:7:"#FFFF00";}', 'a:6:{s:5:"align";s:1:"L";s:3:"pad";s:2:"50";s:1:"y";s:3:"110";s:4:"font";s:11:"arialbd.ttf";s:4:"size";s:2:"25";s:5:"color";s:7:"#FFFF00";}', 'a:7:{s:4:"text";s:5:"F j Y";s:5:"align";s:1:"C";s:3:"pad";s:0:"";s:1:"y";s:3:"270";s:4:"font";s:11:"arialbd.ttf";s:4:"size";s:2:"14";s:5:"color";s:7:"#FFA500";}', 'a:7:{s:4:"text";s:5:"CODE:";s:5:"align";s:1:"R";s:3:"pad";s:2:"75";s:1:"y";s:2:"50";s:4:"font";s:11:"arialbd.ttf";s:4:"size";s:2:"14";s:5:"color";s:7:"#FFA500";}', 'a:7:{s:4:"text";s:19:"www.yourwebsite.com";s:5:"align";s:1:"C";s:3:"pad";s:0:"";s:1:"y";s:3:"200";s:4:"font";s:11:"arialbd.ttf";s:4:"size";s:2:"25";s:5:"color";s:7:"#FFFAFA";}', 10, 14, 18, 22 ), ("Flower",7,"html","flower.png", 'a:6:{s:5:"align";s:1:"C";s:3:"pad";s:0:"";s:1:"y";s:3:"280";s:4:"font";s:11:"arialbd.ttf";s:4:"size";s:2:"14";s:5:"color";s:7:"#000000";}', 'a:6:{s:5:"align";s:1:"C";s:3:"pad";s:0:"";s:1:"y";s:3:"250";s:4:"font";s:11:"arialbd.ttf";s:4:"size";s:2:"25";s:5:"color";s:7:"#000000";}', NULL, 'a:7:{s:4:"text";s:19:"www.yourwebsite.com";s:5:"align";s:1:"C";s:3:"pad";s:0:"";s:1:"y";s:2:"30";s:4:"font";s:11:"arialbd.ttf";s:4:"size";s:2:"25";s:5:"color";s:7:"#FFD700";}', 'a:7:{s:4:"text";s:10:"Thank you!";s:5:"align";s:1:"C";s:3:"pad";s:0:"";s:1:"y";s:2:"70";s:4:"font";s:11:"arialbd.ttf";s:4:"size";s:2:"20";s:5:"color";s:7:"#FF69B4";}', 11, 15, 19, 23 ), ("Brown",8,"html","brown.png", 'a:6:{s:5:"align";s:1:"R";s:3:"pad";s:2:"20";s:1:"y";s:2:"50";s:4:"font";s:11:"arialbd.ttf";s:4:"size";s:2:"18";s:5:"color";s:7:"#FFFFFF";}', 'a:6:{s:5:"align";s:1:"L";s:3:"pad";s:2:"20";s:1:"y";s:2:"50";s:4:"font";s:11:"arialbd.ttf";s:4:"size";s:2:"25";s:5:"color";s:7:"#FFFFFF";}', 'a:7:{s:4:"text";s:5:"j F Y";s:5:"align";s:1:"R";s:3:"pad";s:2:"50";s:1:"y";s:2:"80";s:4:"font";s:11:"arialbd.ttf";s:4:"size";s:2:"15";s:5:"color";s:7:"#F0F8FF";}', 'a:7:{s:4:"text";s:9:"GIFT CARD";s:5:"align";s:1:"C";s:3:"pad";s:0:"";s:1:"y";s:3:"260";s:4:"font";s:11:"arialbd.ttf";s:4:"size";s:2:"30";s:5:"color";s:7:"#000000";}', 'a:7:{s:4:"text";s:19:"www.yourwebsite.com";s:5:"align";s:1:"C";s:3:"pad";s:0:"";s:1:"y";s:3:"180";s:4:"font";s:11:"arialbd.ttf";s:4:"size";s:2:"30";s:5:"color";s:7:"#8B0000";}', 12, 16, 20, 24 ), ("Snowman",9,"html","snowman.png", 'a:6:{s:5:"align";s:1:"R";s:3:"pad";s:2:"30";s:1:"y";s:2:"60";s:4:"font";s:11:"arialbd.ttf";s:4:"size";s:2:"14";s:5:"color";s:7:"#000000";}', 'a:6:{s:5:"align";s:1:"L";s:3:"pad";s:2:"30";s:1:"y";s:2:"60";s:4:"font";s:11:"arialbd.ttf";s:4:"size";s:2:"22";s:5:"color";s:7:"#000000";}', 'a:7:{s:4:"text";s:5:"j M Y";s:5:"align";s:1:"R";s:3:"pad";s:2:"30";s:1:"y";s:2:"90";s:4:"font";s:11:"arialbd.ttf";s:4:"size";s:2:"14";s:5:"color";s:7:"#000000";}', 'a:7:{s:4:"text";s:19:"www.yourwebsite.com";s:5:"align";s:1:"C";s:3:"pad";s:0:"";s:1:"y";s:3:"170";s:4:"font";s:11:"arialbd.ttf";s:4:"size";s:2:"32";s:5:"color";s:7:"#0000FF";}', 'a:7:{s:4:"text";s:28:"Enjoy your shopping with us!";s:5:"align";s:1:"C";s:3:"pad";s:0:"";s:1:"y";s:3:"260";s:4:"font";s:11:"arialbd.ttf";s:4:"size";s:2:"20";s:5:"color";s:7:"#B22222";}', 13, 17, 21, 25 ) ; INSERT INTO #__awocoupon_lang_text (elem_id,lang,text) VALUES (6,"en-GB","Ordered Gift Certificate(s)"), (7,"en-GB","Ordered Gift Certificate(s)"), (8,"en-GB","Ordered Gift Certificate(s)"), (9,"en-GB","Ordered Gift Certificate(s)") ; INSERT INTO #__awocoupon_lang_text (elem_id,lang,text) VALUES (10,"en-GB","Included is your gift certificate valid towards all products at {siteurl}.<br />Simply enter the code from your gift certificate in the coupon code entry form during checkout. Enjoy shopping!<br /><br />Thank you,<br />{store_name}"), (11,"en-GB","Included is your gift certificate valid towards all products at {siteurl}.<br />Simply enter the code from your gift certificate in the coupon code entry form during checkout. Enjoy shopping!<br /><br />Thank you,<br />{store_name}"), (12,"en-GB","Included is your gift certificate valid towards all products at {siteurl}.<br />Simply enter the code from your gift certificate in the coupon code entry form during checkout. Enjoy shopping!<br /><br />Thank you,<br />{store_name}"), (13,"en-GB","Included is your gift certificate valid towards all products at {siteurl}.<br />Simply enter the code from your gift certificate in the coupon code entry form during checkout. Enjoy shopping!<br /><br />Thank you,<br />{store_name}") ; INSERT INTO #__awocoupon_lang_text (elem_id,lang,text) VALUES (14,"en-GB","Gift Certificate: {voucher}<br />Value: {price}{expiration_text}<br /><br />"), (15,"en-GB","Gift Certificate: {voucher}<br />Value: {price}{expiration_text}<br /><br />"), (16,"en-GB","Gift Certificate: {voucher}<br />Value: {price}{expiration_text}<br /><br />"), (17,"en-GB","Gift Certificate: {voucher}<br />Value: {price}{expiration_text}<br /><br />") ; INSERT INTO #__awocoupon_lang_text (elem_id,lang,text) VALUES (18,"en-GB","<br />Expiration: {expiration}"), (19,"en-GB","<br />Expiration: {expiration}"), (20,"en-GB","<br />Expiration: {expiration}"), (21,"en-GB","<br />Expiration: {expiration}") ; INSERT INTO #__awocoupon_lang_text (elem_id,lang,text) VALUES (22,"en-GB","voucher#"), (23,"en-GB","voucher#"), (24,"en-GB","voucher#"), (25,"en-GB","voucher#") ;

The code for creating coupons should be similar though - and there are some useful info in this thread :

awodev.com/forum/awocoupon/help-section/...ns-directly-database

I will try to copy and paste some stuff and see what I can come up with :).

Please Log in or Create an account to join the conversation.

More
7 years 2 months ago #37092 by nordmograph
Okay
I updated the plugin, now a new options are AWO free and AWO commercial.
I applyed the changes you mentioned to the query. I don't see areason for it causing a 404, so feel free to try this new one and report.

- Need help? Post the URL of the related page (eventualy as confidential info), it will help solve your issue faster.
- An error, notice or warning? report the exact message including the line number
- If you get a white page , enable error reporting and / or check your server error logs.

Please Log in or Create an account to join the conversation.

More
7 years 2 months ago #37093 by loppis
Oh, awesome :) Great job, will download and test!

Yeah, I checked my awocoupon admin and a coupon was actually created - my error 404 might have been caused by modsecurity actually - or something else... I will investigate and report back as soon as I have some news :)

Thanks for your great work.

Best regards

Peter

Please Log in or Create an account to join the conversation.

More
7 years 2 months ago #37094 by loppis
It is actually modsecurity that causes my error 404 :
Code:
[Thu Feb 16 23:08:27 2017] [error] [client 187.181.168.115] ModSecurity: Access denied with code 404 (phase 4). Pattern match "You have an error in your SQL syntax; check the manual " at RESPONSE_BODY. [file "/etc/modsecurity/rules-latest/11_asl_data_loss.conf"] [line "108"] [id "361022"] [rev "2"] [msg "Atomicorp.com WAF Rules: Potential SQL Information Leakage"] [severity "ALERT"] [tag "no_ar"] [hostname "www.dietrecords.org"] [uri "/index.php"] [unique_id "WKYizH8AAQEAAEwBpWoAAAAG"]

Turning modsecurity off for /index.php is something that my server guy will definitely not recommend me to do ;), and still it's weird that modsecurity doesn't catch errors when default VM coupons are created?

Checked the database and the coupon is created although some fields are missing that might be crucial for awocoupon pro :

passcode - a hash of the coupon code I think, as refered to here : awodev.com/forum/awocoupon/help-section/...ns-directly-database

coupon_value_type - should probably be set to "amount"

the other fields seem to be OK as they are (either set to NULL or with the current values)

the "coupon_value_type" field I can figure out myself how to set but I'm a little worried about that hash code thing, I could need your help there :)

Thanks again :)

Best

Peter

Please Log in or Create an account to join the conversation.

More
7 years 2 months ago #37097 by nordmograph
I made some changes for the type value to 'amount' and adding the coupon code hash.
Give it a try and let me know.

- Need help? Post the URL of the related page (eventualy as confidential info), it will help solve your issue faster.
- An error, notice or warning? report the exact message including the line number
- If you get a white page , enable error reporting and / or check your server error logs.

Please Log in or Create an account to join the conversation.

Time to create page: 0.338 seconds
Powered by Kunena Forum
Disclaimer: Nordmograph is not affiliated with or endorsed by The Joomla! Project™. Any products and services provided through this site are not supported or warrantied by The Joomla! Project or Open Source Matters, Inc. Use of the Joomla!® name, symbol, logo and related trademarks is permitted under a limited license granted by Open Source Matters, Inc.