How to Display Product Category Name Before Products Name in WooCommerce Emails in WordPress

How to Display Product Category Name Before Products Name in WooCommerce Emails in WordPress

WebTask With Hassan

1 месяц назад

58 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@WebTaskWithHassan
@WebTaskWithHassan - 18.11.2024 09:49

Use this code:

add_filter('woocommerce_order_item_name', 'add_category_to_product_name', 10, 2);
function add_category_to_product_name($item_name, $item) {
if ($item->get_product()) {
$categories = wp_get_post_terms($item->get_product_id(), 'product_cat', array('fields' => 'names'));
if (!empty($categories)) {
$item_name = "Product Category: " . implode(', ', $categories) . ' <br> ' . $item_name;
}
}
return $item_name;
}

Ответить
@GameShort-en9oq
@GameShort-en9oq - 27.11.2024 18:28

Assalamu walaikum Hasan bhai partial payment ka koi coding hoga to dijiye Aur use per video bhi banaen

Ответить