Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter arneolaf

    (@arneolaf)

    Hi Alex.
    Thanks. Ticket #48180.

    Kind Regards
    Arne-Olaf

    Thread Starter arneolaf

    (@arneolaf)

    Perfect! Thanks again. This is for exporting orders to Tripletex.

    Kind Regards
    Arne-Olaf

    Thread Starter arneolaf

    (@arneolaf)

    Thanks! I made a grey field. Now I’m missing the same for the shipping line and coupon line.
    “nullstress” = coupon
    “Frakt” = shipping

    ORDER NO	ORDER DATE	CUSTOMER NO	DELIVERY DATE	ORDER LINE	UNIT PRICE				
    288		2020-11-07	vipps		2020-11-07	20001		204				
    289		2020-11-07	vipps		2020-11-07	20001		204				
    269		2020-11-07	vipps		2020-11-07	62016		360				
    270		2020-11-09	vippswoo	2020-11-09	31006		560				
    270								31022		560				
    270								12008		1440				
    270								310016		560				
    270								31002		560				
    270								31009		560				
    								nullstress	-636				
    								Frakt		40				
    272		2020-11-12	izettle		2020-11-12	95049		120				
    271		2020-11-13	vippswoo	2020-11-13	72011		200				

    I have used this code in functions.php for coupons:

    //eksporter Coupon line 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++;
    		//$taxes = $item->get_total_tax();
    		$coupon = new WC_Coupon($item->get_code());
    		foreach ( $labels as $field => $label ) {
    			if ( $field == 'line_id' ) {
    				$row[ $field ] = $i;
    			} elseif ( $field == 'sku' ) {
    				$row[ $field ] = $item["code"];
    			} elseif ( $field == 'name' ) {
    				$row['name'] = $item["name"];
    			} elseif ( $field == 'qty' ) {
    				$row['qty'] = 1;
    			} elseif ( $field == 'item_price_before_discount' ) {
    				$row['item_price_before_discount'] = - $item["discount_amount"];
    			} elseif ( $field == 'price' ) {
    				$row['price'] = - $item["discount_amount"];
    			} elseif ( $field == 'line_tax' ) {
    				$row['line_tax'] = $taxes;
    			} elseif ( $field == 'tax_rate' ) {
    				$row['tax_rate'] = $item["cost"] ? round($coupon/$item["cost"] *100 , 2) : 0;
    			} elseif ( isset( $static_vals[ $field ] ) ) {
    				$row[ $field ] = $static_vals[ $field ];
    			} 
    		}
    		$products[] = $row;
    	}
    	return $products;
    }, 10, 5);

    And this for shipping:

    //eksporter Frakt as Products 
    add_filter('woe_fetch_order_products', function ($products,$order,$labels, $format, $static_vals) {
    	$i = count ($products);
    	foreach ( $order->get_items('shipping') as $item_id=>$item ) {
    		$row = array();
    		$i++;
    		$taxes = $item->get_total_tax();
    		foreach ( $labels as $field => $label ) {
    			if ( $field == 'line_id' ) {
    				$row[ $field ] = $i;
    			} elseif ( $field == 'sku' ) {
    				$row[ $field ] = $item["method_title"];
    			} elseif ( $field == 'name' ) {
    				$row['name'] = $item["name"];
    			} elseif ( $field == 'qty' ) {
    				$row['qty'] = 1;
    			} elseif ( $field == 'item_price_before_discount' ) {
    				$row['item_price_before_discount'] = $item["cost"];
    			} elseif ( $field == 'price' ) {
    				$row['price'] = $item["cost"];
    			} elseif ( $field == 'line_tax' ) {
    				$row['line_tax'] = $taxes;
    			} elseif ( $field == 'tax_rate' ) {
    				$row['tax_rate'] = $item["cost"] ? round($taxes/$item["cost"] *100 , 2) : 0;
    			} elseif ( isset( $static_vals[ $field ] ) ) {
    				$row[ $field ] = $static_vals[ $field ];
    			} 
    		}
    		$products[] = $row;
    	}
    	return $products;
    }, 10, 5);
    Thread Starter arneolaf

    (@arneolaf)

    Thanks again. Unfortunately no luck with that. I get the same result as in code box #2. The order number doesn’t show for each order line. Only the first one.

    Thread Starter arneolaf

    (@arneolaf)

    Thanks for your reply. The result with this option is like this:

    288	2020-11-07	10001	2020-11-07	20001	204	1	3		
    289	2020-11-07	10001	2020-11-07	20001	204	1	3		
    270	2020-11-09	10001	2020-11-09	31006	560	1	3		
    				                31022	560	1	3		
    				                12008	1440	1	3		
    				                310016	560	1	3		
    				                31002	560	1	3		
    				                31009	560	1	3		
    272	2020-11-12	10007	2020-11-12	95049	120	1	3		
    271	2020-11-13	10001	2020-11-13	72011	200	1	3
    Thread Starter arneolaf

    (@arneolaf)

    288	2020-11-07	10001	2020-11-07	20001	204	1	3	
    289	2020-11-07	10001	2020-11-07	20001	204	1	3
    270	2020-11-09	10001	2020-11-09	31006	560	1	3	
    270				                31022	560	1	3	
    270				                12008	1440	1	3	
    270				                310016	560	1	3	
    270				                31002	560	1	3	
    270				                31009	560	1	3	
    272	2020-11-12	10007	2020-11-12	95049	120	1	3	
    271	2020-11-13	10001	2020-11-13	72011	200	1	3
Viewing 6 replies - 1 through 6 (of 6 total)