From 2732c685cb8b9d9918a8af225e8613c7577ddad3 Mon Sep 17 00:00:00 2001
From: Reinhold Kainhofer <reinhold@kainhofer.com>
Date: Sat, 2 Sep 2017 14:33:41 +0200
Subject: [PATCH] Add WC Product Vendors 2.0 support to evaluate_for_vendors,
 too

---
 includes/rules_shipping_framework_woocommerce.php | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/includes/rules_shipping_framework_woocommerce.php b/includes/rules_shipping_framework_woocommerce.php
index bd7da51..3199766 100644
--- a/includes/rules_shipping_framework_woocommerce.php
+++ b/includes/rules_shipping_framework_woocommerce.php
@@ -444,13 +444,20 @@ class RulesShippingFrameworkWooCommerce extends RulesShippingFramework {
 					$vnd_props[] = $vnd->user_login;
 				}
 
-				// "WooThemes Product Vendors" support (vendors stored in its own taxonomy)
+				// "WooThemes Product Vendors"<2.0 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);
 					}
 				}
 
+				// "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")) {
+					$vndid = WC_Product_Vendors_Utils::get_vendor_id_from_product($p['data']->get_id());
+					$vendor = WC_Product_Vendors_Utils::get_vendor_data_by_id($vndid);
+					$vnd_props[] = urldecode($vendor["slug"]);
+				}
+
 				// "YITH WooCommerce Multi Vendor" support (vendors stored in its own taxonomy)
 				if (function_exists("yith_get_vendor")) {
 					$vendor = yith_get_vendor($p['data']->id, 'product');
-- 
GitLab