• Resolved gamerwp

    (@gamerwp)


    Hello.

    For accounting purposes, i need the sale price of each sold product, before discounts. I tried with the field “Item Cost” but is showing the cost/price with discounts applied. Is there any field working in this way?

    Thank you in advance.

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author algol.plus

    (@algolplus)

    Hello

    Could you try field “Order Line Subtotal” ?
    section >Setup Fields>Product Items

    thanks, Alex

    Thread Starter gamerwp

    (@gamerwp)

    Hello.

    Unfortunately, this is for total items and we need the cost of “each item”, before discounts. Any workaround?

    Thanks again.

    Plugin Author algol.plus

    (@algolplus)

    Hello

    you can add this code to “Misc Settings” to divide subtotal amount.
    thanks, Alex

    add_filter('woe_get_order_product_value_line_subtotal', function ($value, $order, $item, $product,$Item_meta) {
    	return $value/$item['qty'];
    }, 10, 5);
    Thread Starter gamerwp

    (@gamerwp)

    Great, it worked like a charm!

    But how can i add a “new field” with this function? Not replacing “Order Line Subtotal”.

    Thank you again.

    • This reply was modified 4 years, 10 months ago by gamerwp.
    • This reply was modified 4 years, 10 months ago by gamerwp.
    Plugin Author algol.plus

    (@algolplus)

    please, follow to https://algolplus.freshdesk.com/support/solutions/articles/25000018287-add-calculated-field-for-product-

    use meta key “item_cost_raw” and this PHP code
    thanks, Alex

    add_filter('woe_get_order_product_value_item_cost_raw', function ($value, $order, $item, $product,$item_meta) {
       return $item->get_subtotal()/$item['qty'];
    }, 10, 5);
    Thread Starter gamerwp

    (@gamerwp)

    It worked like a charm! Thanks mate.
    One extra thing: how can i get the “Order Total Amount” but without fees? Only with discounts applied.

    Thanks again.

    Plugin Author algol.plus

    (@algolplus)

    please, follow to https://algolplus.freshdesk.com/support/solutions/articles/25000016635-add-calculated-field-for-order-

    use meta key “total_no_fee” and this code

    add_filter('woe_get_order_value_total_no_fee',function ($value, $order,$fieldname) {
    $fee_total  = 0;
    foreach( $order->get_items('fee') as $item_id => $item_fee ){
        $fee_total += $item_fee->get_total();
    }
    return $order->get_total() - $fee_total ;
    },10,3);

    Warning: amount includes shipping cost.

    • This reply was modified 4 years, 10 months ago by algol.plus.
    Thread Starter gamerwp

    (@gamerwp)

    Thanks, your solution worked great. I have another question: how can we round Order Total Fee value? Is there any option to round values before export?
    Thanks again!

    Plugin Author algol.plus

    (@algolplus)

    hello

    please, open section “Misc Settings” and mark “Format numbers”
    thanks, Alex

    Thread Starter gamerwp

    (@gamerwp)

    Hello mate.

    Unfortunately, it didn’t work; we got ,00 at the end of all values.
    We already fixed total_no_fee in this way:

    add_filter('woe_get_order_value_total_no_fee',function ($value, $order,$fieldname) {
    $fee_total  = 0;
    foreach( $order->get_items('fee') as $item_id => $item_fee ){
        $fee_total += $item_fee->get_total();
    }
      return $order->get_total() - round($fee_total, 0) ;
    },10,3);

    How can we do the same but with order_total_fee?

    Thank you in advance.
    Regards.

    Thread Starter gamerwp

    (@gamerwp)

    I’m not sure if you are getting notifications of this topic because it’s resolved @algolplus
    Please, check the message above. Thanks.

    Plugin Author algol.plus

    (@algolplus)

    Some details about hooks
    https://algolplus.com/plugins/documentation-order-export-woocommerce/

    + a lot of examples https://algolplus.com/plugins/code-samples/

    please, try this code

    add_filter('woe_get_order_value_order_total_fee',function( $value,$order, $fieldname ) {
      return round($value); 
    }, 10, 3 );
Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Item Cost – issue’ is closed to new replies.