Adding a Dokan product dynamically and setting the Vendor
-
Hi, I need to add a Dokan product dynamically on the click of a button. I have done this successfully with the following code but need help with setting the Vendor of the product created. By default, it creates the product under the Admins username but I want to set the Vendor to another user. Is there a Vendor attribute I can set? Hope someone can help.
$objProduct = new WC_Product();
$objProduct->set_name($_POST[‘jobTitle’] . ” TEST” );
$objProduct->set_status(“publish”);
$objProduct->set_catalog_visibility(‘hidden’);
$objProduct->set_description(“Product Description”);
$objProduct->set_sku(‘1234’]);
$objProduct->set_price(20);
$objProduct->set_regular_price(15);
$objProduct->set_manage_stock(true);
$objProduct->set_stock_quantity(10);
$objProduct->set_stock_status(‘instock’);
$objProduct->set_backorders(‘no’);
$objProduct->set_reviews_allowed(true);
$objProduct->set_sold_individually(false);
$objProduct->set_virtual(‘yes’);
$objProduct->set_category_ids(array(1,2,3));
$new_product_id = $objProduct->save();
- The topic ‘Adding a Dokan product dynamically and setting the Vendor’ is closed to new replies.