JChario
JChario

Reputation: 61

After Order Details Hook[Woocommerce]

https://postimg.org/image/xgyc0hgxz/

Ok so i want to create an extra field(Column) where the picture has the black square but first of all i don't know what the hook is . After searching i found the hook

woocommerce_admin_order_data_after_order_details

but this hook is above what i want as showed here.. Add order metadata to WooCommerce admin order overview

Also what i want is to show shipping Class for each object which i suppose i could access through global $product if i could access the loop there but i just don't know the hook or how am i suppose to add this column. Any ideas?

Upvotes: 1

Views: 5518

Answers (1)

JChario
JChario

Reputation: 61

Ok I found a solution and i post it here for anyone else searching for this.

add_action('woocommerce_before_order_itemmeta','woocommerce_before_order_itemmeta',10,3);
function woocommerce_before_order_itemmeta($item_id, $item, $product){
    $shippingclass = $product->get_shipping_class();

    echo ($shippingclass) ? __('<hr><b>Shipping with: </b> <i style = "text-transform:uppercase">'. $shippingclass .'</i><hr>','woocommerce') : 'No Shipping Class is assigned to this product';
    echo '<p><b>Category:</b>  <i>'.get_the_term_list($product->id, 'product_cat').'</i></p>';
}

Upvotes: 4

Related Questions