Advertisement
developerjustin

Untitled

Apr 18th, 2014
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.51 KB | None | 0 0
  1.     global $woocommerce;
  2.  
  3.     $my_post = array(
  4.       'post_title'    => 'My post',
  5.       'post_content'  => 'This is my post.',
  6.       'post_status'   => 'publish',
  7.       'post_author'   => 1,
  8.       'post_type'     =>'product'
  9.     );
  10.  
  11.     // Insert the post into the database
  12.     $product_ID = wp_insert_post( $my_post );
  13.  
  14.     if ( $product_ID ){
  15.       add_post_meta($product_ID, '_regular_price', 100 );
  16.       add_post_meta($product_ID, '_price', 100 );
  17.       add_post_meta($product_ID, '_stock_status', 'instock' );
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement