Inserting Vendor + Product from Code
-
The code below DOES succeed in creating a new vendor merchant and inserting a product in the vendor store…
except…
1) The Vendor does not appear in the vendors list when the [wcv_vendorslist] short tag is used
2) When the product is purchased from the vendor store, the sales does not appear in the vendor’s sale display
Any other meta-data (and so forth) that I must be setting to make this work?
function diag(){ $userdata = array( 'user_email' => '[email protected]', 'user_login' => 'BHSSpartans', 'display_name' => 'BHSSpartans', 'user_nicename' => 'BHSSpartans', 'nickname' => 'BHSSpartans', 'first_name' => 'Bubba', 'last_name' => 'Baggins', 'role' => 'vendor',); $author = wp_insert_user($userdata); echo 'User ID: ' . $author . '<br />'; $post_id = wp_insert_post(array( 'post_author' => $author, 'post_title' => 'Noble Fir 8 Foot', 'post_type' => 'product', 'post_status' => 'publish', 'post_content' => 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.', 'post_excerpt' => 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.' )); echo 'POST ID: ' . $post_id; wp_set_object_terms( $post_id, 'simple', 'product_type' ); update_post_meta( $post_id, '_visibility', 'visible' ); update_post_meta( $post_id, '_stock_status', 'instock'); update_post_meta( $post_id, 'total_sales', '0' ); update_post_meta( $post_id, '_downloadable', 'no' ); update_post_meta( $post_id, '_virtual', 'yes' ); update_post_meta( $post_id, '_regular_price', '77.00' ); update_post_meta( $post_id, '_sale_price', '67.00' ); update_post_meta( $post_id, '_purchase_note', '' ); update_post_meta( $post_id, '_featured', 'no' ); update_post_meta( $post_id, '_weight', '11' ); update_post_meta( $post_id, '_stock_status', 'instock' ); update_post_meta( $post_id, '_length', '11' ); update_post_meta( $post_id, '_width', '11' ); update_post_meta( $post_id, '_height', '11' ); update_post_meta( $post_id, '_sku', 'BHSSpartansNoFir8' ); update_post_meta( $post_id, '_sale_price_dates_from', '' ); update_post_meta( $post_id, '_sale_price_dates_to', '' ); update_post_meta( $post_id, '_price', '67.00' ); update_post_meta( $post_id, '_sold_individually', 'yes' ); update_post_meta( $post_id, '_manage_stock', 'no' ); update_post_meta( $post_id, '_backorders', 'no' ); update_post_meta( $post_id, '_stock', 50 ); wc_update_product_stock($post_id, 50, 'set'); }
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Inserting Vendor + Product from Code’ is closed to new replies.