• Hello,

    Is there a way to add shipping cost as a new row for each order?( same way multiple items are added). At the moments that’s a column.

    Thank you

    • This topic was modified 1 year, 5 months ago by dmc2031.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author algol.plus

    (@algolplus)

    Hello
    1. please, visit https://docs.algolplus.com/algol_order_export/add-product-rows/
    2. copy 2nd code
    3. go back to export
    4. add code to section “Misc settings”

    thanks, Alex

    Thread Starter dmc2031

    (@dmc2031)

    Hi Alex,

    Thank you very much. It worked really well. One more question. Is there a way to skip row creation if shipping cost is 0?

    Thank you,

    Cosmin

    Plugin Author algol.plus

    (@algolplus)

    below line
    foreach ( $order->get_items(‘shipping’) as $item_id=>$item ) {

    add line
    if($item["cost"] == 0 ) continue;

    Thread Starter dmc2031

    (@dmc2031)

    Thank you again @algolplus. Everything is working really nice.

    One last question. Can we do the same thing for coupons?( adding them as a row, not a colum)

    We tried to use Set up fields to export?->Add coupons as rows but this did nothing.

    Thank you,

    Cosmin

    Plugin Author algol.plus

    (@algolplus)

    please, add this code to Misc Settings
    ?
    //export coupons as Products
    add_filter('woe_fetch_order_products', function ($products,$order,$labels, $format, $static_vals) {
    $i = count ($products);
    foreach ( $order->get_items('coupon') as $item_id=>$item ) {
    $row = array();
    $i++;
    foreach ( $labels as $field => $label ) {
    if ( $field == 'line_id' ) $row[ $field ] = $i;
    elseif ( $field == 'sku' ) $row[ $field ] = $item->get_code();
    elseif ( $field == 'name' ) $row['name'] = $item->get_name();
    elseif ( $field == 'qty' ) $row['qty'] = 1;
    elseif ( $field == 'line_subtotal' ) $row['line_subtotal'] = -$item->get_discount();
    elseif ( $field == 'line_subtotal_tax' ) $row['line_subtotal_tax'] = -$item->get_discount_tax();
    elseif ( $field == 'price' ) $row['item_price'] = -$item->get_discount();
    elseif ( isset( $static_vals[ $field ] ) ) $row[ $field ] = $static_vals[ $field ];
    }
    $products[] = $row;
    }
    return $products;
    }, 10, 5);
    Thread Starter dmc2031

    (@dmc2031)

    Hello,

    Thank you again for your fast reply. I just got the chance to test it and everything looks good. One thing that we would like to modify if possible, would be to populate the discount amount value under the item cost column, at the moment this is empty for coupons.

    Thank you,

    Cosmin

    Plugin Author algol.plus

    (@algolplus)

    just replace line

    elseif ( $field == 'line_subtotal' ) $row['line_subtotal'] = -$item->get_discount();

    with

    elseif ( $field == 'price' ) $row['price'] = -$item->get_discount();
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Adding shipping cost as a row’ is closed to new replies.