Simply trying to store and retrieve unregistered customer data from page to page in a custom checkout template. I've stripped it down to the bare bones to try to pinpoint the issue.
This
<?php
$customer = WC()->customer;
$customer->set_billing_first_name("WORKING!!!");
$customer->save();
var_dump($customer->get_billing());
?>
Outputs this
array (size=2)
'country' => string 'US' (length=2)
'first_name' => string 'WORKING!!!' (length=10)
But then this
<?php
$customer = WC()->customer;
//$customer->set_billing_first_name("WORKING!!!");
//$customer->save();
var_dump($customer->get_billing());
?>
Outputs this
array (size=1)
'country' => string 'US' (length=2)
Even though I should still be firmly within the same session, and therefore should get the data stored before the comments. All I did was refresh the page after commenting out those two lines.
Am I completely wrong about these methods?
Checked
Environment is configured entirely correctly. Even had someone else double-check it for me. URLs, caches, etc.
It does appear to work when logged in, but the vast majority of users never do so that's not very helpful.
Have tried this on two different servers (one local, one remote) and have the same issue.
Started fresh with a new WP+WC install, created a blank theme, functions.php that does the above on init code. Same exact issue.