Jump to content

warning before checkout


Shamon

Recommended Posts

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.

Link to comment
Share on other sites

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) 🤔 

Link to comment
Share on other sites

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.

q6PZkQX.png

yes!!!! 
@brian! its what i asked😍 
give me that hook please🙂
 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 1 year later...
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.

Link to comment
Share on other sites

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.. 🙂

1IMswKL.png

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.

EobOTVb.png

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.

Link to comment
Share on other sites

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 by Sufiyan Shaikh
Link to comment
Share on other sites

  • 1 month later...
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;
	}
});

 

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated