Skip to content

Instantly share code, notes, and snippets.

@EricBusch
Last active November 6, 2022 11:05
Show Gist options
  • Save EricBusch/75169e64fd244efae226c5c3c04764c4 to your computer and use it in GitHub Desktop.
Save EricBusch/75169e64fd244efae226c5c3c04764c4 to your computer and use it in GitHub Desktop.
Prevent the product name, product description and product excerpt from being overwritten during a Product Set update. [datafeedr]
<?php
/**
* Prevent product titles, descriptions & excerpts from being overwritten during Product Set updates.
*/
add_filter( 'dfrpswc_filter_post_array', 'mycode_prevent_product_title_content_excerpt_override', 999, 4 );
function mycode_prevent_product_title_content_excerpt_override( $post, $product, $set, $action ) {
if ( $action == 'update' ) {
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment