• Resolved aumjosh

    (@aumjosh)


    I would like to format a custom field in a certain way, but was unable to find a proper filter for doing this.

    Also, for the ‘format excel column as number’ code snippet.. how can I adjust this code for a specific column?
    It says: $row = $formatter->last_row;
    how do I replace last_row with a custom field?

    Any help is appreciated.

    -Josh

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

    (@algolplus)

    hi Josh

    could you use this way to modify value ?
    https://docs.algolplus.com/algol_order_export/hooks-filters/

    Thread Starter aumjosh

    (@aumjosh)

    This looks like it could work.
    To get modify the value for Postcode (Shipping)
    Shall I use: postcode_shipping ?

    Plugin Author algol.plus

    (@algolplus)

    The hook name is a bit different.
    Do you want to add leading zeros ?

    Try this code

    add_filter('woe_get_order_value_shipping_postcode',function( $value,$order, $fieldname ) {
      return str_pad($value, 5, '0', STR_PAD_LEFT); 
    }, 10, 3 );
    
    • This reply was modified 2 years, 7 months ago by algol.plus.
    Thread Starter aumjosh

    (@aumjosh)

    Actually this one I wanted to format as text because for postcodes that start with a 0, excel removes the 0

    Plugin Author algol.plus

    (@algolplus)

    CSV is plain format. it doesn’t support any formattting.
    please, google “open csv with leading zeros”

    Thread Starter aumjosh

    (@aumjosh)

    Thanks for reminding me. That’s fine, then I don’t need to format this at all.

    But what I still need to do is format a custom field (_wcpdf_invoice_number).
    I need the output to adhere to this regex:

    <?php
    $string = _wcpdf_invoice_number;
    preg_replace('/(\w+)(\s\-\s)(\d+)/', '$3', $string);
    ?>

    Can you help me apply this to the correct filter?

    Plugin Author algol.plus

    (@algolplus)

    hi Josh

    You should add field “_wcpdf_invoice_number” using Setup Fields
    and use hook “woe_get_order_value__wcpdf_invoice_number”

    More details https://docs.algolplus.com/algol_order_export/fields/

    Thread Starter aumjosh

    (@aumjosh)

    Ok great, thank you for your help

    Plugin Author algol.plus

    (@algolplus)

    You’re welcome.
    if you can – please, add final code to this ticket.

    Thread Starter aumjosh

    (@aumjosh)

    Sure thing.. this worked great, much appreciated:

    <?php 
    add_filter('woe_get_order_value__wcpdf_invoice_number',function ($value, $order,$fieldname) {
    	return preg_replace('/(\w+)(\s\-\s)(\d+)/', '$3', $value);
    },10,3);
    Plugin Author algol.plus

    (@algolplus)

    Thank you very much.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Filter to format custom field column in CSV output’ is closed to new replies.