Advertisement
verygoodplugins

Untitled

Oct 24th, 2017
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. add_action('init', 'reset_product_ids');
  2.  
  3. function reset_product_ids() {
  4.    
  5.     if(isset($_GET['woo_reset_wpf_product_ids'])) {
  6.  
  7.         $args = array(
  8.             'numberposts' => -1,
  9.             'post_type'   => 'product',
  10.             'fields'      => 'ids',
  11.             'meta_query'  => array(
  12.                 array(
  13.                     'key'     => wp_fusion()->crm->slug . '_product_id',
  14.                     'compare' => 'EXISTS'
  15.                 )
  16.             )
  17.         );
  18.  
  19.         $products = get_posts( $args );
  20.  
  21.         foreach( $products as $product_id ) {
  22.             delete_post_meta( $product_id, wp_fusion()->crm->slug . '_product_id' );
  23.         }
  24.  
  25.     }
  26.    
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement