Hello
please, visit section https://algolplus.com/plugins/code-samples/#add_product_rows and review 2nd example.
you must adapt it , use $order->get_items(‘coupon’) to add coupons
Thanks, I tried it but isn’t function. The shipping is ok but no coupons
Thanks
Could you try this version ?
//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 == 'item_price' ) {
$row['item_price'] = $item->get_discount();
} elseif ( $field == 'line_tax' ) {
$row['line_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);
Perfect, many thanks !!
Just see now, can I make the price from the voucher negativ?
-
This reply was modified 6 years, 4 months ago by
laangen.
Sorry
Just see now, can I make the price from the voucher negativ?
Regards
just replace
$item->get_discount()
with
- $item->get_discount()
Please delete my Account here.
Thank you