Select all product woocommerce

you could use something like this: $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => -1 ); $results = new WP_Query( $args ); $products = $results->posts; $json_data = array(); foreach($products as $product){ $product = wc_get_product( $product->ID); if($product->is_visible()){ $json_data[] = array( ‘id’=> $product->get_id(), ‘title’=> $product->get_title(), ); } } $output= json_encode($json_data); reutrn $output this part get all the … Read more

Add WooCommerce vendor slug to auto-generated SKU

There’s a class WC_Product_Vendors_Utils that you can use e.g. $vendor = WC_Product_Vendors_Utils::is_vendor_product( $item[“product_vendors_product_id”] ); //replace this with the product ID if ( ! empty( $vendor[0] ) ) { $vendor_data = WC_Product_Vendors_Utils::get_vendor_data_by_id( $vendor[0]->term_id ); if ( ! empty( $vendor_data ) ) { $vendor_slug = $vendor_data[‘slug’]; // I am not sure of the correct value here but … Read more