Hi there,
I am trying to generate personalised coupons directly via a joomla database call as users fill out a email subscription form.
The concept was working in AWOCoupon 1.x (Free) but seems to no longer work in AWOCoupon Pro 2. I guessed the problem was due to the new passcode field, which appears to be a hash of the coupon code.
From models/coupon.php it looks like this passcode hash should be:
But this does not seem to work. Is there something in the db request below that would be causing the problem? (The generated coupons neither work nor show up in AWO Coupon in the Back End.
Thanks
Will
I am trying to generate personalised coupons directly via a joomla database call as users fill out a email subscription form.
The concept was working in AWOCoupon 1.x (Free) but seems to no longer work in AWOCoupon Pro 2. I guessed the problem was due to the new passcode field, which appears to be a hash of the coupon code.
From models/coupon.php it looks like this passcode hash should be:
substr( md5((string)time().rand(1,1000).$_POST['coupon']), 0, 6);
But this does not seem to work. Is there something in the db request below that would be causing the problem? (The generated coupons neither work nor show up in AWO Coupon in the Back End.
$db = JFactory::getDBO();
$data =new stdClass();
$data->id = null;
$data->coupon_code = $_POST['coupon'];
$data->num_of_uses_type = 'total';
$data->num_of_uses = '1';
$data->coupon_value_type = 'percent';
$data->coupon_value_def = '1-25;4-25;5-0;';
$data->min_value = null;
$data->discount_type = 'overall';
$data->function_type = 'coupon';
$data->expiration = $_POST['couponexp'];
$data->published = '1';
$data->user_type = 'user';
/* THIS IS WHERE I GUESS THE PROBLEM IS... */
$pcode = substr( md5((string)time().rand(1,1000).$_POST['coupon']), 0, 6);
$data->passcode = $pcode;
$db->insertObject( 'j25_awocoupon', $data, id );
Thanks
Will