I’m using the Product Vendors plugin for WooCommerce (https://woocommerce.com/products/product-vendors/).
I’m also creating a custom loop for a page builder module, which pulls products by ID.
Using the above, I’m able to pull the WC_Product data using:
$thisProduct = new WC_product($id);
From there, I can get the price/product image etc using
$image = $thisProduct->get_image();
$price = $thisProduct->get_price();
Does anyone know how I would be able to pull the Vendors name? I’ve one a var_dump on the full $thisProduct, and it doesn’t contain the vendor name anywhere within.
Any help would be much appreciated!
Thanks guys.
2
Answers
I figure this out, In order to retrieve the vendor information, we can use the following ($id being the product ID)
$sold_by will then contain an array of the vendor info, such as the store name and the link to the vendor store, which we can retrieve such as:
Thanks guys, hopefully this can be of assistance with someone in the future.
If that product is having a vendor mostly it will be saved under ‘post_author’; You can retrieve Vendor by that author id.
This variable
$author
will have all the info like name.