Jump to content

redirection after the payment


Recommended Posts

Hello

suppose I have a product ID 5 and a product ID 6 and I want redirect the customer after the payment to a custom link

who order the product ID5 should be redirected to page5.html (after the payment)
who order the product ID6 should be redirected to page6.html (after the payment)

how to do this please ?

Thank you

 

 

Link to comment
Share on other sites

Hello, thanks for reply, I'm asking because I am still seeing this (right now I am seeing it)

" Your content will need to be approved by a moderator. This happens within 24 - 48 hours and applies for your first few posts, usually no more than 10. Please note the moderators cannot remove this moderation step you must go thru this like all other community users. "

 

 

 

Link to comment
Share on other sites

  • 2 weeks later...

Use this hook point. You'll need to use invoiceid parameter to perform a query to look for your product ID 5 and 6. You'll need to join tblinvoiceitems with tblhosting. Once done, you can perform your redirect.

Here you can find all details about hooks.

Edited by Kian
Link to comment
Share on other sites

  • 2 months later...

I'm trying to code the required hook but I have some problem


- After the payment the array $var does not contain the product pid=5 , how to add it to $var array ?
- When I try to return a value from $var array It does not work for example

<?php
add_hook('ShoppingCartCheckoutCompletePage', 1, function ($vars)
{

    $firstname = $vars['firstname'];
    echo "-->$firstname<--";
    // Run code to create remote community account here...
     
});

returns nothing , why ?

- How to change the button "Continue to the Client area" with "Countinue to mysite.com" and how to change the link tied to this button ?

 

Thank you
 

Link to comment
Share on other sites

3 hours ago, graziano_68 said:

After the payment the array $var does not contain the product pid=5 , how to add it to $var array ?

Kian gave you a clue about that - $vars only returns certain values, e.g the invoice or order ID... with only that one piece of information, you then have to query the database to get the information you require - which in your case is the PID.

untested, but I think it should be along the lines of...

<?php

# Cart Complete Page Redirection Hook
# Written by brian!

use WHMCS\Database\Capsule;

add_hook('ShoppingCartCheckoutCompletePage', 1, function($vars) {
	
	if ($vars['ispaid'] == true) {
		$orderID = $vars['orderid'];
		$myproducts = Capsule::table('tblhosting')->where('orderid',$orderID)->pluck('tblhosting.packageid');
		if (in_array("5",$myproducts)) {
			return '<META http-equiv="refresh" content="0;URL=http://www.mydomain.com/ownpage.html" />';
		} elseif (in_array("6",$myproducts)) {
			return '<META http-equiv="refresh" content="0;URL=http://www.mydomain.com/anotherpage.html" />';
		}
	}
});

the database query creates a list of products in the order, then if it finds pid=5 in that list, it redirects to one page; if it finds pid=6, it redirects to another page; if neither are in there, it does nothing...

the obvious bug in your question is what to do if the order contains both 5 & 6, but I assume that's not going to occur (depending on what those products are)... as written, it will see 5 first and redirect accordingly...

btw to make it easier for you to follow, i've used the refresh code from the hook developer docs, though i'd personally use header location redirection...

3 hours ago, graziano_68 said:

returns nothing , why ?

for starters, $vars['firstname'] won't exist as a variable...

3 hours ago, graziano_68 said:

How to change the button "Continue to the Client area" with "Continue to mysite.com"

changing the text would require using Language Overrides...

$_LANG['orderForm']['continueToClientArea'] = "Continue To Client Area";
3 hours ago, graziano_68 said:

and how to change the link tied to this button ? 

the easiest way would be to edit the complete.tpl template and change the hardcoded link to clientarea.php in there, but it could possibly be done with a ClientAreaFooterOutput hook using JS.

Link to comment
Share on other sites

  • 2 weeks later...

Please Brian or anyone who can help,  another question,

I would set OFF terms of service acceptance if a customer ordesr a product ID 5 
OR I would provide the customer another TOS  link (not the default TOS link set in WHMCS)  if the if a customer orders a product ID 5  .

Is it possible ?

 

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