I'm creating a WooCommerce plugin,
How to execute javascript code (wait to finish it), get a value from a method and use the variable in php code using Wordpress and WooCommerce?
Everything, after call submit payment button.
Greetings.
I'm creating a WooCommerce plugin,
How to execute javascript code (wait to finish it), get a value from a method and use the variable in php code using Wordpress and WooCommerce?
Everything, after call submit payment button.
Greetings.
Just save it in a cookie:
$(document).ready(function () {
createCookie("height", $(window).height(), "10");
});
function createCookie(name, value, days) {
var expires;
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toGMTString();
}
else {
expires = "";
}
document.cookie = escape(name) + "=" + escape(value) + expires + "; path=/";
}
And then read it with PHP:
<?PHP
$_COOKIE["height"];
?>
You can read more about it here