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

Fix compat with WC vendors and product variations (variations do not have any...

Fix compat with WC vendors and product variations (variations do not have any post_author, so we need to use the parent product in this case...
parent f3b0bfe7
No related branches found
No related tags found
No related merge requests found
......@@ -234,7 +234,14 @@ class RulesShippingFrameworkWooCommerce extends RulesShippingFramework {
if (class_exists("WC_Vendors")) {
$vendorids = array();
foreach ($products as $product) {
$vendorids[] = $product['data']->post->post_author;
// Variations inherit the vendor from their parent product
if (!isset($product['variation_id'])) {
// "Normal" product, not a variation
$vendorids[] = $product['data']->post->post_author;
} else {
// A variation => load the parent product instead and use its vendor
$vendorids[] = get_post_field('post_author', $product['product_id']);
}
}
$data['vendorids'] = array_unique($vendorids);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment