• Resolved laangen

    (@laangen)


    Hello.

    Is it possible to export the discount voucher value in a seperate line ?
    Exemple
    Productprice is 10€
    Customer has voucher with 3€

    The export file must have one ligne with the product 10€ and a second ligne with -3€.
    Thanks

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

    (@algolplus)

    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

    Thread Starter laangen

    (@laangen)

    Thanks, I tried it but isn’t function. The shipping is ok but no coupons
    Thanks

    Plugin Author algol.plus

    (@algolplus)

    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);
    Thread Starter laangen

    (@laangen)

    Perfect, many thanks !!
    Just see now, can I make the price from the voucher negativ?

    • This reply was modified 5 years, 1 month ago by laangen.
    Plugin Author algol.plus

    (@algolplus)

    you’re welcome

    Thread Starter laangen

    (@laangen)

    Sorry

    Just see now, can I make the price from the voucher negativ?
    Regards

    Plugin Author algol.plus

    (@algolplus)

    just replace
    $item->get_discount()
    with
    - $item->get_discount()

    Please delete my Account here.

    Thank you

    Plugin Author algol.plus

    (@algolplus)

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Order export’ is closed to new replies.