Craft Posted October 28, 2020 Share Posted October 28, 2020 Is there any way to offer my customers a discount and they could use it only once per domain, not per client? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 28, 2020 Share Posted October 28, 2020 on a service related to the domain, or on domain registration itself ?? 0 Quote Link to comment Share on other sites More sharing options...
Craft Posted October 28, 2020 Author Share Posted October 28, 2020 27 minutes ago, brian! said: on a service related to the domain, or on domain registration itself ?? A service related to the domain (Web Hosting) I need to offer a free trial period for a web hosting plan but I need the customer could only use it once per domain. 0 Quote Link to comment Share on other sites More sharing options...
Craft Posted October 29, 2020 Author Share Posted October 29, 2020 @brian! Any update? 🙂 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 30, 2020 Share Posted October 30, 2020 14 hours ago, Craft said: Any update? I couldn't think of an existing solution - commercial or otherwise.... possibly one of Kian's hooks could have been expanded to cover this, but it doesn't work in v8 anyway even before you could think about expanding it. 🙄 all you should need is a domain validation hook that checks the domain entered when used with specific products... <?php # Prevent Domain Re-Use with Trial Products Hook # Written by brian! use WHMCS\Database\Capsule; add_hook('ShoppingCartValidateDomain', 1, function($vars) { $pid = $_SESSION["cart"]["domainoptionspid"]; $trialproducts = array(44); $domain = $vars['sld'].$vars['tld']; $domaincheck = Capsule::table('tblhosting')->where('packageid',$pid)->where('domain',$domain)->count(); if(in_array($pid,$trialproducts) && $domaincheck > 0) { return 'You cannot use this trial service with '.$domain; } }); On 28/10/2020 at 14:53, Craft said: I need to offer a free trial period for a web hosting plan but I need the customer could only use it once per domain. so in the above hook, $trialproducts should contain a list of your trial product IDs and then the hook checks if there is a record in the hosting database for that product AND domain... if yes, then it throws an error message and prevents the ordering continuing. as written, it's only going to check for the current PID in the database, .e.g let's say you had 2 trial products (44 & 45) and someone had previously used domain.com with PID#44... the hook would prevent them using the domain again with #44, but wouldn't stop them using it with #45.... now you may or may not want that to happen if you don't, e.g you want to prevent a domain being re-used after it's been used on ANY listed trial service, then that's just a tweak to the query changing the first where condition to a wherein. $domaincheck = Capsule::table('tblhosting')->whereIn('packageid',$trialproducts)->where('domain',$domain)->count(); the error message thrown could use a language string if you prefer to ensure that it's shown in the user's language. 1 Quote Link to comment Share on other sites More sharing options...
Craft Posted October 30, 2020 Author Share Posted October 30, 2020 8 hours ago, brian! said: I couldn't think of an existing solution - commercial or otherwise.... possibly one of Kian's hooks could have been expanded to cover this, but it doesn't work in v8 anyway even before you could think about expanding it. 🙄 Are you sure that this hook doesn't work in v8? Then this hook is useless 🙂 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 31, 2020 Share Posted October 31, 2020 11 hours ago, Craft said: Are you sure that this hook doesn't work in v8? the hook I posted works in v8, and I see no reason why it wouldn't work in v7.... I was saying that when I tested Kian's hook previously, it didn't work in v8 (but did in v7). 11 hours ago, Craft said: Then this hook is useless 🙂 i'm not in the habit of posting useless hooks - I can leave that to others. 😜 0 Quote Link to comment Share on other sites More sharing options...
Craft Posted October 31, 2020 Author Share Posted October 31, 2020 4 hours ago, brian! said: the hook I posted works in v8, and I see no reason why it wouldn't work in v7.... I was saying that when I tested Kian's hook previously, it didn't work in v8 (but did in v7). i'm not in the habit of posting useless hooks - I can leave that to others. 😜 I thought it doesn't work in v8 so I thought it's useless, but if it works in v8 then it's very useful 🙂 I'll try it and give you my feedback, thanks in advance 🙂 0 Quote Link to comment Share on other sites More sharing options...
Craft Posted November 13, 2020 Author Share Posted November 13, 2020 On 10/31/2020 at 6:09 PM, Craft said: I'll try it and give you my feedback, thanks in advance 🙂 @brian! Sorry for my late reply. I have tested the hook (both conditions) and they are working fine in v8 Thank you ❤️ 0 Quote Link to comment Share on other sites More sharing options...
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.