Jump to content

Take customer directly to checkout page


zooky

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by brian!
Link to comment
Share on other sites

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.

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