Shamon Posted June 19, 2019 Share Posted June 19, 2019 hi, how can i show a warning message like this? Thanks 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 19, 2019 Share Posted June 19, 2019 17 minutes ago, HEROCLOUDS said: how can i show a warning message like this? editing viewcart.tpl would be the simplest way - using a hook would be another way, but the template's not expecting it, so you'd either have to hijack an existing alert variable, or create a new one... but if you create a new variable, you'd have to edit the template to output the text anyway... so you might as well ignore using hooks and just edit the template. it's the block of code starting <div class="col-md-8"> where this message would be displayed, so just create an alert <div> similar to the ones already there to display your message. 1 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 19, 2019 Share Posted June 19, 2019 for a more complete answer, I should add that you could use a ShoppingCartViewCartOutput hook, but it's output will be shown in a different location than the one you specified. 1 Quote Link to comment Share on other sites More sharing options...
Shamon Posted June 19, 2019 Author Share Posted June 19, 2019 4 minutes ago, brian! said: editing viewcart.tpl would be the simplest way - using a hook would be another way, but the template's not expecting it, so you'd either have to hijack an existing alert variable, or create a new one... but if you create a new variable, you'd have to edit the template to output the text anyway... so you might as well ignore using hooks and just edit the template. it's the block of code starting <div class="col-md-8"> where this message would be displayed, so just create an alert <div> similar to the ones already there to display your message. Hi @brian! , I`m using whmcs six template without any customization, i want to show a warning message in my whmcs cart view like that website(screenshot), 🙄 can you share that hook? (i'm not good in coding) 🤔 0 Quote Link to comment Share on other sites More sharing options...
Shamon Posted June 19, 2019 Author Share Posted June 19, 2019 5 minutes ago, brian! said: for a more complete answer, I should add that you could use a ShoppingCartViewCartOutput hook, but it's output will be shown in a different location than the one you specified. yes!!!! @brian! its what i asked😍 give me that hook please🙂 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 19, 2019 Share Posted June 19, 2019 9 minutes ago, HEROCLOUDS said: can you share that hook? it's only 3 lines and basically what's in the docs... <?php add_hook('ShoppingCartViewCartOutput', 1, function($vars) { $return = '<div class="alert alert-warning text-center" role="alert"><b>Please Note:</b> please choose the correct currency before proceeding.</div>'; return $return; }); i'd be tempted to say if your site is multilingual that you should use a Language Override in that output.... but if not, don't worry about doing that. 1 Quote Link to comment Share on other sites More sharing options...
Sufiyan Shaikh Posted May 16, 2021 Share Posted May 16, 2021 On 6/19/2019 at 8:50 PM, brian! said: it's only 3 lines and basically what's in the docs... <?php add_hook('ShoppingCartViewCartOutput', 1, function($vars) { $return = '<div class="alert alert-warning text-center" role="alert"><b>Please Note:</b> please choose the correct currency before proceeding.</div>'; return $return; }); i'd be tempted to say if your site is multilingual that you should use a Language Override in that output.... but if not, don't worry about doing that. Can you please update this hook? It's not working on WHMCS 8.1 version. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 17, 2021 Share Posted May 17, 2021 13 hours ago, Sufiyan Shaikh said: Can you please update this hook? It's not working on WHMCS 8.1 version. it works fine in v8.1.. 🙂 the problem might be if you are using the Lagom template, then it practically doesn't use viewcart - it goes straight to checkout... if that's the case, you could try changing ShoppingCartViewCartOutput to ShoppingCartCheckoutOutput in the hook code and that will display a similar message at checkout. I don't have Lagom in my 8.1 dev, so the above screenshot is from v7.10 - i'd be surprised if it didn't work in the v8.1 version of Lagom. 0 Quote Link to comment Share on other sites More sharing options...
Sufiyan Shaikh Posted May 17, 2021 Share Posted May 17, 2021 (edited) 7 hours ago, brian! said: the problem might be if you are using the Lagom template, then it practically doesn't use viewcart - it goes straight to checkout... if that's the case, you could try changing ShoppingCartViewCartOutput to ShoppingCartCheckoutOutput in the hook code and that will display a similar message at checkout. Thanks. I am using Lagom theme and after I made the change you said, it's working fine. Edited May 17, 2021 by Sufiyan Shaikh 0 Quote Link to comment Share on other sites More sharing options...
Sufiyan Shaikh Posted June 20, 2021 Share Posted June 20, 2021 Hello @Brian I need one help. I want to hide the message of hook if user is logged in. Please let me know how can I do it. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 20, 2021 Share Posted June 20, 2021 7 minutes ago, Sufiyan Shaikh said: I want to hide the message of hook if user is logged in. <?php add_hook('ShoppingCartCheckoutOutput', 1, function($vars) { $client = Menu::context('client'); if (is_null($client)) { $return = '<div class="alert alert-warning text-center" role="alert"><b>Please Note:</b> please choose the correct currency before proceeding.</div>'; return $return; } }); 2 Quote Link to comment Share on other sites More sharing options...
Sufiyan Shaikh Posted June 20, 2021 Share Posted June 20, 2021 6 minutes ago, brian! said: <?php add_hook('ShoppingCartCheckoutOutput', 1, function($vars) { $client = Menu::context('client'); if (is_null($client)) { $return = '<div class="alert alert-warning text-center" role="alert"><b>Please Note:</b> please choose the correct currency before proceeding.</div>'; return $return; } }); Thanks a ton Brian! 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.