Home / Admin / Add a single Order export field with all Shipping address details
Duplicate Snippet

Embed Snippet on Your Site

Add a single Order export field with all Shipping address details

<10
Code Preview
php
<?php
function custom_woo_ce_extend_order_fields( $fields ) {
	$fields[] = array(
		'name' => 'shipping_address_full',
		'label' => 'Shipping: All details',
		'hover' => 'Custom Order field within functions.php'
	);
	return $fields;
}
add_filter( 'woo_ce_order_fields', 'custom_woo_ce_extend_order_fields' );
function custom_woo_ce_extend_order( $order, $order_id ) {
    $order->shipping_address_full = '';
	$order->shipping_address_full .= $order->shipping_address . "\n";
	if( !empty( $order->shipping_city ) )
		$order->shipping_address_full .= $order->shipping_city . "\n";
	if( !empty( $order->shipping_postcode ) )
		$order->shipping_address_full .= $order->shipping_postcode . "\n";
	if( !empty( $order->shipping_state ) )
		$order->shipping_address_full .= $order->shipping_state . "\n";
	if( !empty( $order->shipping_country ) )
		$order->shipping_address_full .= $order->shipping_country;
    return $order;
}
add_filter( 'woo_ce_order', 'custom_woo_ce_extend_order', 10, 2 );

Comments

Add a Comment