Woocommerce - wc_add_notice() not adding to session when nothing in the cart
<p>I have a custom form that calls a function in function.php when submitted. It will eventually check the fields input and either do something or send back an error message using the <code>woocommerce wc_add_notice()</code>, standard stuff.</p>

<p>The problem is, it only seems to add the notice to the session when items have been added to the cart at some point. If I open in an incognito tab and try the form I will get no message. Just to be clear I am using <code>wc_print_notices()</code>in my template. </p>

<p>I have printed out the woocommerce session just to confirm and yep its not in there when nothing has been added to the cart. I have stripped the function right back so it should send back an error message when you click submit regardless of anything filled out or not, just to check. Here is the function in question :</p>

<pre><code>add_action('wp_ajax_add_transfer', 'process_add_transfer');
add_action('wp_ajax_nopriv_add_transfer', 'process_add_transfer');
function process_add_transfer() {
     global $woocommerce;
     wc_add_notice( 'This is my custom error', 'error' );
     wp_redirect( get_permalink(125) ); //this is the same page form is on
}
</code></pre>

<p><a href="http://star2.christianpaton.co.uk/technical-support/product-registration/" rel="nofollow">link to page here</a></p>

<p>I have searched and searched and have not come across what I am doing incorrectly or why this isn't working, any help appreciatted.</p>

<p>cheers chris</p>