This looks like it could work.
To get modify the value for Postcode (Shipping)
Shall I use: postcode_shipping ?
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 1 year, 4 months ago by
algol.plus.
Actually this one I wanted to format as text because for postcodes that start with a 0, excel removes the 0
CSV is plain format. it doesn’t support any formattting.
please, google “open csv with leading zeros”
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?
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/
Ok great, thank you for your help
You’re welcome.
if you can – please, add final code to this ticket.
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);