If this is your first visit, check our documentation. To post, register or login.
Forums / Upgrading Your Zen Cart / Upgrading to 1.5.x / "Total" is not removing shipping charge after removing shippable items from basket

"Total" is not removing shipping charge after removing shippable items from basket

Started by jnr345 on 11 Jan 2015, 10:53 PM · Views: 2,497

Results 1 to 20 of 23
11 Jan 2015, 10:53 PM
#1
jnr345 avatar

jnr345

New Zenner

Join Date:
Nov 2013
Location:
USA
Posts:
52
Plugin Contributions:
0

Post #1 by jnr345

This problem doesn't occur on Zen Cart 1.5.0. It's only when I upgrade to either 1.5.3 or 1.5.4.

The problem is I have both digital and physical products. Digital items (ebooks) are zero shipping, and physical items are charged a shipping fee. When I add just an ebook, no shipping is charged - good. When I also add a physical item, the correct shipping is charged for just that item - good. Problem occurs when I delete the physical item and leave only the digital item in the cart - the shipping charge remains in the Total (which was from the deleted physical item). So there is no way to remove this false shipping charge in the Total (it is cached) unless I log-out and log-in again. This happens every time I remove a physical item from the shopping cart (it retains the amount in the Total). Zen Cart version 1.5.0 had no issues with this. Thank you very much for any help as this is driving me bonkers.

12 Jan 2015, 1:25 AM
#2
mc12345678 avatar

mc12345678

Totally Zenned

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

Post #2 by mc12345678

JNR345:

This problem doesn't occur on Zen Cart 1.5.0. It's only when I upgrade to either 1.5.3 or 1.5.4.

The problem is I have both digital and physical products. Digital items (ebooks) are zero shipping, and physical items are charged a shipping fee. When I add just an ebook, no shipping is charged - good. When I also add a physical item, the correct shipping is charged for just that item - good. Problem occurs when I delete the physical item and leave only the digital item in the cart - the shipping charge remains in the Total (which was from the deleted physical item). So there is no way to remove this false shipping charge in the Total (it is cached) unless I log-out and log-in again. This happens every time I remove a physical item from the shopping cart (it retains the amount in the Total). Zen Cart version 1.5.0 had no issues with this. Thank you very much for any help as this is driving me bonkers.

What are your cache settings in your includes/configure.php file? There were some differences introduced to ZC through those versions. More queries are actually cached even without the setting in the configure.php file in effort to increase performance throughout.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

12 Jan 2015, 3:50 AM
#3
jnr345 avatar

jnr345

New Zenner

Join Date:
Nov 2013
Location:
USA
Posts:
52
Plugin Contributions:
0

Post #3 by jnr345

Thanks for your help. My setting is:

define('SQL_CACHE_METHOD', 'none');

I tried switching it to "database" but no change.

Edit: Tried "file" as well. No change, either.

12 Jan 2015, 5:28 AM
#4
mc12345678 avatar

mc12345678

Totally Zenned

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

Post #4 by mc12345678

JNR345:

Thanks for your help. My setting is:

define('SQL_CACHE_METHOD', 'none');

I tried switching it to "database" but no change.

Edit: Tried "file" as well. No change, either.

No change in operation was expected, but knowledge of setting helps a little.

Perhaps I totally missed it, but what shipping module(s) are being used? Any customizations done to the shipping module(s)? (Please identify what is/was modified as able.)

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

12 Jan 2015, 6:04 AM
#5
jnr345 avatar

jnr345

New Zenner

Join Date:
Nov 2013
Location:
USA
Posts:
52
Plugin Contributions:
0

Post #5 by jnr345

It does it with any shipping module but the Table Rate was the main one I was using.

After many hours, I have determined that it isn't anything in the updated database. Turns out it is some file in the upgraded "includes" folder. The admin folder is fine with the upgrade. So, I just re-uploaded the 1.5.0 files and it works fine now. Wish I could find out exactly which file is causing the problem as I would like to upgrade.:(

12 Jan 2015, 11:45 AM
#6
mc12345678 avatar

mc12345678

Totally Zenned

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

Post #6 by mc12345678

A little code explanation to what's going on, while I'm not highly knowledgeable on the inner workings of the shipping modules (can get done what I need) basically, all select queries are cached. When a $db->Execute is performed, if the cache is not requested to be cleared, then there is a strong likelihood that the most recent version of that query is used.

Not sure if there is a way to call the total calculator to ask for the cache to be cleared (recommend calling such after item removal from cart) or if the total calculator should just always clear the cache for that query when calculating. The cache clear variable is I think the fifth to be passed to the Execute command.. (Usually look it up when working the code found in: includes/classes/db/mysql/query_factory.php)

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

12 Jan 2015, 11:51 AM
#7
mc12345678 avatar

mc12345678

Totally Zenned

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

Post #7 by mc12345678

JNR345:

It does it with any shipping module but the Table Rate was the main one I was using.

After many hours, I have determined that it isn't anything in the updated database. Turns out it is some file in the upgraded "includes" folder. The admin folder is fine with the upgrade. So, I just re-uploaded the 1.5.0 files and it works fine now. Wish I could find out exactly which file is causing the problem as I would like to upgrade.:(

To follow up a little, are you saying that at the moment you have a 1.5.4 database, but are using 1.5.0 code to access it? Even 1.5.1 would be better, but maybe one of the more core code centric individuals will address this today and you can return to the 1.5.4 version. Btw, remember to follow instructions such as: http://www.zen-cart.com/entry.php?3-How-do-I-rebuild-my-site-on-the-new-version-instead-of-upgrading to do your upgrade. At least do the upgrade independent of your live store so that things like this can be more easily noted.

Perhaps ajeh or lhungil can help? (No need to PM them, they regularly scan the forums for messages, and I'm thinking this one will catch the attention of someone on the team.)

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

12 Jan 2015, 12:31 PM
#8
mc12345678 avatar

mc12345678

Totally Zenned

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

Post #8 by mc12345678

JNR345:

This problem doesn't occur on Zen Cart 1.5.0. It's only when I upgrade to either 1.5.3 or 1.5.4.

The problem is I have both digital and physical products. Digital items (ebooks) are zero shipping, and physical items are charged a shipping fee. When I add just an ebook, no shipping is charged - good. When I also add a physical item, the correct shipping is charged for just that item - good. Problem occurs when I delete the physical item and leave only the digital item in the cart - the shipping charge remains in the Total (which was from the deleted physical item). So there is no way to remove this false shipping charge in the Total (it is cached) unless I log-out and log-in again. This happens every time I remove a physical item from the shopping cart (it retains the amount in the Total). Zen Cart version 1.5.0 had no issues with this. Thank you very much for any help as this is driving me bonkers.

Another question (looking into the code a little to see how this works), what are the settings for the ebook product regarding shipping and whether it is a mixed product? Basically the items around the middle of the product window just before providing the description in a "standard" ZC install.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

12 Jan 2015, 1:00 PM
#9
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,151
Plugin Contributions:
56

Post #9 by lat9

If I run your scenario through a "standard" Zen Cart v1.5.4 with demo products, I add a "Single Download" (no shipping shows), then a physical product (shows shipping), then remove the physical product ... free shipping shows when I go back to the checkout process.

As mc12345678 indicated above, perhaps it's got something to do with your product's settings?

12 Jan 2015, 5:55 PM
#10
jnr345 avatar

jnr345

New Zenner

Join Date:
Nov 2013
Location:
USA
Posts:
52
Plugin Contributions:
0

Post #10 by jnr345

Wow, thanks for all of your help. Really appreciate it.

As you said, it looks like the cache just needs to clear on the Total (as it does when I log-out). I'll try switching only the query_factory.php file and see if that is the culprit.

The ebook settings I use have always worked fine until I tried to Upgrade.

These are selected:

No, Shipping Address Required
No, Normal Shipping Rules

There are NOT selected:

Yes, Skip Shipping Address
Yes, Always Free Shipping
Special, Product/Download Combo Requires a Shipping Address

I am now using a 1.5.3 database using 1.5.0 files and it works fine; on another server (a client's) she had the exact same issue with the Total not clearing (she has the 1.5.4 database). I'm going to try the 1.5.1 files and see if it works (I suspect it will because I've never had a client complain about this problem when I was installing 1.5.1 for them).

To lat9:

The Free Shipping always shows in the calculation -- it says correctly "Free Shipping: $0.00" but the "Total" always retains the shipping amount when the physical item is deleted (only logging out and logging back in clears it).

Thanks again to both of you.

12 Jan 2015, 6:40 PM
#11
mc12345678 avatar

mc12345678

Totally Zenned

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

Post #11 by mc12345678

Bzzztttt...

Wait... Don't swap out the query_factory.php file in this effort...

That was not to what I was referring...

The $db->Execute command (located inside query_factory.php) has for a while had the clear cache option... But, it wasn't until 1.5.3 that the select queries became well, cached more... There was a significant amount of time/resources savings identified for the code. Thing is that perhaps not all things/situations/conditions were fully tested and therefore some conditions may have made it through to need to have the cache cleared that didn't...

Seeing lat9s response, I stopped looking through the code to see when/where the shipping would get calculated/recalculated. It does seem like there are some session variables at play and perhaps upon removal of the physical product the session variable is not adjusted/corrected for what ends up being a removal of a shipping aspect or there is a query cache issue associated...

Could you perhaps identify when/where in the process the shipping error is identified? For example the shopping_cart page does not necessarily have a shipping price showing when first selected, so when is the shipping rate first identified, what is done to remove the product and then where is the shipping discrepancy seen. (Details/reproducibility are important especially when someone has used a standard cart to try to reproduce and has not found a similar error...)

Also what code differences exist between your store and a stock ZC store? I tried to review the above to identify such, but it is not clear at what point in the rebuild of the site that the issue can be identified...

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

12 Jan 2015, 7:31 PM
#12
jnr345 avatar

jnr345

New Zenner

Join Date:
Nov 2013
Location:
USA
Posts:
52
Plugin Contributions:
0

Post #12 by jnr345

Too late -- I did swap the query_factory.php but it didn't work.

I have determined that version 1.5.1 also works perfectly. So both 1.5.0 and 1.5.1 do not have this "Total" caching issue.

Here is when/where in the process the shipping error is identified:

First step add ebook to shopping cart, click "Go to Checkout" and log-in to account, click on "Go to Checkout" again and it now shows this:

Sub-Total: $4.95
Free Shipping: $0.00
Total: $4.95

Now add a physical item to the cart, click "Go to Checkout" and see this selected shipping:

Table Rate (1 x 0.06lbs)
Best Way $8.50

Now click the "Continue Checkout" button and get this:

Sub-Total: $10.90
Table Rate (1 x 0.06lbs) (Best Way): $8.50
Total: $19.40

Now I click on the header bar where it says: "Shopping Cart - 2 item(s) - $10.90" to access the shopping cart and I see both items. I then click the red "X" to remove the physical item and only the ebook remains in the shopping cart.

Next I click "Go to Checkout"and the calculation incorrectly states:

Sub-Total: $4.95
Free Shipping: $0.00
Total: $13.45

Nothing will correct it unless I log-out and log-in again.

Edit: Forgot to add that the only add-on I use is "Easy Populate 4.0".

12 Jan 2015, 7:34 PM
#13
mc12345678 avatar

mc12345678

Totally Zenned

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

Post #13 by mc12345678

What are the sort orders for each of the modules under modules->Order Totals? (Some reason I'm thinking that makes a difference... Could be wrong... (more than likely am.. :P)) (Sub-total, shipping, and Total I think are the three that may be important here..)

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

12 Jan 2015, 7:39 PM
#14
jnr345 avatar

jnr345

New Zenner

Join Date:
Nov 2013
Location:
USA
Posts:
52
Plugin Contributions:
0

Post #14 by jnr345

mc12345678:

What are the sort orders for each of the modules under modules->Order Totals? (Some reason I'm thinking that makes a difference... Could be wrong... (more than likely am.. :P)) (Sub-total, shipping, and Total I think are the three that may be important here..)

I haven't touched the sort orders. They remain:

Shipping 200
Sub-Total 100
Tax 300
Total 999

12 Jan 2015, 7:44 PM
#15
mc12345678 avatar

mc12345678

Totally Zenned

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

Post #15 by mc12345678

JNR345:

I haven't touched the sort orders. They remain:

Shipping 200
Sub-Total 100
Tax 300
Total 999

These were what I had in I think in a vanilla install of 1.5.3 (reported above to be a problem also after database import) Do you have any additional order totals options beyond what is below? Entries without a value are disabled...

[TABLE="width: 100%"]
[TR="class: dataTableRow"]
[TD="class: dataTableContent"]COD Fee
[/TD]
[TD="class: dataTableContent"]ot_cod_fee
[/TD]
[TD="class: dataTableContent, align: right"][/TD]
[TD="class: dataTableContent, align: right"][/TD]
[/TR]
[TR="class: dataTableRow"]
[TD="class: dataTableContent"]Discount Coupon
[/TD]
[TD="class: dataTableContent"]ot_coupon
[/TD]
[TD="class: dataTableContent, align: right"][/TD]
[TD="class: dataTableContent, align: right"][/TD]
[/TR]
[TR="class: dataTableRow"]
[TD="class: dataTableContent"]Group Discount
[/TD]
[TD="class: dataTableContent"]ot_group_pricing
[/TD]
[TD="class: dataTableContent, align: right"]290
[/TD]
[TD="class: dataTableContent, align: right"][/TD]
[/TR]
[TR="class: dataTableRow"]
[TD="class: dataTableContent"]Gift Certificates
[/TD]
[TD="class: dataTableContent"]ot_gv
[/TD]
[TD="class: dataTableContent, align: right"][/TD]
[TD="class: dataTableContent, align: right"][/TD]
[/TR]
[TR="class: dataTableRow"]
[TD="class: dataTableContent"]Low Order Fee
[/TD]
[TD="class: dataTableContent"]ot_loworderfee
[/TD]
[TD="class: dataTableContent, align: right"]400
[/TD]
[TD="class: dataTableContent, align: right"][/TD]
[/TR]
[TR="class: dataTableRowSelected"]
[TD="class: dataTableContent"]Shipping
[/TD]
[TD="class: dataTableContent"]ot_shipping
[/TD]
[TD="class: dataTableContent, align: right"]200
[/TD]
[TD="class: dataTableContent, align: right"][/TD]
[/TR]
[TR="class: dataTableRow"]
[TD="class: dataTableContent"]Sub-Total
[/TD]
[TD="class: dataTableContent"]ot_subtotal
[/TD]
[TD="class: dataTableContent, align: right"]100
[/TD]
[TD="class: dataTableContent, align: right"][/TD]
[/TR]
[TR="class: dataTableRow"]
[TD="class: dataTableContent"]Tax
[/TD]
[TD="class: dataTableContent"]ot_tax
[/TD]
[TD="class: dataTableContent, align: right"]300
[/TD]
[TD="class: dataTableContent, align: right"][/TD]
[/TR]
[TR="class: dataTableRowOver"]
[TD="class: dataTableContent"]Total
[/TD]
[TD="class: dataTableContent"]ot_total
[/TD]
[TD="class: dataTableContent, align: right"]999
[/TD]
[TD="class: dataTableContent, align: right"][/TD]
[/TR]
[/TABLE]

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

12 Jan 2015, 7:48 PM
#16
mc12345678 avatar

mc12345678

Totally Zenned

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

Post #16 by mc12345678

What about sort order on your available shipping options? I've been presented a message before where two shipping options with the same sort order could cause a discrepancy in (unexpected) reported shipping costs...

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

12 Jan 2015, 8:03 PM
#17
jnr345 avatar

jnr345

New Zenner

Join Date:
Nov 2013
Location:
USA
Posts:
52
Plugin Contributions:
0

Post #17 by jnr345

mc12345678:

What about sort order on your available shipping options? I've been presented a message before where two shipping options with the same sort order could cause a discrepancy in (unexpected) reported shipping costs...

COD Fee ot_cod_fee (red dot; not installed)
Discount Coupon ot_coupon 280 (all remaing are green dots)
Group Discount ot_group_pricing 290
Gift Certificates ot_gv 840
Low Order Fee ot_loworderfee 400
Shipping ot_shipping 200
Sub-Total ot_subtotal 100
Tax ot_tax 300
Total ot_total 999

Shipping modules:

Flat Rate flat 0 (yellow dot; not enabled)
Free Shipping Options freeoptions (red dot; uninstalled)
FREE SHIPPING! freeshipper 2 (yellow dot; not enabled)
Per Item item 0 (yellow dot; not enabled)
Per Unit perweightunit 0 (yellow dot; not enabled)
Store Pickup storepickup (red dot; uninstalled)
Table Rate table 1 (green dot; enabled)
Zone Rates zones (red dot; uninstalled)

12 Jan 2015, 8:07 PM
#18
mc12345678 avatar

mc12345678

Totally Zenned

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

Post #18 by mc12345678

FYI, I just repeated the issue on 1.5.3... Even though I had to add a "shipping method" to my test site (one that actually would charge something) and added it as sort order 10, I originally added Unreal Tournament Linked as a download only, then added a mouse, then removed the mouse following the above process, and when I pressed the last checkout button I was redirected to Page 2 of 3 with no shipping option selected, had free shipping and a price discrepancy equivalent to the price of the shipping that had just been removed... Error continued on to next page as well..

In SESSIONS, the Shipping->cost remains set at the value previously reported...

Doesn't seem to get updated until the button is pressed on Screen 1 of 3, which somewhat seems like perhaps there is something in the header for checkout_payment that may be an issue for when there is a shipping->cost previously existing that it is not recalculated if the entire order now doesn't have shipping??? (Haven't looked through applicable code, just based on system response and information gathered..)

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

12 Jan 2015, 8:20 PM
#19
mc12345678 avatar

mc12345678

Totally Zenned

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

Post #19 by mc12345678

Found it...

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'));
}

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

12 Jan 2015, 8:30 PM
#20
jnr345 avatar

jnr345

New Zenner

Join Date:
Nov 2013
Location:
USA
Posts:
52
Plugin Contributions:
0

Post #20 by jnr345

Fantastic! Amazing how you were able to figure this out. Thank you!!!