I know this question has been asked 100 times, and I've googled it and tried multiple solutions, but I'm still getting this error. I removed all the white space, tried to encode it in UTF-8
in notepad ++ and still no success. Below is my code for my plugin, this is the only code used, and its all in 1 file:
<html>
<head>
<script type = "text/javascript">
function randomCoupGen()
{
var RanNum = Math.floor(Math.random() * 6);
if(RanNum == 1)
{
alert("You rolled a 1");
}
else if(RanNum == 2)
{
alert("You rolled a 2.");
}
else
{
alert("You rolled something other than 1 or 2");
}
}
</script></head><body></body></html>
<?php
function GenCoupon(){
echo "<input type = \"button\" onclick = \"randomCoupGen()\">Click here to see if you won!!</input>";
}
add_filter('woocommerce_after_order_notes', 'GenCoupon', 9999999, 2);
?>
Sorry for the sloppy code, I tried to delete every white space I saw to see if it would help. It took the character from 380 to about 330. I also tried to set the priority to make it load last.
This plugin makes the purchasing of products in my checkout tab on my woocommerce site indefinitely try to calculate the price, with no success.
Any ideas would be appreciated.
<html>
to</html>
will be "unexpected output" for good reason as @user5200704 says... the script should be added viawp_enqueue_script
function as a js file, or just echoed by adding a function that echoes it to thewp_footer
hook,