Skip to content
Snippets Groups Projects
Commit 10593a23 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Support for WooCommerce Product Vendors >=2.0

parent 7f7b3fae
Branches
Tags
No related merge requests found
......@@ -242,7 +242,7 @@ class RulesShippingFrameworkWooCommerce extends RulesShippingFramework {
$data['vendors'] = array_unique($vendors);
}
// "WooThemes Vendor Products" support (vendors stored in its own taxonomy)
// "WooThemes Vendor Products" <2.0 support (vendors stored in its own taxonomy)
if (class_exists("WooCommerce_Product_Vendors") && function_exists("get_product_vendors")) {
$vendors = array();
$vendornames = array();
......@@ -250,7 +250,6 @@ class RulesShippingFrameworkWooCommerce extends RulesShippingFramework {
// The plugin provides its own function to retrieve the vendor for a product
foreach ($products as $product) {
foreach (get_product_vendors($product['data']->get_id()) as $vendor) {
// $this->printWarning("<pre>vendor: ".print_r($vendor,1)."</pre>");
$vendors[] = urldecode($vendor->slug);
$vendornames[] = $vendor->title;
$vendorids[] = $vendor->ID;
......@@ -260,6 +259,25 @@ class RulesShippingFrameworkWooCommerce extends RulesShippingFramework {
$data['vendornames'] = array_unique($vendornames);
$data['vendorids'] = array_unique($vendorids);
}
// "WooThemes Vendor Products" >=2.0 support (vendors stored in its own taxonomy)
if (class_exists("WC_Product_Vendors") && method_exists("WC_Product_Vendors_Utils", "get_vendor_id_from_product")) {
$vendors = array();
$vendornames = array();
$vendorids = array();
// The plugin provides its own function to retrieve the vendor for a product
foreach ($products as $product) {
$vndid = WC_Product_Vendors_Utils::get_vendor_id_from_product($product['data']->get_id());
if ($vndid>0) {
$vendor = WC_Product_Vendors_Utils::get_vendor_data_by_id($vndid);
$vendors[] = urldecode($vendor["slug"]);
$vendornames[] = $vendor["name"];
$vendorids[] = $vendor["term_id"];
}
}
$data['vendors'] = array_unique($vendors);
$data['vendornames'] = array_unique($vendornames);
$data['vendorids'] = array_unique($vendorids);
}
// "YITH WooCommerce Multi Vendor" support (vendors stored in its own taxonomy)
if (function_exists("yith_get_vendor")) {
......@@ -426,7 +444,7 @@ class RulesShippingFrameworkWooCommerce extends RulesShippingFramework {
$vnd_props[] = $vnd->user_login;
}
// "WooThemes Vendor Products" support (vendors stored in its own taxonomy)
// "WooThemes Product Vendors" support (vendors stored in its own taxonomy)
if (class_exists("WooCommerce_Product_Vendors") && function_exists("get_product_vendors")) {
foreach (get_product_vendors($p['data']->id) as $vendor) {
$vnd_props[] = urldecode($vendor->slug);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment