Now sometimes the products get displayed, sometimes not, and whenever our custom cookie is set in the browser and we go to /wp-admin to login, it gives us the following error:致命错误:在非对象上调用成员函数get() Fatal error: Call to a member function get() on a non-object WordPress登录屏幕上的上述错误来自我们 functions.php 文件中的以下函数:The above error on the login screen of WordPress is coming from the following function in our functions.php file:function gfc_insert_coupon_code_to_session(){if( is_user_logged_in() || ! array_key_exists( 'couponid', $_COOKIE ) || WC()->session->get( 'couponid', 0 )){ return;}$couponID = esc_attr( $_COOKIE['couponid'] ); if( $couponID ){ WC()->session->set( 'couponid', $couponID ); }}add_action( 'woocommerce_init', 'gfc_insert_coupon_code_to_session' );推荐答案尝试使用:WC()->session->set( 'couponid', $couponID );致电之前:WC()->session->get( 'couponid', 0 ) 这篇关于无法识别WooCommerce WC()->会话-> get的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-23 12:47