Prevent product titles, descriptions & excerpts from being overwritten during Product Set updates

Here's the code you need to prevent customized product titles, excerpts and descriptions from being overwritten during a Product Set update. This is useful if you customize product titles or descriptions after the products are imported into your WooCommerce store.

By default, all fields (except the image field) are overwritten on update. To prevent data from being overwritten, action must be taken.

1

Create a custom plugin

If you haven't done so already, create a custom plugin.

2

Add custom code

Add the following custom code to your custom plugin:

add_filter( 'dfrpswc_filter_post_array', function ( $post, $product, $set, $action ) {

   if ( 'insert' === $action ) {
      return $post;
   }

   unset( $post['post_title'] );    // Prevent title from being overwritten.
   unset( $post['post_content'] );  // Prevent description from being overwritten.
   unset( $post['post_excerpt'] );  // Prevent excerpt from being overwritten.

   return $post;

}, 50, 4 );
3

Save

Save your custom plugin file.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us