CraigA Posted October 8, 2013 Report Posted October 8, 2013 Does anyone know a quick way to import coupon codes? WagJag.com is going to be running a special on my company and they've provided me with 1500 codes to import Quote
0 Paul Posted October 8, 2013 Report Posted October 8, 2013 Does anyone know a quick way to import coupon codes? WagJag.com is going to be running a special on my company and they've provided me with 1500 codes to import Whoa, that's a lot of codes. I suppose a utility to loop through all those coupon codes and enter them into the database would be necessary. There's currently no built in support for importing coupon codes. Quote
0 CraigA Posted October 9, 2013 Author Report Posted October 9, 2013 Sounds good. I'm going to write a utility to iterate through this CSV and import it all the codes then. If I could get some confirmation on which tables need to be updated that would really help.Basically these Wag Jag coupon codes are going to give a 100% discount and will expire November 16th. I created a special package just for the Wag Jag customers, which got assigned package id "10"Looking at the DB I came up with this:table: couponsfields: id, code, company_id, used_qty, max_qty, start_date, end_date, status, type, recurring, limit_recurringtable: coupon_amountsfields: coupon_id, currency, amount, typetable: coupon_packagesfields: coupon_id, package_id%fcid% = first coupon code availablePseudo code:for $i = %fcid% to 1500+%fcid% table coupons id = $i, code = from csv, company_id = my company id, used_qty = 0, max_qty = 1, start_date = 2013-10-08 00:00:00, end_date = 2013-11-17 00:00:00, status = active, type = exclusive, recurring = 0, limit_recurring = 0 table coupon_amounts coupon_id = $i, currency = my currency, amount = 100.0000, type = percent table coupon_packages coupon_id = $i, package_id = 10loopother than these three tables, are there any other tables I would have to update with the utility for a successful import? Quote
0 Tyson Posted October 9, 2013 Report Posted October 9, 2013 I don't think there any other tables to consider, however, if it were me, I'd use the API SDK and make a call to Coupons::add() to handle everything. Manually updating table data is prone to mistakes, especially for constraints that are not discernible from the database schema alone. Quote
0 CraigA Posted October 11, 2013 Author Report Posted October 11, 2013 $coupon = $GET['code'];$id = $api->put("Coupons", "add", array('code' => $coupon, 'company_id' => "1", 'max_qty' => "1", 'end_date' => "2013-11-17 03:59:59",'recurring' => "0", 'limit_recurring' => "0", 'packages' => array('0' => "10"), 'currency' => "USD", 'amount' => "100.0000"))->response(); returns "Internal error: Failed to retrieve the default value" can you point me in the right direction Tyson? Quote
0 Tyson Posted October 11, 2013 Report Posted October 11, 2013 Try using POST. The discount amount also needs to be in an array: $id = $api->post("coupons", "add", array('code' => $coupon, 'company_id' => "1", 'max_qty' => "1", 'end_date' => "2013-11-17 03:59:59",'recurring' => "0", 'limit_recurring' => "0", 'packages' => array("10"), array(array('currency' => "USD", 'amount' => "100.0000"))))->response(); Michael 1 Quote
Question
CraigA
Does anyone know a quick way to import coupon codes?
WagJag.com is going to be running a special on my company and they've provided me with 1500 codes to import
5 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.