I have written this code here. Currently doing some tests before going to write a tracking script for WooCommerce.
The idea is I want to check whether user is on cart page and to return a message.
The problem is is_cart() method is not working at all (I think it is not even getting called).
What am I missing?
Should I require wp-includes/query.php or what?
function my_action_callback() {
check_ajax_referer( 'my-special-string', 'security' );
$whatever = intval( $_POST['whatever'] );
if ( is_page( 'cart' ) || is_cart()) {
$message = "Its on cart page";
}else{
$message = "Its not in cart page";
}
$page_id = wc_get_page_id( 'cart');
$whatever += 10;
echo $whatever . '=>>' . $message . ' <==== d';
die();
}