Jump to content

How to display error message instead of "Product successfully added to cart"


maria zagula
 Share

Recommended Posts

Hi experts!

I would like to display simple error message (somethink like this)

http://www.w3schools.com/js/js_popup.asp

when person click "add to cart". I tried hookCart but it run after added product to cart so it is too late.

 

I tried something like this:

public function hookCart($params) 
{
	$cookie = $params['cookie'] ;
	if(empty ($cookie->email))
	{
		return '<!DOCTYPE html>
		<html>
		<body onload="javascript:myFunction()">

		<p>Click the button to display an alert box:</p>

		<button onclick="myFunction()">Try it</button>

		<script>
		function myFunction() {
			alert("I am an alert box!");
		}
		</script>

		</body>
		</html>
		';
	}
	else
	{
         //Some code not important
	}
}

But it does not work ...

 

Please help !!! :)

 

Thanks in advance :)

 

Share this post


Link to post
Share on other sites

  • 4 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More