Pass Woocommerce Session from admin to front-end

会有一股神秘感。 提交于 2021-01-05 09:00:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!