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
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
below line
foreach ( $order->get_items(‘shipping’) as $item_id=>$item ) {
add line
if($item["cost"] == 0 ) continue;
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
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);
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
just replace line
elseif ( $field == 'line_subtotal' ) $row['line_subtotal'] = -$item->get_discount();
with
elseif ( $field == 'price' ) $row['price'] = -$item->get_discount();