Jump to content

AfterShoppingCartCheckout unable to format Invoice Number


webtechwhiz

Recommended Posts

Dear Team,

In reply to a support ticket #KQX-559385 - How to set invoice number raised on 13/01/2021 support team member John Kipling has given AfterShoppingCartCheckout hook on 21st April 2021. 

Based on documentation I had written hook code as below:

function generate_custom_invoice_number_4Client_hook($vars) {
   $invoiceid = $vars['InvoiceID'];
   $customnumber = 'WTW'.date("Y").str_pad($invoiceid,5,"0",STR_PAD_LEFT);
   
   if (isset($customnumber)) {
       try {
           $updatedInvoiceNumber = Capsule::table('tblinvoices')
                                   ->where('id', $invoiceid)
                                   ->update(['invoicenum' => $customnumber,]);
       }
       catch (\Exception $e) {
           // Deal with error
       }
   }
}

add_hook('AfterShoppingCartCheckout', 1, "generate_custom_invoice_number_4Client_hook");

But its not working. As given in hook documentation below parameters should be available:

Parameters

Variable Type Notes
OrderID int The Order ID
OrderNumber int The randomly generated order number
ServiceIDs array An array of Service IDs created by the order
AddonIDs array An array of Addon IDs created by the order
DomainIDs array An array of Domain IDs created by the order
RenewalIDs array An array of Domain Renewal IDs created by the order
PaymentMethod string The payment gateway selected
InvoiceID int The Invoice ID
TotalDue float The total amount due

Hence I have fetched InvoiceId as $invoiceid = $vars['InvoiceID']. But not working.

 

Request community members to help me in formatting invoice number with hook AfterShoppingCartCheckout. Unable to find any post related to AfterShoppingCartCheckout which is used to format invoice number.

Request to kindly approve this topic.

Regards,

Shubhajeet Saha

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.

Guest
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