Hook after payment confirmed but before email sent

This topic contains 9 replies, has 3 voices, and was last updated by  Patrik 5 years, 8 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: , ,

  • Author
    Posts
  • #1873

    Alex Howes
    Buyer
    Post count: 175

    Hello,

    Is there a filter or action I can hook to that’s called after the client’s payment is confirmed but before the client email is sent? I want to dynamically edit the details of the invoice and also dynamically edit the email.

    Thanks,
    Alex

    #1875

    Guust
    Moderator
    Post count: 29970

    I’ll get the developer to have a look after the weekend. Thanks

    #1876

    Alex Howes
    Buyer
    Post count: 175

    Thanks, that’d be good 🙂

    Let me explain a bit more clearly. What I need is:

    1) I have a [wpinv-buy] shortcode on some of my posts. Is there an action or filter I can hook to that’s called after the “Buy” button is pressed but before the wpi-checkout page appears? (I’d like to edit the invoice items dynamically to include the post id of the post the shortcode is on).

    2) An action or filter to hook to after payment is confirmed but before the client email is sent (so that I can dynamically edit the client email depending on the invoice item).

    Looking forwards to hearing from you after the weekend 🙂

    Alex

    #1880

    Patrik
    Moderator
    Post count: 1971

    Hi Alex,

    This all requires customization. There is no direct hook available which executes after clicking on buy button but the invoice is created after buy button pressed so you can use the hook from wpinv_insert_invoice() function which is ‘wpinv_insert_invoice’.

    To edit the content of the email you can use the ‘wpinv_email_content’ filter but you need to use it carefully as it will be called for all the emails sent.

    Regards,
    Patrik

    #1884

    Alex Howes
    Buyer
    Post count: 175

    Hi Patrik,

    Thanks for your information. I’m happy with doing the customization myself, it’s just helpful to have a pointer as to the appropriate hooks I can use- it’s hard to know without being familiar with the code so I appreciate your help 🙂

    I see the hook from the wpinv_insert_invoice() function is an action. Is there a filter I can hook to instead? I want to change the details of the invoice items. Do you know what I could use for that?

    It looks like wpinv_email_content is what I need for the email part. It looks like I can put a condition on the email type to prevent my code applying to all emails sent.

    Thanks,
    Alex

    #1885

    Patrik
    Moderator
    Post count: 1971

    Hi Alex,

    You can use ‘wpinv_add_item_args’ filter to change the item data. It will be hard to modify invoice and invoice item data at runtime. But let me know if you need any help!

    Regards,
    Patrik

    #1933

    Alex Howes
    Buyer
    Post count: 175

    Hi Patrik,

    I’m having difficulty changing the item details for items processed through the wpinv buy shortcode. I’ve tried hooking onto wpinv_setup_invoice but when I set the item details there they don’t change anywhere else. E.g. the item name shown on the checkout page is unchanged. My code is below.

    
    
    add_action('wpinv_setup_invoice','add_fields_to_invoice_setup',10,2);
    
    function add_fields_to_invoice_setup($this_invoice, $invoice_id) {
        $this_invoice->payment_meta['cart_details'][0]['name'] = 'Testing';
    }

    Is there a function called after setup_invoice that’s overwriting it?

    Thanks,
    Alex

    #1942

    Patrik
    Moderator
    Post count: 1971

    Hi Alex,

    That is the hook actually and you can’t modify the variable from hook. For that, you need a filter. You may try filter instead of the action. Try changing add_action() to add_filter() and let me know if it works or not. You may need to make a change in core and add filter if it doesn’t work.

    Regards,
    Patrik

    #1952

    Alex Howes
    Buyer
    Post count: 175

    Hi Patrik,

    I tried changing add_action() to add_filter() and also added a filter to hook to in the code but it didn’t work. The details changed within the function but on the wpi-checkout page they are unchanged. Perhaps it is being overwritten later on, or the wpi-checkout page is retrieving the item details from somewhere else?

    Alex

    #1960

    Patrik
    Moderator
    Post count: 1971

    Hi Alex,

    Can you please let us know which details you are changing for invoice and also tell us your exact requirements so that we can tell you the solution if possible else you can get the help of the Developer for customisation. It may be possible you have to change the code to fulfill your requirements as we have the plugin general for all but we have given all possible hooks from our side. If you think there is need of hook in future releases then just let us know and we will look into it.

    Regards,
    Patrik

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

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket