Page 1 of 1

[FIX] Stop orders losing Shipping Service

Posted: Tue May 07, 2013 9:43 pm
by Martin
This particular issue has driven me slightly bonkers of late because of the way customers would sometimes open up multiple windows and mess with different currencies and addresses to see if they could get a better deal by using different country variables, etc...

It may just be something that affected my "Display Prices inclusive/exclusive based on currency viewed" mod' but either way it may well ring true in some other instances and this takes care of it.

Order is placed that has no shipping service selected when one is required. End-user has paid for order successfully and system has validated it regardless.

Customer gets to "Confirm order" page but before clicking to make payment, they open a new browser tab/window to view the cart. They input a new country/state/zip and click the "Estimate Shipping & Tax" button. They don't have to click on the "Update Shipping Cost" button. They then return to their original "Confirm Order" browser tab/window and click "Proceed to Payment".

What this does is wipes the current orders shipping information and leaves the alternate country/state/zip information in the quote. Critically, ISC does not check the validity of the shipping information but it still wipes it from the final total to be paid so the customer is left with a smaller order payment and you get left with an embarrassing situation you need to rectify.

Open: class.checkout.php


Code: Select all

	 * Create the pending order in the database with the customers selected payment details, etc.
	 * @return array An array containing information about what needs to be done next.
	public function SavePendingOrder()
After, Add:

Code: Select all

		 * MOD: Check a shipping service is selected and valid
		 * Avoid the loss of Shipping information caused by some messing with currencies
		if(!$this->getQuote()->isDigital()) {
			$shippingMethod = $this->getQuote()->getShippingAddress()->getShippingMethod();
			if(empty($shippingMethod['module'])) {
				header("Location: ".$GLOBALS['ShopPathSSL']."/checkout.php?action=confirm_order");
		// END MOD
The above code, grabs the shipping method data from the session variable and checks it's actually valid... If no shipping method has been selected it'll redirect the user back to the confirmation page routine although that effectively realises there's bogus shipping info and sends the user back to the address selection/input page(s).

Caveat: Worth noting that I do not offer free shipping as set on specific products so I haven't tested the above code against that scenario. It may well create a no-win loop in that situation so be sure to test it works as expected for all your shipping options at service and product level.

Honesty Box (Contributions)
Just to note this bug has driven me nutty for the last 6 hours so if you use this I expect a bare minimum of a £10/$15 donation to make its way to the International Red Cross. I don't need to know about it but if you charge anyone for the fix you had better send the fee to the IRC then too... That includes you Mr_ISC!