Jump to content

How to redirect users from "cart.php" to "MyPage.php"


benneth

Recommended Posts

Would like to create a landing page for all users who are on any "cart.php" page.

The purpose is to redirect users to "MyPage.php", a page with a contact form and "Need additional services? Fill out the form below, or call xyz".

How can I do this?

Thanks!

Link to comment
Share on other sites

7 hours ago, benneth said:

How can I do this?

you don't want any existing client or new user to be able to access any cart page and redirect them elsewhere?

if so, a hook similar to the one posted in the thread below would work...

... but in your case, it's more generic, so you would need to change that if statement to...

if ($vars['filename'] === 'cart'){

and change clientarea.php to MyPage.php

Link to comment
Share on other sites

EDIT: Even when client is not logged in, if a visitor tries visiting "/contact.php", it goes to the "/submitticket.php?step=2&deptid=1" URL

//

Hey Brian,

 

Thanks for the feedback. I tried it, and initially, it worked!

 

However, after about 5-10 minutes (perhaps after a cache clear?), when I click on "Order New Services", or any "cart.php?xyz"... the URL goes to:

/submitticket.php?step=2&deptid=1

 

Here's the code, looked pretty straightforward. I put the code in my "/includes/hooks/helloworld.php" file. Any ideas?

 

<?php

# Redirect Cart Visitors Hook to Contact Form
# Written by brian!

function redirect_cart_vistors($vars)
{
    if ($vars['filename'] === 'cart'){
        header("Location: contact.php");
        exit;
    }
}
add_hook("ClientAreaPageCart", 1, "redirect_cart_vistors");
?>


 

Edited by benneth
Found that it's a macro effect (redirect from contact.php --> tickets page)
Link to comment
Share on other sites

13 hours ago, benneth said:

Any ideas?

aah you want a hook to work for more than 5 minutes... 🤑

the hook code itself isn't the issue, it's your choice of redirection page. ➡️

if the hook was redirecting to a custom page (as per the question), it would work fine.... however, you chose to use contact.php which is a conditional page - e.g., clients cannot use that form to contact you (they would get redirected to a support department regardless of this hook), only non logged-in clients can use that page.

if you want to test that, disable the hook (rename its extension to .php9), login as a client and try to go to contact.php - and you'll find that you'll get redirected to a support department.

what you'll probably have to do is either...

  1. redirect everyone to the same support department (by changing the url in the hook)..
  2. redirect clients to a support dept, non-clients to contact.php (whmcs will do that anyway, but the hook could be tweaked to forward clients to a specific dept if required)..
  3. use a separate custom form for both.
Link to comment
Share on other sites

Hey Brian,

Looks like the issue was a setting under "General Settings".

I had mistakenly entered an email for pre-sales email, instead of setting the ticketing email to Department-based emailing.

All is working now! Thank you for your insight and help.

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