Why isn't working WooCommerce session inside shortcode?

Hope you're doing great! I am trying to print the WC()->session->get inside a shortcode but getting error , b

Hope you're doing great! I am trying to print the WC()->session->get inside a shortcode but getting error , bellow is my code and error

function set_session(){

    global $woocommerce;
    WC()->session->set( 'some_data_get' ,' some_data_get' );    

}
add_action( 'init', 'set_session' );

function show_session(){

   global $woocommerce;
   var_dump(  WC()->session->get( 'some_data_get' ) );

}
add_shortcode( 'show_session', 'show_session' );

do_shortcode('[show_session]');

here is error

Fatal error: Uncaught Error: Call to a member function get() on null in E:\OFFICE-SERVER\htdocs\aspw\wp-content\themes\twentynineteen\functions.php:335 

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745293199a4620986.html

相关推荐

  • Why isn't working WooCommerce session inside shortcode?

    Hope you're doing great! I am trying to print the WC()->session->get inside a shortcode but getting error , b

    13小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信