问题
I try to pass datas from admin to front like :
WC()->frontend_includes();
WC()->session = new WC_Session_Handler();
WC()->session->set('datas', array(
'_email' => "email_here"
));
And retrieve them in front. For example here :
function action_woocommerce_before_checkout_form($wccm_autocreate_account)
{
$datas = WC()->session->get('datas');
var_dump($datas);
}
add_action('woocommerce_before_checkout_form', 'action_woocommerce_before_checkout_form', 10, 1);
add_action('woocommerce_before_cart_contents', 'action_woocommerce_before_checkout_form', 10, 1);
When I var_dump $datas in admin, I see my values but not on front
来源:https://stackoverflow.com/questions/65552426/pass-woocommerce-session-from-admin-to-front-end