Rajat Pillai
Rajat Pillai

Reputation: 13

How to add custom total of an individual product on order backend page

Basically, on the order edit page, I want to calculate the total of an individual product as price * product_height * quantity_of_products.

reference image

I have used the following hook but this hook is not getting executed.

add_filter( 'woocommerce_data_get_total', 'change_product_total_on_order_edit_page', 10, 2);
function change_product_total_on_order_edit_page ($value, $abc ) {
   var_dump($value);
   die();
   return 15;
}

Upvotes: 1

Views: 82

Answers (1)

Narayan Choudhary
Narayan Choudhary

Reputation: 100

Use 'woocommerce_order_item_get_total' filter instead of 'woocommerce_data_get_total' because this filter is created dynamically by Woocommerce. The data in the hook is object type. When order items are fetched on orders edit page the object type is order_item.

Upvotes: 1

Related Questions