WP-e-Commerce
WP-e-Commerce copied to clipboard
Activating WPEC via WP CLI error - Call to undefined function wpsc_get_current_customer_id
I see the following when I activate WPEC 3.12.0 via WP CLI:
wp plugin activate wp-e-commerce --url=https://mysite.com
Plugin 'wp-e-commerce' activated.
Success: Activated 1 of 1 plugins.
PHP Fatal error: Uncaught Error: Call to undefined function wpsc_get_current_customer_id() in /var/www/mu/mysite/wp-content/plugins/wp-e-commerce/wpsc-core/wpsc-functions.php:649
Stack trace:
#0 /var/www/mu/mysite/wp-includes/class-wp-hook.php(298): wpsc_serialize_shopping_cart('')
#1 /var/www/mu/mysite/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters(NULL, Array)
#2 /var/www/mu/mysite/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
#3 /var/www/mu/mysite/wp-includes/load.php(677): do_action('shutdown')
#4 [internal function]: shutdown_action_hook()
#5 {main}
thrown in /var/www/mu/mysite/wp-content/plugins/wp-e-commerce/wpsc-core/wpsc-functions.php on line 649
Fatal error: Uncaught Error: Call to undefined function wpsc_get_current_customer_id() in /var/www/mu/mysite/wp-content/plugins/wp-e-commerce/wpsc-core/wpsc-functions.php:649
Stack trace:
#0 /var/www/mu/mysite/wp-includes/class-wp-hook.php(298): wpsc_serialize_shopping_cart('')
#1 /var/www/mu/mysite/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters(NULL, Array)
#2 /var/www/mu/mysite/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
#3 /var/www/mu/mysite/wp-includes/load.php(677): do_action('shutdown')
#4 [internal function]: shutdown_action_hook()
#5 {main}
thrown in /var/www/mu/mysite/wp-content/plugins/wp-e-commerce/wpsc-core/wpsc-functions.php on line 649
Just hit this too. Probably could get away with keeping it by just wrapping it in a function_exists() call:
function wpsc_serialize_shopping_cart() {
global $wpsc_cart;
if ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) )
return;
if ( is_object( $wpsc_cart ) ) {
$wpsc_cart->errors = array();
}
if ( function_exists( 'wpsc_get_current_customer_id' ) ) {
// need to prevent set_cookie from being called at this stage in case the user just logged out
// because by now, some output must have been printed out
$customer_id = wpsc_get_current_customer_id();
if ( $customer_id ) {
wpsc_update_customer_cart( $wpsc_cart, $customer_id );
}
}
return true;
}
@DrewAPicture Would happily accept that PR 👍
PR: #2316