1
Woocommerce 용 플러그 스마트 쿠폰을 사용하고 있습니다. 우편으로받은 상품권을 맞춤 설정하려고 할 때 주문에 포함 된 상품 카테고리를 표시 할 수 없습니다.WooCommerce 전자 메일 알림에서 주문 항목의 제품 범주 표시
주문의 이메일에 제품 카테고리를 표시하는 방법은 무엇입니까? $order
합니다 (WC_Order
객체의 인스턴스)으로
Woocommerce 용 플러그 스마트 쿠폰을 사용하고 있습니다. 우편으로받은 상품권을 맞춤 설정하려고 할 때 주문에 포함 된 상품 카테고리를 표시 할 수 없습니다.WooCommerce 전자 메일 알림에서 주문 항목의 제품 범주 표시
주문의 이메일에 제품 카테고리를 표시하는 방법은 무엇입니까? $order
합니다 (WC_Order
객체의 인스턴스)으로
이 이메일 템플릿과 후크의 대부분에 포함되어, 당신은 순서에 포함 된 제품의 종류를 얻을 수 있습니다. 주문에는 많은 항목이 있고 각 항목에는 많은 범주가있을 수 있습니다. 다음 코드를 사용하여 해당 제품 범주를 가져옵니다.
$product_categories = array();
// Loop through order items
foreach($order->get_items() as $items){
// Get an array of the WP_Terms of the product categories
$terms = wp_get_post_terms($items->get_product_id(), 'product_cat');
// Loop through the product categories WP_Term objects
foreach($terms as $wp_term){
// Get the product category ID
$term_id = $wp_term->term_id;
// Get the product category Nmae
$term_name = $wp_term->name;
// Get the product category Slug
$term_slug = $wp_term->slug;
// Get the product category Parent ID
$term_parent_id = $wp_term->parent;
// Set each product category WP_Term object in an array (avoiding duplicates)
$product_categories[$wp_term->term_id] = $wp_term;
}
}
// Output the raw data of all product categories in the order (Testing)
var_dump($product_categories);
이 코드는 테스트되었으며 작동합니다.