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
评论列表(0条)