Jump to content

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


maria zagula

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

 

Link to comment
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
×
×
  • Create New...