• Никакой политики на форуме. Иначе - бан!
  • Вопрос без рабочей ссылки на проблему считается риторическим. Без ссылки и скриншота - провокацией!
  • Темы озаглавленные с маленькой буквы или капсом удаляются без предупреждения!

Отобразить категорию товара (Детали заказа)

Adrenamix

Новичок
Здравствуйте, как мне отобразить категорию возле товара, например у менять есть два одинкавових товара но они находяться в разных категория, и вот когда приходит на почту детали заказа то я не могу определит к какой категории он относится, и незнаю какаой отправлять :(
 

Adrenamix

Новичок
только что решил сам, нужнон просто код вставить function.php

// Display order items product categories (Orders on front end and emails) add_action( 'woocommerce_order_item_meta_end', 'display_custom_data_in_emails', 10, 4 ); function display_custom_data_in_emails( $item_id, $item, $order, $bool ) { // Get the product categories for this item $terms = wp_get_post_terms( $item->get_product_id(), 'product_cat', array( 'fields' => 'names' ) ); // Output a coma separated string of product category names echo "<br><small>" . implode(', ', $terms) . "</small>"; } // Display order items product categories in admin order edit pages add_action( 'woocommerce_after_order_itemmeta', 'custom_admin_order_itemmeta', 15, 3 ); function custom_admin_order_itemmeta( $item_id, $item, $product ){ //if( ! is_admin() ) return; // only backend // Target order "line items" only to avoid errors if( $item->is_type( 'line_item' ) ){ // Get the product categories for this item $terms = wp_get_post_terms( $item->get_product_id(), 'product_cat', array( 'fields' => 'names' ) ); // Output a coma separated string of product category names echo "<br><small>" . implode(', ', $terms) . "</small>"; } }

Источник: https://overcoder.net/q/1297024/отображение-названий-категорий-товаров-в-деталях-заказа-woocommerce
 
Сверху Снизу