jarvis Posted October 7, 2020 Share Posted October 7, 2020 Hi, Am hoping someone can please help. I've the following code: $chosen_methods = WC()->session->get( 'chosen_shipping_methods' ); $chosen_method = explode(':', reset($chosen_methods) ); The first line returns the warning: "Warning: reset() expects parameter 1 to be array, null given in" I've tried the following: $chosen_method = ''; $chosen_method = NULL; $chosen_methods = array(); Sadly, none have worked. What am I missing? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/311569-reset-expects-parameter-1-to-be-array-null-given/ Share on other sites More sharing options...
requinix Posted October 7, 2020 Share Posted October 7, 2020 $chosen_methods = WC()->session->get( 'chosen_shipping_methods' ); Apparently there is no "chosen_shipping_methods" value in the session. You need to provide a default - an array of shipping method values to use when that session value isn't present. Guessing based on the code, you can do so with $chosen_methods = WC()->session->get( 'chosen_shipping_methods' ) ?? ['suitable:set:of:values']; 1 Quote Link to comment https://forums.phpfreaks.com/topic/311569-reset-expects-parameter-1-to-be-array-null-given/#findComment-1581747 Share on other sites More sharing options...
jarvis Posted October 7, 2020 Author Share Posted October 7, 2020 Ah! Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/311569-reset-expects-parameter-1-to-be-array-null-given/#findComment-1581748 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.