Avatar of sharingsunshine
sharingsunshine
Flag for United States of America

asked on 

In jQuery How Do You Do "If Test" On Cookie?

I am trying to have jquery write a cookie and test for its presence.  If if is present write a message in the order_comments box of Woo Commerce.  Here is an answer using jquery to write in the order_comments box.

https://www.experts-exchange.com/questions/29114316/Need-Javascript-JQuery-Button-Update-Woo-Commerce-Order-Notes.html

Open in new window


Here is my present jquery code

<script type="text/javascript">

jQuery(function() {
		jQuery('#cook').click(function(e) {
		e.preventDefault();
		document.cookie = "wantmembership=1; path=/";
              jQuery(this).css('background-color','green');
              jQuery(this).text("I Now Have A Membership!");
			});
	
		
	});

</script>

Open in new window


This creates the code.  I just need help knowing how to read the presence of the cookie and then write the message in the order_comments box.

Thanks,
Web Development* woo commercejQuery

Avatar of undefined
Last Comment
Julian Hansen

8/22/2022 - Mon