Jump to content

disable redirect to created invoice when convert quote to invoice


Recommended Posts

The redirect can't be disabled but you can get the job done using an action hook that brings you back to the original document like follows.


function somePrefix_InvoiceCreation($vars)
    $quoteID = Capsule::table('tblinvoices')->where('id', $vars['invoiceid'])->where('notes', 'like', 'Re Quote #%')->first(['notes']);
    header('Location: quotes.php?action=manage&id=' . explode('#', $quoteID->notes)[1]);

add_hook('InvoiceCreation', 1, 'somePrefix_InvoiceCreation');

You have to place this code in a new file under includes/hooks folder. You can name the file as you prefer. Lastly you should replace the two somePrefix_ in the code with something else to avoid function name collission (e.g. use your brand name).

The code is pretty simple. InvoiceCreation hook point triggers the code every time you create an invoice from admin area. The code runs a query in database to detect if the current invoice "comes" from a quote (all quotes have "Re Quote #{QUOTE-ID}" string in name tblinvoices.notes column). If this string "Re Quote #" is found I extract the ID of the original quote exploding tblinvoices.notes by # and getting the second match (the part in red "Re Quote #{QUOTE-ID}"). Long story short now that we know that the invoice in question "comes" from a quote we can redirect you back to quote since we also know the ID. From now on when you press Convert to Invoice you'll stay on quote page.

Edited by Kian
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated