Jump to content

Redirection to a page for new customers without an active product


Jim1120

Recommended Posts

Good morning,


I made a hook to try to redirect new customers and those who no longer have an active product among product group 1 :

 

With this, the customer is always redirected to the page /store/adhesion even if he has an active product,

I check documentation, this is my first hook and I can't figure out where the problem is.


Can you help me ?
Thank you so much

Link to comment
Share on other sites

I can't post my hook code, i retry now :

add_hook('ClientAreaPage', 1, function($vars) {
    if ($_SERVER['REQUEST_URI'] === '/store/adhesion') {
        return;
    }
    if (isset($_SESSION['uid']) && $_SESSION['uid']) {
        $client_id = $_SESSION['uid'];
        $result = localAPI('GetClientsProducts', array('clientid' => $client_id, 'status' => 'Active'), '');
        if ($result['result'] == 'success') {
            $products = $result['products'];
            $has_active_product = false;
            foreach ($products as $product) {
                if ($product['gid'] == 1 && $product['status'] == 'Active') {
                    $has_active_product = true;
                    break;
                }
            }
            if (!$has_active_product) {
                header('Location: /store/adhesion');
                exit;
            }
        }
    }
});

 

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