Only load WC data when WC is active
MAILPOET-5467
This commit is contained in:
committed by
Aschepikov
parent
fe4621f503
commit
6b8fc3df83
@@ -127,24 +127,26 @@ class DynamicSegments {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$data['product_attributes'] = [];
|
$data['product_attributes'] = [];
|
||||||
$productAttributes = $this->woocommerceHelper->wcGetAttributeTaxonomies();
|
if ($this->woocommerceHelper->isWooCommerceActive()) {
|
||||||
|
$productAttributes = $this->woocommerceHelper->wcGetAttributeTaxonomies();
|
||||||
|
|
||||||
foreach ($productAttributes as $attribute) {
|
foreach ($productAttributes as $attribute) {
|
||||||
$taxonomy = 'pa_' . $attribute->attribute_name;// phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
|
$taxonomy = 'pa_' . $attribute->attribute_name;// phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
|
||||||
$attributeTerms = $this->wp->getTerms(
|
$attributeTerms = $this->wp->getTerms(
|
||||||
[
|
[
|
||||||
'taxonomy' => $taxonomy,
|
'taxonomy' => $taxonomy,
|
||||||
'hide_empty' => false,
|
'hide_empty' => false,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!isset($attributeTerms['errors'])) {
|
if (!isset($attributeTerms['errors'])) {
|
||||||
$data['product_attributes'][$taxonomy] = [ // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
|
$data['product_attributes'][$taxonomy] = [ // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
|
||||||
'id' => $attribute->attribute_id, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
|
'id' => $attribute->attribute_id, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
|
||||||
'label' => $attribute->attribute_label, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
|
'label' => $attribute->attribute_label, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
|
||||||
'terms' => $attributeTerms,
|
'terms' => $attributeTerms,
|
||||||
'taxonomy' => $taxonomy,
|
'taxonomy' => $taxonomy,
|
||||||
];
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user