Support » Plugin: Advanced Order Export For WooCommerce » Is it possible merge certain fields?

  • Resolved miikewordpress

    (@miikewordpress)


    Hello,

    This plugin is great!

    I have just one question about functionality.

    I use this plugin mainly to export the orders then manually adjust the excel format so I can upload it to the shipping courier’s system.

    It’s been working great but the manually adjusting excel file is pretty repetitive and I wonder if this can be done on the plugin.

    For example

    Address 1, Address 2, City are exported as separate columns.
    Is there any way to merge these columns to a single column as I export?

    What I do is I use the excel formula like Address1&” “&Address2&” “&City everyday.
    But it would be super convenient if this plugin has some way to do it as it exports.

    Thank you!

    Mike

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

    (@algolplus)

    hello Mike

    You can try this code

    // merge 3 fields to  Shipping Address 1
    add_filter('woe_get_order_value_shipping_address_1',function ($value, $order,$fieldname) {
    	return get_post_meta($order->id,'_shipping_address_1',true).' '.get_post_meta($order->id,'_shipping_address_2',true).' '.get_post_meta($order->id,'_shipping_address_3',true);
    },10,3);
    

    We plan to code field constructor in version 2.0 only.

    thanks, Alex

    Plugin Author algol.plus

    (@algolplus)

    ops, here is corrected version

    // merge 3 fields to  Shipping Address 1
    add_filter('woe_get_order_value_shipping_address_1',function ($value, $order,$fieldname) {
    	return get_post_meta($order->id,'_shipping_address_1',true).' '.get_post_meta($order->id,'_shipping_address_2',true).' '.get_post_meta($order->id,'_shipping_city',true);
    },10,3);

    Hello Alex!

    That worked perfectly thank you,

    but I forgot to mention that I need to merge State column as well
    so I added below code at the end

    .' '.get_post_meta($order->id,'_shipping_state',true);

    But it’s giving me state code instead of state name.

    Am I doing something wrong?

    Thank you very much,

    Mike

    Plugin Author algol.plus

    (@algolplus)

    // merge shipping fields to  Shipping Address 1
    add_filter('woe_get_order_value_shipping_address_1',function ($value, $order,$fieldname) {
    	
    	$state  = get_post_meta($order->id,'_shipping_state',true);
    	$country = get_post_meta($order->id,'_shipping_country',true);
    	$country_states = WC()->countries->get_states( $country );
    	if( isset( $country_states[$state]) ) // has full name ?
    		$state = html_entity_decode( $country_states[ $state ] ) ;
    		
    	$parts = array();
    	$parts[] = get_post_meta($order->id,'_shipping_address_1',true);
    	$parts[] = get_post_meta($order->id,'_shipping_address_2',true);
    	$parts[] = get_post_meta($order->id,'_shipping_city',true);
    	$parts[] = $state;
    	$parts = array_filter($parts);
    	
    	return join(" ", $parts);
    },10,3);
    

    Oh wow that worked perfectly!

    Thank you very much for your help!

    Plugin Author algol.plus

    (@algolplus)

    you’re welcome

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Is it possible merge certain fields?’ is closed to new replies.