Customer Invoice Email not sending

This topic contains 8 replies, has 5 voices, and was last updated by  Alison Teitel 1 year ago.

Tagged: 

  • Author
    Posts
  • #3741

    Alison Teitel
    Free User
    Post count: 5

    I have the checkbox checked to send the customer invoice email out to let them know that they need to pay it (screenshot attached).

    I also checked my SendGrid account and installed and activated this plugin: https://wordpress.org/plugins/wp-mail-logging/

    The email does not go out nor does any record of it get logged in either place.

    I am creating my invoices with wpinv_insert_invoice() and all other emails I send with wp_mail go out just fine.

    When I add the field user_note, I do get the “Customer Note” email so I know the email sending mechanism works. It just isn’t sending the customer invoice.

    Please let me know what other debugging I can do. Thanks.

    #3743

    Guust
    Moderator
    Post count: 29970

    Please post your URL and WP admin details in a private reply and we will check your settings if you like.
    Thanks

    #3745

    Alison Teitel
    Free User
    Post count: 5

    Just tell me where to look in the UI. I can’t give out access. I will be happy to screenshot whatever you need to see or check settings and report them here.

    #3746

    Paolo
    Site Admin
    Post count: 31205

    We can’t debug a site via screenshots. Please provide credentials in a private reply, or alternative you could setup a staging server for us to do our job.

    Thanks

    #3747

    Alison Teitel
    Free User
    Post count: 5

    There is proprietary code and personal information that I can’t give access out to a third party without us drawing up an NDA of some kind and I’m not even sure that is an option.

    I included the screenshot of those settings and I can provide you screenshots to whatever else you need to see in the back end.

    I’m sure you can accommodate us this way. It might take a little longer, but it might be the only option.

    You should be able to supply a short list of debugging steps or things to check out. I’ll check them and get back to you.

    Thanks again.

    #3748

    Alex Rollin
    Moderator
    Post count: 27815

    If you visit the invoice in the backend and click the button to “Resend Invoice”

    1) Is that how you want to trigger sending the invoice email?
    2) Does that work?

    #3749

    Alison Teitel
    Free User
    Post count: 5

    The “Resend Invoice” button sent out the invoice, but I need it to send after a successful call to wpinv_insert_invoice().

    The invoices are created just fine and appear in the user’s dashboard, but no email gets sent even though that checkbox is checked. As I said before, when the below call includes the “user_note”, a user note email gets sent out.

    I’ll include my call here.

    All these variables are present and accurate. I populate a lot of these fields with ACF.

    $data = array(
                'status'            => 'wpi-pending',
                'user_id'           => $practice_userid,
                'cart_details'      => $invoice_items,
                'user_info'         => array(
                    'first_name'        => get_field("practice_owner_first_name", $practice_id),
                    'last_name'         => get_field("practice_owner_last_name", $practice_id),
                    'phone'             => get_field("practice_owner_phone", $practice_id),
                    'address'           => get_field("practice_billing_address_1", $practice_id) . ' ' . get_field("practice_billing_address_2", $practice_id),
                    'city'              => get_field("practice_billing_city", $practice_id),
                    'country'           => 'US',
                    'state'             => get_field("practice_billing_state", $practice_id),
                    'zip'               => get_field("practice_billing_postal_code", $practice_id),
                    'company'           => get_the_title($practice_id),
                    'vat_number'        => '',
                    'discount'          => ''
                ),
                'due_date'          => '2019-11-20',
                'private_note'      => 'assignment_id=' . $assignment_id,
            );
    		
            $invoice = wpinv_insert_invoice( $data, true );
    #3750

    Patrik
    Moderator
    Post count: 1971

    Hi,

    The function wpinv_insert_invoice() will not send an invoice as we are using that function to create an invoice from add ons and GD. You have to do minor customization to send an invoice in the email using a hook “wpinv_insert_invoice” from this function. Add note function sends a note to the customer so it will trigger email. Try the following code and let us know if it helps:

    add_action('wpinv_insert_invoice', 'wpinv_insert_invoice_cb', 10, 2);
    function wpinv_insert_invoice_cb($invoice_id, $invoice_data){
    	if ( ! empty( $invoice_id ) ) {
    		wpinv_user_invoice_notification( $invoice_id );
    	}
    }

    Regards,
    Patrik

    #3761

    Alison Teitel
    Free User
    Post count: 5

    That worked very nicely. I didn’t need to use the callback, although I might use it later. Upon the creation of my invoice I used your wpinv_user_invoice_notification() function.

    Passing it the newly created invoice ID was all I needed to do after a successful creation.

    Maybe include that in your list of developer functions as you continue to publish your documentation.

    Thanks again for your help!

Viewing 9 posts - 1 through 9 (of 9 total)

The topic ‘Customer Invoice Email not sending’ is closed to new replies, this may be for inactivity, please open a new topic if you have a similar question.