Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save EricBusch/ec646153dc399db204edd95cad2750a0 to your computer and use it in GitHub Desktop.
Save EricBusch/ec646153dc399db204edd95cad2750a0 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.
*
* @param array $post Array containing WordPress Post information.
* @param array $product Array containing Datafeedr Product information.
* @param array $set Array containing Product Set information.
* @param string $action Either "update" or "insert" depending on what the Product Set is doing.
*
* @return array Updated $post array.
*/
function mycode_prevent_product_title_content_excerpt_override( $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;
}
add_filter( 'dfrpswc_filter_post_array', 'mycode_prevent_product_title_content_excerpt_override', 999, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment