• Resolved lilingg

    (@lilingg)


    Hi there,

    As we would like to add the wholesale feature to our website. Is there any chance we can send the invoice to the wholesale users only by this plugin?

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

    (@alexmigf)

    Hi @lilingg

    Yes, it’s possible.

    First you need to attach the Invoice to an email under PDF Invoices > Documents > Invoice > Attach to, and finally you need to add the code snippet below:

    add_filter( 'wpo_wcpdf_custom_attachment_condition', function( $condition, $order, $email_id, $document_type ) {
    if ( ! empty( $order ) && 'invoice' === $document_type ) {
    $user = $order->get_user();
    $user_roles = (array) $user->roles;

    if ( ! in_array( 'wholesale', $user_roles ) ) { // 'wholesale' role slug
    $condition = false;
    }
    }

    return $condition;
    }, 10, 4 );

    If you never worked with code snippets, please read this documentation page: How to use code snippets

    I have considered the role slug as wholesale, but depending on the plugin it can be different, and you might need to update in the code.

    • This reply was modified 7 months, 3 weeks ago by alexmigf.
    Thread Starter lilingg

    (@lilingg)

    Thank you! That’s really helpful!

    Plugin Contributor alexmigf

    (@alexmigf)

    You’re welcome ??

    Have a nice day!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Only send invoice to specific users’ is closed to new replies.