Woocommerce INTERNAL attribute issue
-
UPD: Не видел что вы ответили на прошлую тему. Не знаю как удалить дубликат. Прошу решить. Очень важно и срочно…
Функция function is_wc_product_not_converted_attribute не работает. внутренние атрибуты товара (не глобальные!) переводятся всегда! По итогу на фронтенде может показываться “tsvet”, вместо “Цвет”. Хотя он вообще не должен был их трогать. Это очень серьёзная недоработка.
The is_wc_product_not_converted_attribute function doesn’t work. Internal product attributes (not global ones!) are always converted! As a result, the frontend might show “tsvet” instead of “Colour.” Even though it shouldn’t have touched them at all. This is a very serious flaw.protected function is_wc_product_not_converted_attribute( string $title ): bool {
global $product;
if ( ! is_a( $product, 'WC_Product' ) ) {
return false;
}
// We have to get attributes from postmeta here to see the converted slug.
$attributes = (array) get_post_meta( $product->get_id(), '_product_attributes', true );
foreach ( $attributes as $slug => $attribute ) {
$name = $attribute['name'] ?? '';
if ( $name === $title && sanitize_title_with_dashes( $title ) === $slug ) {
return true;
}
}
return false;
}
You must be logged in to reply to this topic.