From e2627fbd08faf47a706e3946d13c1e05c559af0c Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer <reinhold@kainhofer.com> Date: Sat, 24 Feb 2018 23:12:34 +0100 Subject: [PATCH] Add evaluate_for_shippingclasses scoping function --- .../rules_shipping_framework_woocommerce.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/includes/rules_shipping_framework_woocommerce.php b/includes/rules_shipping_framework_woocommerce.php index 0c6fd95..5696946 100644 --- a/includes/rules_shipping_framework_woocommerce.php +++ b/includes/rules_shipping_framework_woocommerce.php @@ -23,6 +23,7 @@ class RulesShippingFrameworkWooCommerce extends RulesShippingFramework { "products" => 'products', "skus" => 'products', "vendors" => 'vendors', + "shippingclasses" => 'shippingclasses', )); } static function getHelper() { @@ -473,6 +474,17 @@ class RulesShippingFrameworkWooCommerce extends RulesShippingFramework { if (!empty($filter_conditions['subcategories']) && count(array_intersect($subcategories, $prodcategories))==0) continue; + if (!empty($filter_conditions['shippingclasses'])) { + $shipclass = $p['data']->get_shipping_class(); + if ($shipclass) { + if (!in_array($shipclass, $filter_conditions['shippingclasses'] )) + continue; + } else { + // No shipping class set for product, but scoping has a valid shipping clase => filter out product + continue; + } + } + if (!empty($filter_conditions['vendors'])) { // Collect all vendors (ids and slug/login_name - PLUGIN-specific!) // for the current product. If any of them is in the vendor conditions @@ -480,8 +492,8 @@ class RulesShippingFrameworkWooCommerce extends RulesShippingFramework { $vnd_props = array(); // THIRD-PARTY SUPPORT - // "WC Vendors" support (vendors stored as post author) - if (class_exists("WC_Vendors")) { + // "WC Vendors" and "Dokan Marketplace" support (vendors stored as post author) + if (class_exists("WC_Vendors") || class_exists("WeDevs_Dokan")) { $vendor = $p['data']->post->post_author; $vnd = get_user_by('id', $vendor); // Get user name by user id $vnd_props[] = $vendor; -- GitLab