• Resolved cubes91

    (@cubes91)


    Hello!

    First of all.. Great plugin! it works great with my own styling.
    But i have a minor question.. Is it possible to only attach the PDF when the customer is a ‘business’?

    For example i want to attach the PDF only in the order completed mail when the customer fills in a company name.

    Thanks in advance

    • This topic was modified 5 months ago by cubes91.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @cubes91,

    Although it is possible, you would need to check whether the customer has filled the company name or not. This can be done through a code snippet, like the following I just wrote for you:

    /**
    * PDF Invoices & Packing Slips for WooCommerce:
    * Disable Invoice creation if customer doesn't provide the company name
    */
    add_filter( 'wpo_wcpdf_document_is_allowed', function( $allowed, $document ) {
    if ( 'invoice' === $document->type && ( $order = $document->order ) && ! $document->exists() ) {
    $allowed = empty( $order->get_billing_company() ) ? false : true;
    }
    return $allowed;
    }, 10, 2 );

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

    Please note that you also need to choose in which email notification you want to attach the PDF invoice (when the company name is filled). You can set this in WooCommerce?> PDF Invoices?> Documents?> Invoice?> Attach?to.

    Thread Starter cubes91

    (@cubes91)

    Hi Yordan,

    Thanks for your quick reply! im going to try your snippet.

    Thanks!

    Thread Starter cubes91

    (@cubes91)

    Hi Yordan,

    Confirmed it works! Thanks man

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Thanks for confirming, @cubes91: I’m glad to hear that! ??

    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 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.