Zen Cart Logo
Forums / Bug Reports / 1.5.3 and 1.5.4, removal of shipped product with free shipping item remaining

1.5.3 and 1.5.4, removal of shipped product with free shipping item remaining

Views: 3,351

Results 1 to 5 of 5
12 Jan 2015, 8:41 PM
#1
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

1.5.3 and 1.5.4, removal of shipped product with free shipping item remaining

If a customer has a cart with a free shipping item included after previously getting to the checkout_payment screen with an item that is to be shipped, the cost of shipping is not reset to 0.00 when returning to checkout with only free shipping (no cost shipping) other than store pickup.

In includes/modules/pages/checkout_shipping/header_php.php

the following code:

// if the order contains only virtual products, forward the customer to the billing page as
// a shipping address is not needed
if ($order->content_type == 'virtual') {
$_SESSION['shipping']['id'] = 'free_free';
$_SESSION['shipping']['title'] = 'free_free';
$_SESSION['sendto'] = false;
zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
}

Doesn't clear the cost before redirecting to the Checkout_payment page..

Add the following to correct this:
$_SESSION['shipping']['cost'] = '0.00'; to read:

 // if the order contains only virtual products, forward the customer to the billing page as
// a shipping address is not needed
if ($order->content_type == 'virtual') {
$_SESSION['shipping']['id'] = 'free_free';
$_SESSION['shipping']['title'] = 'free_free';
$_SESSION['shipping']['cost'] = '0.00';
$_SESSION['sendto'] = false;
zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
}
12 Jan 2015, 8:46 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: 1.5.3 and 1.5.4, removal of shipped product with free shipping item remaining

You say this affects only v1.5.3 and v1.5.4 .... but ... the line you're suggesting to add wasn't something that was ever removed.

So, before accepting this as the fix to a problem, I must ask: what would be the root cause for the issue appearing in v153 but not being in v151 also?

12 Jan 2015, 8:51 PM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: 1.5.3 and 1.5.4, removal of shipped product with free shipping item remaining

Hmmm ... I suppose the difference is that v1.5.1 was setting $_SESSION['shipping'] to a text string 'free_free', which also effectively removed the whole set of sub-array elements, including ['cost'], which thus made cost be 0 implicitly.

Might be further side-effects to research here before a final solution is engaged ... need to determine whether unset($_SESSION['shipping']) should be run before setting any of those elements at all.

12 Jan 2015, 9:13 PM
#4
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: 1.5.3 and 1.5.4, removal of shipped product with free shipping item remaining

Thank you for looking into that difference already... I began a comparison of 1.5.3 and 1.5.1; however, currently only have my eyes to do so. Agree that a larger review would be necessary for the final proper fix; however, setting the cost to 0.00 seemed to fall in line with the other "resets" in the "newer" code..

Perhaps the assignment of shipping to free_free had a positive unintended result, whereas what seems to be a more implicitly called change of the id to free_free fell in line with only modifying the id, but the potentially unintended bonus was missed.. :) Certainly makes one wonder if there are other "keys" that are being generated by other programmers that are desired to be kept (in 1.5.2 and beyond), but that wouldn't have been considered in core 1.5.1 code as the shipping session was cleared/reset...

I also considered the possibility that maybe the shipping quote from the free_free id be captured instead of assigning to 0.00; somewhat maintaining a more object oriented calculation in the event someone has reworked the free_free id shipping module to return an other than 0.00 value... :/

But for the intended individual, they were looking for 0.00 and perhaps there are more areas than the shipping module's quote that would need to be modified to support an other than 0.00 response...

12 Jan 2015, 9:45 PM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: 1.5.3 and 1.5.4, removal of shipped product with free shipping item remaining

I think the most backward-compatible solution is this:

In includes/modules/pages/checkout_shipping/header_php.php

// if the order contains only virtual products, forward the customer to the billing page as
// a shipping address is not needed
if ($order->content_type == 'virtual') {
[B]  $_SESSION['shipping'] = array();[/B]
 $_SESSION['shipping']['id'] = 'free_free';
 $_SESSION['shipping']['title'] = 'free_free';
 [B]$_SESSION['shipping']['cost'] = 0;[/B]
 $_SESSION['sendto'] = false;
 zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
}