• Resolved wph4x

    (@wph4x)


    H there.

    We have a problem with the packaging slips using the wrong format.
    The format the client is using is no spaces nor dashes.

    So instead of the number being displayed like:
    070 – 021 21 21
    It should be
    0700212121

    Do you guys have any scripts or code i could swap out to make this display correctly?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @wph4x,

    This is not something controlled by our plugin. I guess this phone formatting is something added by WooCommerce, another plugin, or a code snippet.

    However, you can try using this code to remove that formatting in the PDF documents:

    /**
     * WooCommerce PDF Invoices & Packing Slips:
     * Remove spaces and special characters (except +) from billing/shipping phone number in the PDF documents 
     * E.g. this number: +1-555-123-4567, will be converted to this: +15551234567
     */
    add_filter( 'wpo_wcpdf_billing_phone', 'wpo_format_phone_number_with_dashes', 10, 2 );
    add_filter( 'wpo_wcpdf_shipping_phone', 'wpo_format_phone_number_with_dashes', 10, 2 );
    function wpo_format_phone_number_with_dashes( $phone, $document ) {
    	$phone = preg_replace( '/[^+|^0-9]/', '', $phone );
    	return $phone;
    }

    If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters

    Thread Starter wph4x

    (@wph4x)

    That worked perfect. Thanks alot boss.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    I’m glad to hear that it worked!

    If you don’t mind and have the time, do you think you could leave us a review?

    Thanks in advance and all the best with your store!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Phone numer format’ is closed to new replies.