Based upon a clean install, just D7.12, Ubercart and dependencies.

Shipping Rules in Place:
Zone: Alabama
Postal code: 11111
Postal code: 22222

/cart
Clicking the Calculate button in "Estimated shipping cost:" doesn't trigger either 11111 or 22222 (but does trigger on zone).

/cart/checkout
The shipping costs are only changed when the Country changes* or the Postal code field loses focus (or you click the button). Selecting an address from the drop down doesn't trigger shipping costs or triggers incorrect shipping costs.

An example of incorrect shipping costs being triggered:
Selected a drop down delivery address with Alabama and 11111 Postal code, no shipping costs triggered. (do nothing in between) Then select another address with Newfoundland (Canada) and 22222 Postal code. The "Alabama" shipping cost is triggered (but not 11111 or 22222).

# # #
And as a last tidbit, using the Postal code field gives wonky results. Sometimes it triggers my "22222" zip code on checkout and sometimes it doesn't.

Original discussion in #1317692: Fetch shipping quote based on State/Province selection rather than postal code

Best,
Sam

*And this seems useless??, as the State/Province is re-set to "Select" so it can't pull up the correct shipping costs anyway. Is this the intended behavior, or is this a typo in the code, such that State/Province was suppose to be the trigger on change and not Country? Would make more sense, but I don't know what the expected behavior is.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

TR’s picture

Status: Active » Closed (duplicate)

This is a duplicate of #1317692: Fetch shipping quote based on State/Province selection rather than postal code. Please keep the discussion in that issue.

Michael-IDA’s picture

Status: Closed (duplicate) » Active

Not a duplicate! Please don't be so quick to close things out.

Yes, that thread is a discussion of a similar topic, but I'm reporting errors here.

See above:

An example of incorrect shipping costs being triggered:

Michael-IDA’s picture

Title: Shipping costs not trigger correctly » Shipping costs not triggered correctly on /cart and /cart/checkout

better title

Additional info: Using Flatrate shipping

TR’s picture

Status: Active » Closed (duplicate)

It's exactly a duplicate. The Ajax event isn't fired in general on changes in the address fields, and that can be expressed in many ways, but it's the same problem.

Michael-IDA’s picture

Status: Closed (duplicate) » Active

One more time,

WHEN the Ajax fires, it does not trigger the correct rule.

/cart
Clicking the Calculate button in "Estimated shipping cost:" doesn't trigger either 11111 or 22222 (but does trigger on zone).

How is that not a bug? Specifically related to "Shipping costs not triggered correctly on /cart," and has nothing to do with "AJax firing on changes in the address fields."

Also, how is

The Alabama shipping cost is triggered {when Canada is selected}

not a bug?

So, please read the whole ticket before you close it as duplicate. If you want, and it helps with clarity, please feel free to remove my question at the end of the original ticket.

Best Regards,

Sam

Additional Info:

Sometimes it triggers my "22222" zip code on checkout and sometimes it doesn't.

When clicking the "Click to calculate shipping" button on the /cart/checkout page.

TR’s picture

Status: Active » Closed (duplicate)

... and you keep listing symptoms all stemming from the same underlying problem. We don't need multiple issues open to track just one problem.

Any further discussion should take place in that other issue.

Michael-IDA’s picture

Status: Closed (duplicate) » Active

WTF?

These bugs have nothing to do with "Fetch shipping quote based on State/Province selection rather than postal code"

Stop being an ass,
Sam

longwave’s picture

Category: bug » support
Status: Active » Postponed (maintainer needs more info)

How exactly do you have your rules configured?

I just created a flat rate shipping quote and applied the following condition:

{ "get_quote_from_flatrate_6" : {
    "LABEL" : "Zip code 11111 conditions",
    "PLUGIN" : "and",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "order" : { "type" : "uc_order", "label" : "Order" } },
    "AND" : [
      { "data_is" : { "data" : [ "order:delivery-address:postal-code" ], "value" : "11111" } }
    ]
  }
}

(in other words, "Data comparison", on "order:delivery-address:postal-code", with "11111" in the value field)

On /cart and /cart/checkout this shipping quote only shows up if I enter 11111 in the zip code field.

MegaChriz’s picture

FileSize
2.21 KB
1015 bytes

This is one part of the issue:

Selecting an address from the drop down doesn't trigger shipping costs or triggers incorrect shipping costs.

When a customer has previously placed orders, there will be drop down called "Saved addresses" from which the customer can select an address.
Well, at first, when selecting an address for delivery no shipping costs are calculated. But when selecting an other address, shipping costs *are* calculated, but these shipping costs are based on the previously selected address.

Example

Let's say whe have three flat rates:
1. $ 5.00 (valid when postal code is "11111")
2. $ 7.50 (valid when postal code is "22222")
3. $ 2.50 (valid when zone is "Alabama" (= 1))

The customer has placed three orders in the past, one with postal code = "11111", one with postal code = "22222" and one with zone = "Alabama".

The customer wants to checkout for the fourth time, he/she adds a product to the cart and goes to the checkout page.

At first, the customer selects the address with postal code 11111 from the saved address drop down. No shipping costs are calculated.
Second, the customer changes his/her mind and selects the address with postal code 22222 from the saved addresses drop down. Shipping costs are calculated and result into $ 5.00. This is wrong, because that rate may only be valid when the postal code is "11111" and the current postal code is "22222". So the shipping costs should have been $ 7.50.

Modules installed

- uc_cart
- uc_order
- uc_product
- uc_store
- uc_quote
- uc_flatrate
- rules
- rules_admin
(and modules were the above listed depend on)

Attachments

Attached are two files:
- One with the rules I had defined.
- One PHP file, to be executed in a Drupal environment, that adds three orders and three flat rates to the database.

MegaChriz’s picture

Status: Postponed (maintainer needs more info) » Active
MegaChriz’s picture

Attached some images to clarify what happens as explained in #9.

1. Customer enters checkout page. No shipping costs are calculated.
2. Customer selects address with postal code = "11111". No shipping costs are calculated.
3. Customer selects address with postal code = "22222". Shipping costs for postal code = "11111" are calculated.
4. Customer selects address with zone = "Alabama". Shipping costs for postal code = "22222" are calculated.

Michael-IDA’s picture

Category: support » bug

Hi Dave,

I only opened this ticket for the bug issue, not for any additional feature implementation. This is the "11111" rule (condition) used.

{ "rules_zip_11111_conditions" : {
    "LABEL" : "zip 11111 conditions",
    "PLUGIN" : "or",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "order" : { "label" : "order", "type" : "uc_order" } },
    "OR" : [
      { "data_is" : { "data" : [ "order:delivery-address:postal-code" ], "value" : "11111" } }
    ]
  }
}

It seems not to fire on /cart, and sporadically fires on checkout.

I can tarball the install if you wish?*

Best,
Sam

*It was a standard "drush site-install standard --db-url=mysql://....." w/ "drush dl/en ubercart".

longwave’s picture

Category: bug » support

A Rule named "rules_zip_11111_conditions" doesn't apply directly to any particular shipping quote method, so you must be calling this condition set from another condition set? How do you have that set up? Can you reproduce this with a simple flat rate method, with the condition applied directly to the method condition set (as in my example)?

MegaChriz’s picture

How do you have that set up?

@longwave, Sam-Inet
See my message with attachments in #9.

longwave’s picture

@MegaChriz: I am talking about the /cart page which does not use an address dropdown; that issue is a different one which I have not started investigating yet

Michael-IDA’s picture

It's setup as a flat rate method, but I don't know how to export that, so I recreated a condition (to export) for post #12.* Doing this the hard way:

/admin/store/settings/quotes
Shipping method: zip 11111 
Details: $11,111.00 + $0.00 per item

/admin/store/settings/quotes/methods/flatrate/4
Shipping method title * zip 11111
Line item label * zip 11111
Base price * 11111.00
Default product shipping rate * 0.00

/admin/store/settings/quotes/manage/get_quote_from_flatrate_4

Data comparison
Parameter: Data to compare: [order:billing-address..., Data value: 11111
{steps to data entry exactly as created condition export in #12}

Three other shipping quotes(all enabled):
Shipping method - Details
Alabama - $111.00 + $0.00 per item
always visible - $0.00 + $0.00 per item
zip 22222 - $22,222.00 + $0.00 per item

Doubtful if helpful, but I'll add this as well:
PHP 5.3.10
mysql Ver 14.14 Distrib 5.1.61, for redhat-linux-gnu (x86_64) using readline 5.1

Thanks for the help,
Sam

*Not that I want to do it for this as it will just add extra elements to debug, but what is the way to export shipping quotes? (my module searching has been fruitless, and I guess I'm not familiar enough with UC if it's part of core.)

longwave’s picture

You can export the conditions via the Rules interface at /admin/config/workflow/rules/components , the same way you presumably exported the other condition set you created.

MegaChriz’s picture

@Sam-Inet
I've exported the shipping quotes using phpMyAdmin 3.4.9. In phpMyAdmin, I selected the table "uc_flatrate_methods" and exported it as a PHP array. I've posted the result in the file 1448288-db.php_.txt (which is attached to comment #9 of this issue). It should be similar to your shipping quotes setup.

Michael-IDA’s picture

Status: Closed (fixed) » Active
{ "get_quote_from_flatrate_4" : {
    "LABEL" : "zip 11111 conditions",
    "PLUGIN" : "and",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "order" : { "label" : "Order", "type" : "uc_order" } },
    "AND" : [
      { "data_is" : { "data" : [ "order:billing-address:postal-code" ], "value" : "11111" } }
    ]
  }
}

{@#17: *cough* oh. and thanks for being patient enough to point out the blatantly obvious.}

Edit:
Might as well add everything I can.

On /cart, Estimated shipping cost:

* State/Province - Alabama
* Country - United States
* Postal code - "11111" {11111 is cut and pasted to validate no extra spaces, etc.}

Click "Calculate", results:
* Alabama: $111.00
* always visible: $0.00

Exporting the rest, just in case I've done something boneheaded (which is preferable to have a deeply embedded bug):

{ "get_quote_from_flatrate_1" : {
    "LABEL" : "Alabama conditions",
    "PLUGIN" : "and",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "order" : { "label" : "Order", "type" : "uc_order" } },
    "AND" : [
      { "data_is" : { "data" : [ "order:delivery-address:zone" ], "value" : "1" } }
    ]
  }
}

{ "get_quote_from_flatrate_3" : {
    "LABEL" : "always visible conditions",
    "PLUGIN" : "and",
    "USES VARIABLES" : { "order" : { "label" : "Order", "type" : "uc_order" } },
    "AND" : []
  }
}

{ "get_quote_from_flatrate_5" : {
    "LABEL" : "zip 22222 conditions",
    "PLUGIN" : "and",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "order" : { "type" : "uc_order", "label" : "Order" } },
    "AND" : [
      { "data_is" : { "data" : [ "order:billing-address:postal-code" ], "value" : "22222" } }
    ]
  }
}

On /cart/checkout
Entering 11111 in Delivery Postal code produces (seemingly) random results when tabbing out of the Delivery Postal code field. {Edit: Cause of randomness was randomly checking "My billing information is the same as my delivery information. "}

Edit:
Completely spurious to the ticket, but, usage note for someone in a similar boat:

On /admin/config/workflow/rules/components/import *, you can fix your 'bad' shipping quotes without having to recreate them from scratch (but don't delete them first in /admin/store/settings/quotes as then they are lost and this doesn't work). Fix the export of the broke rule, (e.g replace "billing" with "delivery" above), and make sure to select "Overwrite." Then your shipping quote is updated and is all happy. (Again, if you delete it and then do an import, this doesn't work.)

* Turn on module "Rules UI" if you receive the message, "You do not have any administrative items."

longwave’s picture

You are comparing on billing-address. The shipping quote form on the cart uses the delivery-address selector.

Michael-IDA’s picture

Seriously sorry for making the ticket now.

Thank you for your help.

Best Regards,
Sam

Michael-IDA’s picture

Status: Active » Closed (fixed)
longwave’s picture

@MegaChriz: can you raise the issue about the dropdown address selector being one pageload behind in a new issue, as this issue is really two problems in one?

MegaChriz’s picture

Status: Active » Closed (fixed)

can you raise the issue about the dropdown address selector being one pageload behind in a new issue

Done.
#1453306: Selecting an address from the drop down at checkout doesn't trigger shipping costs or triggers incorrect shipping costs