• Resolved thnor

    (@tonyhnor)


    Hi,

    We want to export orders based on products. It is all good, except that we struggle to find out how to add shipping cost to the same report.

    Have tried to add a calculated field with Custom PHP code to modify output, without getting any output.

    The report is per row; SKU/Product, quantity, amount (w and w/o tax+discount) and the last column should be total shipping cost per product.

    Called it my_custom_field and the php code tried is:

    add_filter('woe_get_order_value_my_custom_field',function ($value,$order,$fieldname) {
    if ( $order->has_shipping_method( 'pakkepost' ) ) {
    foreach ( $order->get_shipping_methods() as $shipping_item_id => $shipping_item ) {
    $point = wc_get_order_item_meta( $shipping_item_id, 'my_custom_field', true );
    if ( ! empty( $point ) ) {
    $value = $point;
    }
    }
    }
    return $value;
    },10,3);

    Also, there is two different shipping methods that we use.

    How to we get the output that we need?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter thnor

    (@tonyhnor)

    Hi again, understand now that this column will do no good.

    Is it possible to add the shipping cost as one row, after the product list? And then have the different shipping methods in each row.

    Plugin Author algol.plus

    (@algolplus)

    hi

    Could you share your settings ? use tab “Tools” to get them.

    you can submit these settings as new ticket to https://algolplus.freshdesk.com/ too

    Thread Starter thnor

    (@tonyhnor)

    Hi, thank you for your reply. I have added a new ticket to your support, so we can take it further from there.

    Plugin Author algol.plus

    (@algolplus)

    Following code was provided as draft solution , it should be tweaked to fill other columns , not only amount

    add_action( "woe_summary_products_added_order", function ($order ){
    $key = "____".$order->get_shipping_method();
    //add new row ?
    if( !isset($_SESSION['woe_summary_products'][$key]) ){
    $first_row = reset($_SESSION['woe_summary_products']);
    $_SESSION['woe_summary_products'][$key] = array_fill_keys( array_keys($first_row),"");
    $_SESSION['woe_summary_products'][$key]['product_name'] = $order->get_shipping_method();
    $_SESSION['woe_summary_products'][$key]['summary_report_total_amount'] = 0;
    }
    $_SESSION['woe_summary_products'][$key]['summary_report_total_amount'] += $order->get_shipping_total();
    });

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add shipping amount to summary report’ is closed to new replies.