Flat rate gives "Invalid option selected. Recalculate shipping quotes to continue." error

Posts: 24
Joined: 12/18/2007
Bug Finder

I'm running ubercart beta 4 with workflow-ng version 5.x-1.6

i have the flat rate module set up with these options:
-pick up from store
-delivery for orders below 450 euro
-delivery for orders above 450 euro

in workflow ng i set up the events like this:
-pick up from store: no conditions
-delivery for orders below 450 euro: "order total" "Total is less than specified value." and for total order value "450"
-delivery for orders above 450 euro: "order total" "Total is greater than or equal to specified value." and for total order value "450"

on the checkout page all options are shown when they need to be shown (pick up from store is always shown and the other two only when the order totals are right).

but when i select the "delivery for orders above 450 euro" option then i always get: Invalid option selected. Recalculate shipping quotes to continue.

when i change the condition to "less than specified value" but select "negate" --> which should be the same as "greater than or equal" i get the same error.

i've tried to disable the shipment quotes and flatrade modules and reenable it. but this didn't help

Posts: 2114
Joined: 08/07/2007
AdministratoreLiTe!

It sounds like you've done all the right things, but maybe you need to upgrade to beta 5. It's no guarantee though. But it might help.

Posts: 31
Joined: 02/10/2008

I believe this is a workflow-ng bug. Something is not working when you have the workflow "check the total order value" I was able to work around this limitation by checking for products in the order of a certain shipping type. I know this is not quite the functionality you are looking for, but I can confirm that it is not fixed in beta5.

--

www.PrintersCloset.com - Epson professional graphics printers and supplies for photographers, fine art galleries, sign printers and commercial printing companies.

Posts: 904
Joined: 11/05/2007
Bug FinderFAQ ModeratorGetting busy with the Ubercode.

I tried the same thing as the OP in a clean install of Beta 5 and I get the same results - looks like a bug somewhere. The error only occurs when you select the "order >= $xx" method and go to the review page. Selecting the "order < $xx" method works fine, and selecting the method that applies to all order totals works fine. (In my case, I'm using weightquote as a method that applies regardless of order total).

--

<tr>.

Posts: 24
Joined: 12/18/2007
Bug Finder

TR wrote:
I tried the same thing as the OP in a clean install of Beta 5 and I get the same results - looks like a bug somewhere. The error only occurs when you select the "order >= $xx" method and go to the review page. Selecting the "order < $xx" method works fine, and selecting the method that applies to all order totals works fine. (In my case, I'm using weightquote as a method that applies regardless of order total).

i also get the bug with > or when i use < and negate the statement.

would this be a bug in workflow ng or in some other module inside ubercart that uses workflow ng? because i kinda need this functionality. our website sells wooden floors and 1 box doesn't cost 500 euro but 20 boxes do... so i can't really say "if you buy product a then you pay 10 euro delivery costs and if you buy product b then you don't"

Posts: 24
Joined: 12/18/2007
Bug Finder

ok instead of choosing for "Check the order total" I've taken "Custom php code"

in here i can make the statement:

return $order->order_total >= 450;

and then again i get the same error message.

BUT if i make it:

return $order->order_total >= 450 || $order->order_total == 0;

then it does work. so what i expect is that $order->order_total isn't loaded yet

Posts: 24
Joined: 12/18/2007
Bug Finder

ok i "fixed" it with this small workarround

as "custom php code" i used this:

$_SESSION['order_total_tmp'] = $order->order_total == 0 ? $_SESSION['order_total_tmp'] : $order->order_total;

return $_SESSION['order_total_tmp'] >= 450;

so i temporarily save the order total in a session variable. it's not perfect... but for now it works

Posts: 4771
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Thanks for the post, Johnny. I finally dug in and tried to setup some flat rate methods on the Livetest and ran into a wall. I also couldn't get a free method to work for orders over $50. We'll do some more testing and hopefully bugfixing throughout the day!

Posts: 2114
Joined: 08/07/2007
AdministratoreLiTe!

That's the exact problem: the order_total wasn't being loaded at the time of the workflow_ng code. In fact, it wasn't available to any of the checkout panes. This has now been fixed.

Posts: 24
Joined: 12/18/2007
Bug Finder
Posts: 18
Joined: 02/03/2008

Hi,

I had the same problem with beta 4.
I download Beta6 but still nothing.
DO i need a new version of workflow_ng also?

Posts: 2114
Joined: 08/07/2007
AdministratoreLiTe!

This was fixed after beta 6, so you'll need to get the version at http://bazaar.ubercart.org/drupal5/ubercart-bzr.tar.gz. Ryan was going to release beta 7 before Drupalcon, but it's a good thing he didn't because I found a major bug in the order module. Too bad I have to take credit for putting it there to begin with.

Posts: 18
Joined: 02/03/2008

you are right..with the first glance everything seems to be working fine and problem is solved.

Thank you very much for you quick answer
Keep up the good work guys!

Posts: 7
Joined: 03/03/2008
Bug Finder

Hello,
I have a very simple situation - every product have a flatrate of its own. Everything works fine in the checkout page, but in the review page the sitewide flatrate is applied for each product instead of the products' own flatrate. I tried to debug the problem without much success. I noticed that inside uc_flatrate_quote(), the product objects don't have the flatrate variable during review but it's there during checkout. Have you noticed any such behaviour? I am using revision 932 of your bazaar repo.

Thanks,
Progga

Posts: 21
Joined: 01/29/2008

Hi,

After installing and updating the latest bazaar version of Ubercart as Lyle suggested, I now receive the following error:

user warning: Table 'database.uc_gc_products' doesn't exist query: SELECT gc_salable FROM uc_gc_products WHERE vid = 6 in /var/www/html/drupal-5.7/includes/database.mysql.inc on line 172.

The table uc_gc_products does not exist. Why would Ubercart get the wrong table info?

Also, I noticed there is no version info in the modules list for any of the Ubercart entries. Bug?

Thanks

Posts: 2114
Joined: 08/07/2007
AdministratoreLiTe!

That's from the Google Checkout module, and it's not ready for use yet. It should install just fine though, so it's even worse off than I thought. Anyway, go back and disable and uninstall it.

Posts: 7
Joined: 03/03/2008
Bug Finder

I now see that the problem with flatrate I have explained two posts ago is only happening in a PHP4 site. It's working fine in the PHP5 test site.

Posts: 21
Joined: 01/29/2008

Thanks Lyle,
Have you heard anything from Google yet about your status as an approved ecommerce provider?

Posts: 2114
Joined: 08/07/2007
AdministratoreLiTe!

Yes, we've gotten approval to provide a Google Checkout solution with Übercart, which is why I've spent the time to work on it. Eye-wink It'll probably end up as a contrib module like uc_manufacturer rather than a core module.

Posts: 21
Joined: 01/29/2008

That's great news Lyle. Any way I can help out? I'm almost through the API docs. You guys did a great job organizing everything.

Posts: 7
Joined: 03/03/2008
Bug Finder

I have managed to solve my problem. It was a classic php4/php5 issue. In PHP4 everything including objects are passed as copy whereas in PHP5 objects are passed by reference. In this case the original array needed to be changed which was not happening in PHP4. Here's the patch:

=== modified file 'shipping/uc_quote/uc_quote.module'
--- shipping/uc_quote/uc_quote.module   2008-02-21 18:16:47 +0000
+++ shipping/uc_quote/uc_quote.module   2008-03-07 00:48:18 +0000
@@ -1061,11 +1061,11 @@
         }
       }
       $products = array();
-      foreach ($arg1->products as $product){
+      foreach ($arg1->products as $key0 => $product){
         $node = (array)node_load($product->nid);
-        foreach ($node as $key => $value){
-          if (!isset($product->$key)){
-            $product->$key = $value;
+        foreach ($node as $key1 => $value){
+          if (!isset($product->$key1)){
+            $arg1->products[$key0]->$key1 = $value;
           }
         }
         $products[] = $product;

Posts: 2114
Joined: 08/07/2007
AdministratoreLiTe!

Ooh, sneaky! This is an example of code creep. If you'll look at the rest of the function, you'll see that $products isn't even being used after it's constructed. It used to be, but Workflow-ng changed that. Thanks for figuring out the problem.

Posts: 7
Joined: 03/03/2008
Bug Finder

Maybe it's time to introduce some drupal_simpletest based unit tests. I have found them to be very useful.

Posts: 2114
Joined: 08/07/2007
AdministratoreLiTe!

Are you volunteering to write them?

Posts: 7
Joined: 03/03/2008
Bug Finder

Okay I'll give it a shot.

Posts: 7
Joined: 03/03/2008
Bug Finder

The attached module does almost nothing. It only tests the 'review' operation of uc_checkout_pane_quotes() . I am sending it mostly as a placeholder on which I'll build some more tests for uc_quotes. Tests are run from 'admin/build/simpletest'. Please note that the test generates tons of E_NOTICE level exceptions which can be safely ignored according to the documentation.

Thanks,
Progga

AttachmentSize
uc_simpletest.tar.gz1.34 KB
Posts: 4771
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Progga, I'm going to create a group forum for Simpletest as I want to have unit tests and preferably function tests in core for Ubercart 2.0. This will be a little ways down the road, but if you got involved in this you'd be a hero. Eye-wink

For now, I'd hold the patches while we work up to the 1.0 release. I'll start a thread with some resources, and feel free to add to it.

Posts: 7
Joined: 03/03/2008
Bug Finder

Yes, I also support your decision to not introduce the tests at this stage. AFAIK beta softwares aren't supposed to get significant additions. What I have wondered after looking into Ubercart's development process is why it doesn't have a Current and Stable branch like everyother software.

Regarding functional test, we are actually spoilt with choice. The simpletest module can do it, Selenium can do it (but the selenium module needs upgrade). And the one that I really loved was twill. Let's just hope we'll find enough time to write all these Sad