Код: Выделить всё
$order = new WC_Order( $order_id );
$items = $order->get_items();
foreach ( $items as $item ) {
$product_catagory_id .= $item['catagory_id']; //in between these brackets I need a value that gives me the catagory id.
}
//Some validation here if one of the catagorie_id's was found.
//I can build this. It's not part of the question
Код: Выделить всё
$order = new WC_Order( $order_id );
$items = $order->get_items();
foreach ( $items as $item ) {
$product_id = $item['product_id'];
var_dump($product_id);
$terms = get_the_term_list( $product_id, 'term_id' );
var_dump($terms);
}
Код: Выделить всё
string(2) "79"
object(WP_Error)#9148 (2) {
["errors"]=>
array(1) {
["invalid_taxonomy"]=>
array(1) {
[0]=>
string(19) "Ongeldige taxonomie" //invalid taxonomy
}
}
["error_data"]=>
array(0) {
}
}
Подробнее здесь: https://stackoverflow.com/questions/366 ... oocommerce