Jump to content
aliman

Retirive order amount in complete page

Recommended Posts

Hello,

we are using whmcs V7 with SIX template, we are trying to retrieve the variable order amount (total) and show it on the complete order page, unfortunately we only can get invoiceid variable, can you please help me

regards

Share this post


Link to post
Share on other sites
On 10/10/2017 at 4:04 PM, aliman said:

we are using whmcs V7 with SIX template, we are trying to retrieve the variable order amount (total) and show it on the complete order page, unfortunately we only can get invoiceid variable, can you please help me

if the total isn't available in the complete.tpl (and off-hand I can't remember one way or the other), then with the invoiceID, you could always query the db to get the total... or you could use the ShoppingCartCheckoutCompletePage action hook to display your total.

your first step might be to add {debug} to the end of the code in complete.tpl and when you next load the page, it should contain a popup window of available variables - if you're in luck, there will be a total / amount variable for you to use.

Share this post


Link to post
Share on other sites
16 minutes ago, brian! said:

if the total isn't available in the complete.tpl (and off-hand I can't remember one way or the other), then with the invoiceID, you could always query the db to get the total... or you could use the ShoppingCartCheckoutCompletePage action hook to display your total.

your first step might be to add {debug} to the end of the code in complete.tpl and when you next load the page, it should contain a popup window of available variables - if you're in luck, there will be a total / amount variable for you to use.

thank you Brian, i have already used {debug} to get page variable, the popup shows that i can't get order amount, so i have tried to use  ShoppingCartCheckoutCompletePage action hook as you said using this code in my hook:

<?php

add_hook('ShoppingCartCheckoutCompletePage', 1, function($vars) {
    /**
     * Redirect all orders to a different page after the order complete page is loaded.
     */

    $amount = Capsule::table('tblinvoices')->select('name', 'email')->where('id', '=', $invoiceid)->get();


    return $amount;
});

 

but i get empty value.

 

 

Share this post


Link to post
Share on other sites

correct code is 

<?php

add_hook('ShoppingCartCheckoutCompletePage', 1, function($vars) {
    /**
     * Redirect all orders to a different page after the order complete page is loaded.
     */

    $amount = Capsule::table('tblinvoices')->select('total')->where('id', '=', $invoiceid)->get();


    return $amount;
});

Share this post


Link to post
Share on other sites

technically, because you only want one value and not an array, you could do this too...

$amount = Capsule::table('tblinvoices')
			->where('id', $invoiceid)
			->value('total'); 

 

Share this post


Link to post
Share on other sites

thank you Brian,

unfortunately, as i forward directly to the payment gateway, I discovered that my complete order page is only the content of forwardpage.tpl so i can't use any hook !!

any suggestion please ?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

By using this site, you agree to our Terms of Use & Guidelines