Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
324 views
in Technique[技术] by (71.8m points)

Pass Woocommerce Session from admin to front-end

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...