Redirect Customer if Minimum order not reached

Open to all! Ask other shopowners for help.
User avatar
Portman
Contributor
Posts: 158
Joined: Mon Mar 08, 2021 1:04 am
Phoenix Version: v1.0.8.20
Has thanked: 29 times
Been thanked: 4 times

Re: Redirect Customer if Minimum order not reached

Post by Portman »

Thankyou all for your help...

@burt - thanks for the heads up on the startCheckout Hook I will definitly use that instead of what I was trying...

However I am still getting errors...

@Kofod95 when I use your suggestion of;

Code: Select all

Guarantor::ensure_global('Href')::redirect($Linker->build('shopping_cart.php'));
it did not work... it gave me the following error;

Code: Select all

PHP Fatal error:  Uncaught Error: Call to a member function build() on null in .../includes/hooks/shop/checkout/MinOrderRedirect.php:6
Stack trace:
#0 /.../includes/system/versioned/1.0.8.1/hooks.php(160): hook_shop_checkout_MinOrderRedirect->listen_startCheckout(Array)
#1 /.../includes/system/segments/checkout/pipeline.php(14): hooks->generate('startCheckout')
#2 /.../checkout_shipping.php(15): require('/home/devcreat/...')
#3 {main}
  thrown in /.../includes/hooks/shop/checkout/MinOrderRedirect.php on line 6
on the other hand both your extended code;

Code: Select all

$Href = Guarantor::ensure_global('Href');
$Linker = Guarantor::ensure_global('Linker');
$Href::redirect($Linker->build('shopping_cart.php'));
and @ecartz suggestion of;

Code: Select all

Href::redirect(Guarantor::ensure_global('Linker')->build('shopping_cart.php'));
both thew out the following error...

Code: Select all

PHP Warning:  Cannot modify header information - headers already sent by (output started at /.../includes/hooks/shop/checkout/MinOrderRedirect.php:14) in /.../includes/system/versioned/1.0.8.5/href.php on line 195
Are there any other things that I should be trying? at this stage I have stripped the code back to the following for testing purposes...

Code: Select all

<?php
class hook_shop_checkout_MinOrderRedirect {
	
	function listen_startCheckout() {

			$Href = Guarantor::ensure_global('Href');
			$Linker = Guarantor::ensure_global('Linker');
			$Href::redirect($Linker->build('shopping_cart.php'));

		}		
		
	}
	
?>	


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
Kofod95
Senior Contributor
Posts: 749
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Redirect Customer if Minimum order not reached

Post by Kofod95 »

Use ecartz example.

The error, (the last one about modifying headers) I think, comes from the spaces after your closing ?>

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
User avatar
Portman
Contributor
Posts: 158
Joined: Mon Mar 08, 2021 1:04 am
Phoenix Version: v1.0.8.20
Has thanked: 29 times
Been thanked: 4 times

Re: Redirect Customer if Minimum order not reached

Post by Portman »

Woo-hoo! it is working, thank you so much everyone!


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply