Site icon Qaisar Satti's Blogs

How to Add More product Information in WooCommerce Programmatically

Today, we are going to learn about adding more information to products in WooCommerce programmatically. This is a beginner guide, so feel free to use the code on your own websites and modify it as you like. If you plan on executing this code on a live website, we strongly suggest speaking with a professional developer. To add more product information in WooCommerce programmatically, copy and post the following code:

update_post_meta( $productId, '_visibility', 'visible' );
update_post_meta( $productId, '_stock_status', 'instock');
update_post_meta( $productId, 'total_sales', '0' );
update_post_meta( $productId, '_sale_price', '' );
update_post_meta( $productId, '_purchase_note', '' );
update_post_meta( $productId, '_product_attributes', array() );
update_post_meta( $productId, '_sale_price_dates_from', '' );
update_post_meta( $productId, '_sale_price_dates_to', '' );
update_post_meta( $productId, '_price', '' );
update_post_meta( $productId, '_sold_individually', '' );
update_post_meta( $productId, '_manage_stock', 'no' );
update_post_meta( $productId, '_backorders', 'no' );
update_post_meta( $productId, '_featured', 'no' );
update_post_meta( $productId, '_weight', '' );
update_post_meta( $productId, '_length', '' );
update_post_meta( $productId, '_width', '' );
update_post_meta( $productId, '_height', '' );
update_post_meta( $productId, '_sku', '' );
update_post_meta( $productId, '_downloadable', 'no' );
update_post_meta( $productId, '_virtual', 'yes' );
update_post_meta( $productId, '_regular_price', '' );

If everything goes right, a new product should appear on the product listing page in the WooCommerce dashboard.

That’s the end of this tutorial; stay tuned for more WordPress and WooCommerce tutorials like this one.

Exit mobile version