“total billings column” — do you calculate the value the order ?
Could you explain the formula?
Sorry it’s actually “net billings” but it should basically be the quantity of the item * the item_price – any amount refunded.
So:
(qty * item_price) - order_refund
To give a net total that was billed. I can’t get it to show this net total for each row and item id though.
hello
please, open >Setup fields>Product Items and try field “Order Line Total (- Refund)”.
thanks, Alex
Gah! That does it! I was told it didn’t exist so had to add it manually. Sorry!
Thank you so much for the awesome help and response! You’re amazing!
-
This reply was modified 6 years, 4 months ago by
jlv4567.
if you still need custom field
please follow to https://algolplus.freshdesk.com/support/solutions/articles/25000018287-add-calculated-field-for-product-
and use code
return $item->get_subtotal() - $order->get_qty_refunded_for_item( $item->get_id());
Follow up question. How can I take the net_billings we just created and multiply it by a static field?
I have a static field that’s a commission percentage that I’d like to multiply the net billings with. I can see that the static field is called “static_field_2”, but searching the forums didn’t reveal a way to access it.
Here’s what I got with a hard coded .6, but I’d like to just grab that value from the static field.
add_filter('woe_get_order_product_value_commission_amount', function ($value, $order, $item, $product, $item_meta) {
return ($item->get_subtotal() - $order->get_qty_refunded_for_item( $item->get_id())) * .6;
}, 10, 5);
-
This reply was modified 6 years, 4 months ago by
jlv4567.
-
This reply was modified 6 years, 4 months ago by
jlv4567.
-
This reply was modified 6 years, 4 months ago by
jlv4567.
hello
yes, as nobody asked for these values.
please, add this code at top of your function and press Preview – you will see fields.
var_dump(WC_Order_Export_Engine::$current_job_settings['order_fields']); die();
and use this field as multiplier ( replace “0” with correct index!) .
WC_Order_Export_Engine::$current_job_settings['order_fields'][0]['value']
Hi, this little bit of code you gave above to use “Order Line Total (- Refund)” actually doesn’t seem to be getting the correct amount. I’ve got a line that has a item price of 500 and a refund of 505 and the “net billings” column we created shows as 500, but it should be -5. So it isn’t getting the right calculation.
I tried to look in to it and this bit seems to always return 0 even if there is a refunded amount:
$order->get_qty_refunded_for_item( $item->get_id())
I tried switching to using get_qty_refunded_for_item but it still gets the 0.
I think the problem may be that we are using the ‘Order Refund Amount’ under totals, and not the ‘Order Line Total Refunded’ under Products.
The code for finding the static value works great though! Thank you for that!
-
This reply was modified 6 years, 4 months ago by
jlv4567.
-
This reply was modified 6 years, 4 months ago by
jlv4567.
I think the problem may be that we are using the ‘Order Refund Amount’ under totals, and not the ‘Order Line Total Refunded’ under Products.
yes, it’s a reason.
you can try $order->get_total_refunded(), but it has no sense if you have 2+ products in the order.