Skip Navigation

[Resolved] Toolset created empty custom fields in Woocommerce products

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 1.02 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 5 replies, has 3 voices.

Last updated by Waqar 1 year ago.

Assisted by: Waqar.

Author
Posts
#2577765
Screenshot 2023-03-21 at 08-16-06 Custom Fields Group ‹ Weatherby Inc. — WordPress.png
Screenshot 2023-03-21 at 08-14-30 Edit product “Delta Long Sleeve” ‹ Weatherby Inc. — WordPress.png

After updating to 3.6.5 and Toolset Types 3.8.1 yesterday, I noticed a lot of empty fields titled "Toolset Woocommerce" (I've attached a screenshot). I also noticed a matching set of un-editable fields in Toolset (screenshot attached). The problem seems like the same as this thread topic (https://toolset.com/forums/topic/toolset-creates-empty-custom-fields-in-woocommerce-productpage-in-backend/). I'm not sure if that fix mentioned in that thread is what I also need to do or if there's something else. Everything was working fine up until the recent update.

#2577863

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi there

This can happen because of third party interference in the queries Toolset uses to check whether the special custom field group it creates for WooCommerce compatibility already exists or not. Some third party code is indiscriminately modifying queries (probably on the WC products or orders pages) that makes it appear that the field group does not exist, and so Toolset keeps creating it.

Unfortunately it requires a trial and error process of elimination to try and identify which product (probably a plugin, possibly the theme or custom code added to the site) is responsible.

First, you'll want to eliminate the surplus groups. You can run this code snippet as many times as is necessary (it eliminates up to 25 field groups at a time, the largest batch size possible for this):

$wcfgs = get_posts( array(
    'post_type' => 'wp-types-group',
    'title' => 'Toolset WooCommerce',
    'numberposts' => 25
));
 
foreach ($wcfgs as $key => $wcfg) {
    wp_delete_post( $wcfg->ID, true );
}

You can add that at Toolset > Settings > Code Snippets. Don't activate it, but instead use the Run Now option to run the code once, and then keep doing that as many times as is needed to remove all the duplicates.

Second, we need to identify the cause of the problem, preferably on a staging site if you have one available. You'll need to deactivate all plugins, then visit Toolset > Custom Fields and confirm there is no more than one such field group. Then reactivate plugins, visit the WC products list and the orders page, then check the field groups. If there are still no surplus groups, try reactivating more plugins and repeat. (It may be quicker to do this in batches rather than one-by-one.)

If you identify what prompts creating the surplus field groups let me know and then I can investigate why.

#2577891

Ok, I ran the snippet and that seemed to clear out the empty fields from the production site.

I do have a staging environment, but don't have toolset configured/allowed for that environment yet. Let me get it set up and I'll get everything updated and get you access.

#2578281

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Sure, please take your time and let us know about your findings.

regards,
Waqar

#2578799

I added Toolset and got it set up to my staging environment. However, the only difference is that a customizer plugin does not work on the staging environment because of licensing. So it's not an "exact" copy of the production environment. The woocommerce toolset fields do not show up in the staging environment.

Also, five new Woocommerce Toolset fields showed up on production this morning. Do I need to run that code snippet every day then?

#2580267

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks for writing back.

From your website's debug information, I'll assume you're referring to the 'Kirki Customizer Framework' plugin.

Would it be possible to temporarily activate the license of the plugin on the staging environment or temporarily deactivate it on the production one? The goal is to confirm that this plugin is what is causing this behavior.

Also, you can make that code snippet execute only once every day, by including it inside the scheduled CRON job like this:


add_action( 'init', function () {

	$hook = 'run_snippet_daily';
	$args = array();

	if ( ! wp_next_scheduled( $hook, $args ) ) {
		wp_schedule_event( time(), 'daily', $hook, $args );
	}
} );

add_action( 'run_snippet_daily', function () {
	
	// do something once each day
	$wcfgs = get_posts( array(
		'post_type' => 'wp-types-group',
		'title' => 'Toolset WooCommerce',
		'numberposts' => 25
	));
	  
	foreach ($wcfgs as $key => $wcfg) {
		wp_delete_post( $wcfg->ID, true );
	}
	
} );

Note: The above code snippet can be included in the 'functions.php' file of the active theme.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.