1

I am trying to manually add a subscription in WooCommerce and keep getting this error.

I have located the PHP file but am unsure of the error. Any help would be appreciated. Thank you.

Fatal error: Uncaught Error: [] operator not supported for strings in /nas/content/live/montkdev/wp-content/plugins/woocommerce-subscriptions/includes/data-stores/class-wcs-customer-store-cached-cpt.php on line 128

Call stack:

WCS_Customer_Store_Cached_CPT::add_subscription_id_to_cache()
wp-content/plugins/woocommerce-subscriptions/includes/data-stores/class-wcs-customer-store-cached-cpt.php:236
WCS_Customer_Store_Cached_CPT::maybe_update_for_post_meta_change()
wp-includes/class-wp-hook.php:303
WP_Hook::apply_filters()
wp-includes/class-wp-hook.php:327
WP_Hook::do_action()
wp-includes/plugin.php:470
do_action()
wp-content/plugins/woocommerce-subscriptions/includes/class-wcs-post-meta-cache-manager.php:234
WCS_Post_Meta_Cache_Manager::trigger_update_cache_hook()
wp-content/plugins/woocommerce-subscriptions/includes/class-wcs-post-meta-cache-manager.php:220
WCS_Post_Meta_Cache_Manager::maybe_trigger_update_cache_hook()
wp-content/plugins/woocommerce-subscriptions/includes/class-wcs-post-meta-cache-manager.php:124
WCS_Post_Meta_Cache_Manager::meta_updated_with_previous()
wp-includes/class-wp-hook.php:303
WP_Hook::apply_filters()
wp-includes/plugin.php:189
apply_filters()
wp-includes/meta.php:205
update_metadata()
wp-includes/post.php:2335
update_post_meta()
wp-content/plugins/woocommerce/includes/data-stores/class-wc-data-store-wp.php:254
WC_Data_Store_WP::update_or_delete_post_meta()
wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-data-store-cpt.php:214
WC_Order_Data_Store_CPT::update_post_meta()
wp-content/plugins/woocommerce-subscriptions/includes/data-stores/class-wcs-subscription-data-store-cpt.php:218
WCS_Subscription_Data_Store_CPT::update_post_meta()
wp-content/plugins/woocommerce/includes/data-stores/abstract-wc-order-data-store-cpt.php:173
Abstract_WC_Order_Data_Store_CPT::update()
wp-content/plugins/woocommerce-subscriptions/includes/data-stores/class-wcs-subscription-data-store-cpt.php:186
WCS_Subscription_Data_Store_CPT::update()
wp-content/plugins/woocommerce/includes/class-wc-data-store.php:179
WC_Data_Store::update()
wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-order.php:185
WC_Abstract_Order::save()
wp-content/plugins/woocommerce/includes/class-wc-order.php:221
WC_Order::save()
wp-content/plugins/woocommerce-subscriptions/includes/admin/meta-boxes/class-wcs-meta-box-subscription-data.php:375
WCS_Meta_Box_Subscription_Data::save()
wp-includes/class-wp-hook.php:303
WP_Hook::apply_filters()
wp-includes/class-wp-hook.php:327
WP_Hook::do_action()
wp-includes/plugin.php:470
do_action()
wp-content/plugins/woocommerce/includes/admin/class-wc-admin-meta-boxes.php:222
WC_Admin_Meta_Boxes::save_meta_boxes()
wp-includes/class-wp-hook.php:305
WP_Hook::apply_filters()
wp-includes/class-wp-hook.php:327
WP_Hook::do_action()
wp-includes/plugin.php:470
do_action()
wp-includes/post.php:4468
wp_insert_post()
wp-includes/post.php:4570
wp_update_post()
wp-admin/includes/post.php:423
edit_post()
wp-admin/post.php:227
mujuonly
  • 11,370
  • 5
  • 45
  • 75

1 Answers1

0

WCS has this issue in the function in the line $subscription_ids[] = $subscription_id; .

/**
 * Add a subscription ID to the cached subscriptions for a given user.
 *
 * @param int $user_id The user the subscription belongs to.
 * @param int $subscription_id A subscription to link the user in the cache.
 */
protected function add_subscription_id_to_cache( $user_id, $subscription_id ) {

    $subscription_ids = $this->get_users_subscription_ids( $user_id );

    if ( ! in_array( $subscription_id, $subscription_ids ) ) {
        $subscription_ids[] = $subscription_id;
        $this->update_subscription_id_cache( $user_id, $subscription_ids );
    }
}

Try adding the below code snippet while adding the subscription if the issue persists.

remove_all_actions('wcs_update_post_meta_caches');
mujuonly
  • 11,370
  • 5
  • 45
  • 75