Technical Solutions: Cannot Edit Products in Woocommerce

Welcome to Sydney Business Web Technical Solutions 

Every day, we solve problems for eCommerce website owners. We had a think about how we might use this activity to help others, and came up with this idea: Every week, we'll take the trickiest problem and publish our solution. 

Important! - Some of these solututions involve adding code to your website (WordPress and Woocommerce mostly), so please ALWAYS be careful. We are not in any way responsible, directly or indirectly for any impact or consequences our code or advice has on your website, nor are we liable for any damage arising from such use.

Always back up your website before changing or adding code and/or editing the database, This is critically important!!!

PROBLEM 1: Could not Edit Products

Our customer informed us that any attempt to edit a product resulted in a  time-out. This should never happen and indicates a possible database malfunction. We already had a databse optimization plugin installed: Advanced Database Cleaner.

(Note: This is installed on >100,000 websites but is currently lagging behind WordPress Updates. We have tested with WordPress 6.3 and Woocommerce 8.02)

What we found was a hundreds of Woocommerce exppired transients (transients in WooCommerce are a mechanism for caching time-sensitive data to enhance performance. They're an integral part of the WooCommerce system, helping reduce the load on the database and speeding up operations). But they do need to be cleaned up and this was not happening. So we decided to save some time and write some code to clear them safely, periodically.

Using the Code Snippets Plugin

Adding code to core files in WordPress and Woocommerce is simply inadvisable for a range of reasons. We always use a plugin called Code Snippets. It's simple, reliable, stable, and a pleasure to use. Next we wrote the php code which is copied below:

// Add this code to your theme's functions.php file or in a custom plugin

// Step 1: Function to clear WooCommerce transients
function clear_woocommerce_transients() {
if ( function_exists('wc_delete_expired_transients') ) {
wc_delete_expired_transients(); // Deletes expired transients
}

// Optionally, if you want to delete all WooCommerce transients (not just the expired ones):
// global $wpdb;
// $wpdb->query( "DELETE FROM `$wpdb->options` WHERE `option_name` LIKE ('_transient_wc_%')" );
// $wpdb->query( "DELETE FROM `$wpdb->options` WHERE `option_name` LIKE ('_transient_timeout_wc_%')" );
}

// Step 2: Set up WP-Cron job to run the above function every 2 hours
function setup_cron_to_clear_transients() {
if ( ! wp_next_scheduled( 'clear_woocommerce_transients_hook' ) ) {
wp_schedule_event(time(), '2hours', 'clear_woocommerce_transients_hook');
}
}
add_action('wp', 'setup_cron_to_clear_transients');
add_action('clear_woocommerce_transients_hook', 'clear_woocommerce_transients');

// Ensure '2hours' recurrence schedule exists
function add_2hours_cron_recurrence($schedules) {
$schedules['2hours'] = array(
'interval' => 2 * 60 * 60,
'display' => __('Every 2 Hours'),
);
return $schedules;
}
add_filter('cron_schedules', 'add_2hours_cron_recurrence');
//Copyright Sydney Business Web

Results

The plugin cleared expired Woocommerce transients and restored operation.  We are still checlking to make sure it works every two hours.

Need help? - 

Frequently Asked Technical Questions

Why can't I edit products in WooCommerce? It times out every time.

This was the exact issue a client faced — timeouts when trying to edit any product in WooCommerce (v8.x), even though they had the Advanced Database Cleaner plugin installed.

Cause: Hundreds of expired WooCommerce transients had accumulated in the database and weren't being cleared automatically. These bloated the options table and caused timeouts/database strain during product edits.

Solution we implemented: Added safe custom code via the Code Snippets plugin to run wc_delete_expired_transients() and scheduled it with WP-Cron to run every 2 hours. Operation was restored immediately after the first cleanup.

Always back up your site before adding code — see our full solution on the Technical Solutions page.

What causes WooCommerce transients to build up and slow everything down?

WooCommerce generates transients for caching (product data, sessions, reports, etc.). If your cron isn't running reliably or plugins interfere, expired ones aren't deleted. Over months this can lead to thousands of rows in wp_options, causing slow queries and timeouts — exactly what happened in our documented client case.

Is it safe to delete expired transients in WooCommerce?

Yes — WooCommerce provides the wc_delete_expired_transients() function specifically for this. It only removes expired ones, so active caches remain intact. We avoid aggressive "delete all" queries unless absolutely necessary.

How do I add the transient cleanup code without breaking my site?

Use the free Code Snippets plugin (never edit functions.php directly). Add the function and WP-Cron scheduling code we published. It includes a custom 'every 2 hours' schedule. Test on staging first if possible.

Why doesn't my Advanced Database Cleaner (or similar plugin) fix the transients issue?

Some plugins only clean on manual button press or have limited scope for WooCommerce-specific transients. In our client example, hundreds remained despite the plugin being active — automated scheduled cleanup via code was the reliable fix.

Can cache bloat cause 503 errors when logging into WordPress?

Yes — excessive transients and object cache bloat can overload the database/server, leading to 503 service unavailable errors (especially on login or admin-ajax calls). We've documented a similar case where cache bloat blocked backend access.

What other common technical issues do you solve for developers and agencies?

We regularly publish fixes for WordPress + WooCommerce problems like: slow admin, broken checkout, cron failures, plugin conflicts, migration errors, performance bottlenecks, custom post type issues, and more. Check the Technical Solutions page for the latest.

Do I need to be a developer to use your code solutions?

No — many are copy-paste ready for the Code Snippets plugin. We include warnings and explain what each piece does. If you're unsure, our team can implement them safely for you.

How often do you publish new technical solutions?

We aim to release new real-world fixes weekly (or as we encounter/solve them for clients). All are based on actual problems we've fixed for eCommerce sites.

What should I do if I have a tricky WordPress/WooCommerce problem?

Contact Sydney Business Web! We specialise in rescuing stalled projects, fixing performance killers, and providing clean solutions for developers/agencies. Use the form on our site or reply here — we usually respond quickly.

CONTACT SYDNEY BUSINESS WEB NOW!

Call Us
Email us