zooky Posted September 2, 2019 Share Posted September 2, 2019 Hi All, Is it somehow possible to skip the "view cart" page for a new customer and take them directly to the "check out" page? 0 Quote Link to comment Share on other sites More sharing options...
zooky Posted September 3, 2019 Author Share Posted September 3, 2019 I have come across the below from a 2010 post. {if $filename eq "cart" && $smarty.get.a eq "view"} <meta HTTP-EQUIV="REFRESH" content="0; url=http://yourwebsite.com/cart.php?a=checkout"> {/if} Would a mod_rewrite rule work better than the above? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 3, 2019 Share Posted September 3, 2019 you could try the following hook, which redirects users who are not logged in from viewcart to checkout... <?php # ViewCart For Clients Only Hook # Written by brian! function viewcart_for_clients_only_hook($vars) { $client = Menu::context('client'); if (!$client && $vars['templatefile'] === 'viewcart' && $vars['checkout'] !== true) { header("Location: cart.php?a=checkout"); exit; } } add_hook("ClientAreaPageCart", 1, "viewcart_for_clients_only_hook"); logged in users, e.g clients, will still able to go to viewcart as normal. 3 Quote Link to comment Share on other sites More sharing options...
zooky Posted September 3, 2019 Author Share Posted September 3, 2019 Works beautifully @brian! thank you!! 😀😄 0 Quote Link to comment Share on other sites More sharing options...
Nick A Posted September 5, 2019 Share Posted September 5, 2019 What's the best way to accomplish this if they added only a specific product to the cart? And how would you skip the Order Complete page if they checked out with only that specific (free) product? Just want to direct them to clientarea.php instead. 0 Quote Link to comment Share on other sites More sharing options...
Nick A Posted September 5, 2019 Share Posted September 5, 2019 (edited) Or rather, skip the order complete page if they were not invoiced (ordered a free product) and were not marked fraud. Edited September 5, 2019 by Nick A 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 6, 2019 Share Posted September 6, 2019 (edited) 19 hours ago, Nick A said: Or rather, skip the order complete page if they were not invoiced (ordered a free product) and were not marked fraud. you can't really skip it, but you could redirect as soon as you hit the page using a similar hook to the viewcart one... <?php # Complete Redirect For Free Products Hook # Written by brian! use WHMCS\Database\Capsule; function complete_page_redirect_free_products_hook($vars) { $orderid = $vars['orderid']; $status = Capsule::table('tblorders')->where('id',$orderid)->value('status'); if ($vars['templatefile'] === "complete" && $vars['amount'] == "0.00" && $vars['invoiceid'] == "0" && $status !== "Fraud") { header("Location: clientarea.php"); exit; } } add_hook("ClientAreaPageCart", 1, "complete_page_redirect_free_products_hook"); so if an order has zero amount, no invoice and is not marked as Fraud, then it should redirect to clientarea.php Edited September 6, 2019 by brian! 2 Quote Link to comment Share on other sites More sharing options...
Nick A Posted September 6, 2019 Share Posted September 6, 2019 Doesn't seem to be working for me for some reason. Tried it for AfterShoppingCartCheckout and ShoppingCartCheckoutCompletePage as well. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 6, 2019 Share Posted September 6, 2019 21 minutes ago, Nick A said: Doesn't seem to be working for me for some reason. damn - typo in the $orderid line... i've fixed the line, try it again. 23 minutes ago, Nick A said: Tried it for AfterShoppingCartCheckout and ShoppingCartCheckoutCompletePage as well. SCCCP only returns html, but the above hook should now work. 1 Quote Link to comment Share on other sites More sharing options...
Nick A Posted September 6, 2019 Share Posted September 6, 2019 36 minutes ago, brian! said: damn - typo in the $orderid line... i've fixed the line, try it again. Thank you! 0 Quote Link to comment Share on other sites More sharing options...
Jafar Muhammed Posted September 8, 2019 Share Posted September 8, 2019 Hey @brian!, I tried this in my Dev WHMCS, and I could still see cart.php?a=view before cart.php?a=checkout 0 Quote Link to comment Share on other sites More sharing options...
Jafar Muhammed Posted September 8, 2019 Share Posted September 8, 2019 Oops! My bad. Since I was using Dev (Fresh instance of WHMCS), I used includes/hooks/example.php file and did paste the whole code from @brian!. I had to remove duplicated <?php. It works now. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.