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

Add evaluate_for_shippingclasses scoping function

parent 2c029632
No related branches found
No related tags found
No related merge requests found
...@@ -23,6 +23,7 @@ class RulesShippingFrameworkWooCommerce extends RulesShippingFramework { ...@@ -23,6 +23,7 @@ class RulesShippingFrameworkWooCommerce extends RulesShippingFramework {
"products" => 'products', "products" => 'products',
"skus" => 'products', "skus" => 'products',
"vendors" => 'vendors', "vendors" => 'vendors',
"shippingclasses" => 'shippingclasses',
)); ));
} }
static function getHelper() { static function getHelper() {
...@@ -473,6 +474,17 @@ class RulesShippingFrameworkWooCommerce extends RulesShippingFramework { ...@@ -473,6 +474,17 @@ class RulesShippingFrameworkWooCommerce extends RulesShippingFramework {
if (!empty($filter_conditions['subcategories']) && count(array_intersect($subcategories, $prodcategories))==0) if (!empty($filter_conditions['subcategories']) && count(array_intersect($subcategories, $prodcategories))==0)
continue; 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'])) { if (!empty($filter_conditions['vendors'])) {
// Collect all vendors (ids and slug/login_name - PLUGIN-specific!) // Collect all vendors (ids and slug/login_name - PLUGIN-specific!)
// for the current product. If any of them is in the vendor conditions // for the current product. If any of them is in the vendor conditions
...@@ -480,8 +492,8 @@ class RulesShippingFrameworkWooCommerce extends RulesShippingFramework { ...@@ -480,8 +492,8 @@ class RulesShippingFrameworkWooCommerce extends RulesShippingFramework {
$vnd_props = array(); $vnd_props = array();
// THIRD-PARTY SUPPORT // THIRD-PARTY SUPPORT
// "WC Vendors" support (vendors stored as post author) // "WC Vendors" and "Dokan Marketplace" support (vendors stored as post author)
if (class_exists("WC_Vendors")) { if (class_exists("WC_Vendors") || class_exists("WeDevs_Dokan")) {
$vendor = $p['data']->post->post_author; $vendor = $p['data']->post->post_author;
$vnd = get_user_by('id', $vendor); // Get user name by user id $vnd = get_user_by('id', $vendor); // Get user name by user id
$vnd_props[] = $vendor; $vnd_props[] = $vendor;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment