- Posts: 3
- Thank you received: 0
Unique Coupon
14 years 9 months ago #33035
by giboo
Unique Coupon was created by giboo
Hello
I just purchased business version, looking for extra restriction over coupons.
Is it possible to create one coupon that any user can use a predefine time, and mostly only once ?
I try this code below, but it comes to conflict with the coupon removal process.
I'm sure you'll be able to implement this very easely :
I just purchased business version, looking for extra restriction over coupons.
Is it possible to create one coupon that any user can use a predefine time, and mostly only once ?
I try this code below, but it comes to conflict with the coupon removal process.
I'm sure you'll be able to implement this very easely :
Code:
function check_coupon(){
// restricted usage numbers
$user=&JFactory::getUser();
$db =& JFactory::getDBO();
$coupon = JRequest::getString('coupon','');
if(!empty($coupon)){
$db->setQuery("SELECT COUNT(order_id) FROM #__hikashop_order AS o".
" LEFT JOIN #__hikashop_user AS u ON o.order_user_id=u.user_id".
" WHERE u.user_cms_id=".$user->id.
" AND o.order_discount_code='".$coupon."'"
);
$already = $db->loadResult();
// the number 1 below might be replaced with a parameter from the backend
if ($already>1){
$app =& JFactory::getApplication();
$app->enqueueMessage(JText::_('COUPON_ALLREADY_USED'));
return false;
} else {
return true ;
}
} else {
return true;
}
}
Please Log in or Create an account to join the conversation.
14 years 9 months ago #33059
by nicolas
Replied by nicolas on topic Re: Unique Coupon
Yes you can do that.
Just select an end date for the coupon and set a user quota of 1 in your coupon and that will do what you want. You don't have to change any code for that.
Just select an end date for the coupon and set a user quota of 1 in your coupon and that will do what you want. You don't have to change any code for that.
Please Log in or Create an account to join the conversation.
14 years 9 months ago - 14 years 9 months ago #33074
by giboo
Replied by giboo on topic Re: Unique Coupon
Is the quota relative to client, or absolute ?
I mean I need the same coupon to be used once per user, not once for every users...
How does it work then ?
Thanks in advance
I mean I need the same coupon to be used once per user, not once for every users...
How does it work then ?
Thanks in advance
Last edit: 14 years 9 months ago by giboo.
Please Log in or Create an account to join the conversation.
14 years 9 months ago #33083
by nicolas
Replied by nicolas on topic Re: Unique Coupon
If you look at the options of the coupon, both options exists: quota and quota per user.
So you can do both.
So you can do both.
Please Log in or Create an account to join the conversation.
14 years 9 months ago #33138
by giboo
Replied by giboo on topic Re: Unique Coupon
Thank you : I've been watching standard options for too long, and not enough business ones :laugh:
Please Log in or Create an account to join the conversation.
Time to create page: 0.157 seconds