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