Durukan Bal Posted July 15, 2020 Share Posted July 15, 2020 Hello, using the whmcs hook system we want to get the domain address and products id before our customer place the order When does the hook named "ShoppingCartValidateCheckout" work? exactly what we want When a hosting order arrives, we want to give an error message if the package is pid = 17 and the domain address has been used on this package before. We share a sample code blog below. Can you help? $cart = $_SESSION['cart']; $products = []; $tlds = []; foreach ($vars['products'] as $product) { $products[] = $product['pid']; } foreach ($vars['domains'] as $domain) { $tlds[] = $domain['domain']; } if (in_array(17, $products) && in_array('testantpi.net', $tlds)) { return array("Error this domain address cannot be used"); } }); //hook Best Regards. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 17, 2020 Share Posted July 17, 2020 On 15/07/2020 at 14:11, Durukan Bal said: using the whmcs hook system we want to get the domain address and products id before our customer place the order When does the hook named "ShoppingCartValidateCheckout" work? https://developers.whmcs.com/hooks-reference/shopping-cart/#shoppingcartvalidatecheckout Quote Executes on checkout via the shopping cart. in other words, after they press the "Complete Order" button at checkout. On 15/07/2020 at 14:11, Durukan Bal said: exactly what we want When a hosting order arrives, we want to give an error message if the package is pid = 17 and the domain address has been used on this package before. <?php # Product Limiter Hook # Written by brian! use WHMCS\Database\Capsule; add_hook('ShoppingCartValidateCheckout', 1, function($vars) { $products = $_SESSION['cart']['products']; foreach ($products as $key => $product) { if ($product['pid'] == '17') { $existingdomain = Capsule::table('tblhosting')->where('packageid','17')->where('domain',$product['domain'])->count(); if ($existingdomain > 0) { return 'Error this domain address cannot be used'; } } } }); possibly, that error text should use a language string instead - but if your site only has one languages, then that's irrelevant. 0 Quote Link to comment Share on other sites More sharing options...
Durukan Bal Posted July 18, 2020 Author Share Posted July 18, 2020 18 hours ago, brian! said: https://developers.whmcs.com/hooks-reference/shopping-cart/#shoppingcartvalidatecheckout in other words, after they press the "Complete Order" button at checkout. <?php # Product Limiter Hook # Written by brian! use WHMCS\Database\Capsule; add_hook('ShoppingCartValidateCheckout', 1, function($vars) { $products = $_SESSION['cart']['products']; foreach ($products as $key => $product) { if ($product['pid'] == '17') { $existingdomain = Capsule::table('tblhosting')->where('packageid','17')->where('domain',$product['domain'])->count(); if ($existingdomain > 0) { return 'Error this domain address cannot be used'; } } } }); possibly, that error text should use a language string instead - but if your site only has one languages, then that's irrelevant. Thank you so much , your software technique is very nice, If you need antpi.net web hosting service, please do not hesitate to contact us. Best Regards. Thank you so much , your software technique is very nice, If you need antpi.net web hosting service, please do not hesitate to contact us. Best Regards. 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.