shipping rates per country

Posts: 102
Joined: 08/08/2007
Getting busy with the Ubercode.Internationalizationizer

today i've been working on a simple uc module for defining shipping rates per country. i've totally ripped off the taxes module and bent it to my evil will. i'm a frontend developer, so i was a bit scared to touch too much of the module code. i've basically just changed variable names and made the final calculation a simple addition (subtotal + shipping) instead of a percentage, but that's it.

it works! Laughing out loud it allows me to define a single shipping rate depending on the delivery location. i've only tested it for 'country' so far, but it probably works for 'postal code' and 'zone', too - i'll test that next.

i could stop there and delete the rest of the taxes features that i'm not using, but it would be nice to take it a bit further and make as useful as possible. does anyone have any suggestions about how the taxes features could be reused for such a module?

the first step in the 'add shipping rate rule (add tax rule)' process is the same as for taxes. administrators fill in a name and select the scope of the rule (postal code/ zone/ country).

the second step is where i'm having trouble. the tax module has the following input elements:
- rate (i've kept this, but users define the cost of postage);
- empty line;
- shipping rate;
- cumulative;
- weight;
- custom conditions.

would any of these be applicable to a 'define shipping cost per geographical location' module as i've described?

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

Nifty!

You should take a look at some of the changes that have been made to taxes in the dev version. I've taken out the cumulative flag, and added the product types. This lets you have different shipping rates for different products as well as different regions.

I think the only other part of the form you may want to keep is the custom conditions. It's dangerous but it could be useful for someone who knows what they're doing.

Posts: 102
Joined: 08/08/2007
Getting busy with the Ubercode.Internationalizationizer

oh, product types would be a great addition! then people can define lower costs for lighter items. perfect for a very small business like the one i'm working for where they have much more time than money.

but, maybe a kinda dumb question - where can i find the development version of the taxes module? i seem to remember trying to get development copies before and not being able to successfully install some kind of cvs software on my computer. i'm quite low-tech when it comes down to it. :/

zmove (not verified)

Ohh, I need this module !!

It's usefull for all european country that export a lot to neighbour country.

Greeeat idea, thanks

(it is possible to dl this module for beta testing ? ) ^^

Posts: 59
Joined: 08/08/2007
Early adopter... addicted to alphas.Getting busy with the Ubercode.

Oh, I might have to have a look at how you did the tax in the development version as well. I also needed a more complex way of defining shipping. Different product types have different amounts and setups for shipping, so I actually took the tablerate module that was contributed and extended it so a table rate can be entered for each type of product, and so country, zone and postcode can have different amounts. It is quite annoying though because if you need to define different rates for many different areas, plus each different product type, it is easy to make a mistake, and also very time consuming.
So basically you can enter the following:

country_code|zone_code|postcode 1:4,4:8,8:10

Or, if you leave out country_code, zone_code and postcode, it is just the default version that is used if there isn't a match in the specific ones. Unfortunately you have to know the codes of the country and zone, so like Australia is 36, and one of the zones is 86...something like that. I was going to make it more user friendly later, but I just think the whole thing is too complex to begin with and should have a full user friendly way of entering shipping stuff.

I also thought of copying the way the tax module works for shipping, but I just didn't have the time to work on the frontend bit for my project. I'm hoping that after this big project is over, I'll be able to turn a handful of solutions I worked on into general solutions and be able to give them to the community. I'd be interested in helping in this shipping solution you have put together by copying the tax module if you like, because like I said, I had the same thought.

Posts: 128
Joined: 08/12/2007
Bug FinderGetting busy with the Ubercode.

let me know if there's anything i can do to help with this. I'm a very novice coder, but I also really need this great module, and want to offer any help you might need.

Idan

Posts: 102
Joined: 08/08/2007
Getting busy with the Ubercode.Internationalizationizer

great that other people will use this module, too! tomorrow i will clean out the unnecessary fields mentioned by lyle above and then put it in... uh... ?contributions? so that anyone interested can use and/or improve it.

my client also wants to offer free shipping on orders over a certain amount, so i'll try to implement that as well before i upload it.

then the only thing missing will be the "per product" settings, but that shouldn't be too difficult to integrate once we get our hands on lyle's new and improved tax module.

by the way, i called this module 'geoshipping' because it's shipping based on geographical area, but if anyone else thinks of a better name let me know.

Posts: 67
Joined: 08/10/2007

as far as shipping module goes, could that be expanded so that different shipping rates can be set for different product categories (for example, tangible products vs. software downloads = $$ vs free shipping)

another suggestion, for the tax module... could it be expanded so you can set certain tax per product category? again, software downloads on my cart would not fall under certain tax categories like the other tangible products)

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

Each shipping module has it's own shipping type that can be assigned to products that it can work with. Nearly all of the ones made so far are for small package or parcel type shipping, but now I think there should be one for digital products. Tomorrow I'll work on rebuilding the documentation for making shipping modules, in case someone wants to take this on.

In the dev version, taxes now can differentiate between product types, so that will be in the next release.

Posts: 67
Joined: 08/10/2007

well, I don't know what might be wrong with my version here (the latest one), but in Shipping Settings in Store Config I have "Nothing to see here." message and no options whatsoever. Was that where I was supposed to set all this up?

And I only have Flatrate shipping module enabled.

How do you actually assign certain shipping types to certain products anyway? Where are those settings?

Also, is there a possibility of adding this option (or hacking it in) so that as far as shipping is concerned, all orders above X total cost/amount are shipped for free (or at a reduced rate or something)? That would be really, really great to have for my specific cart...

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

No, the page you're looking for is Shipping Quote settings, right above the Shipping settings. Since it's looking like I won't need any shipping settings, I'll probably do away with that page.

If you only have Flatrate, then you'll only have the default 'box' type available because it's designed to work with every kind of product. If you had more, you could set the default shipping type in the "Quote Methods" section. You can also set it for individual products on their edit page.

To do all that you need, I'd suggest creating your own custom shipping quote module. It can define as many shipping types as you need and return the exact rates you want based on the conditions you specify.

Posts: 102
Joined: 08/08/2007
Getting busy with the Ubercode.Internationalizationizer

alrightey, the "geoshipping module" is almost ready (as far as i can tell). only two problems:

1. i cannot figure out how to extend it to include per-product shipping definitions. anyone know where i can find the taxes dev version?

2. i cannot for the life of me get "orders over X amount ship for free" working! i can get the maximum amount into the database and it displays with the shipping rules on my site, but i can't get it back out to make the calculation!

here's the code - can anyone see what's wrong?

function uc_geoshipping_calculate($order){

// all this stuff is ripped from taxes module

  if (is_numeric($order)){
    $order = uc_order_load($order);
    if (empty($order->delivery_postal_code)){
      $order->delivery_postal_code = $order->billing_postal_code;
    }
    if (empty($order->delivery_zone)){
      $order->delivery_zone = $order->billing_zone;
    }
    if (empty($order->delivery_country)){
      $order->delivery_country = $order->billing_country;
    }
  }
  if ($order === FALSE) {
    return array();
  }
  $geoshippingrate_rules = uc_geoshipping_get_rates();
  $subtotal = 0;
  $geoshipping = array();
  if (is_array($order->products)) {
    foreach($order->products as $item){
      $subtotal += $item->price * $item->qty;
    }
  }
  $new_total = $subtotal;
  foreach ($geoshippingrate_rules as $rule){
    $max_amount = $rule->max_amount; <---- this is where i try to grab it
    $conditions = $rule->conditions;
    if (!$conditions){
      $conditions = 'return true;';
    }
    else{
      //watchdog('taxes', drupal_eval($conditions));
    }
    if (($rate = uc_geoshipping_match_area($rule, $order->delivery_postal_code, $order->delivery_zone,
    $order->delivery_country)) && eval($conditions)){
$amount = $rate;

// this is where i make my fancy calculation that doesn't work

if (($max_amount > 0) && ($new_total > $max_amount)) {
$new_total = $new_total; // don't add shipping fees
} else {
$new_total += $amount;
}
      $geoshipping[] = array('id' => $rule->id, 'name' => $rule->name, 'amount' => $amount);
    }
  }
  return $geoshipping;
}

Posts: 128
Joined: 08/12/2007
Bug FinderGetting busy with the Ubercode.

what are you getting inside max_amount?

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

Since you had trouble getting bazaar to work, I meant to give you the attached files earlier. Sorry I forgot until now.

For your max amount problem, I'd check uc_geoshipping_get_rates() and make sure it's loading the max_amount from the database. If it's not, each $rule->max_amount will be equal to 0, and that means it fails that if statement.

AttachmentSize
uc_taxes.tar.gz7.98 KB
Posts: 102
Joined: 08/08/2007
Getting busy with the Ubercode.Internationalizationizer

great, got max_amount working! (it was a problem with my understanding how the calculation actually worked). now i'm working on the product types.

Posts: 102
Joined: 08/08/2007
Getting busy with the Ubercode.Internationalizationizer

i just wanted to add, i am having a few difficulties with the per-product functionality, but i'll see if i can chew through it this weekend.

meanwhile, the module is working in so much as it applies specific shipping fees to specific geographical locations with the possibility to ship for free over a specified amount. if anyone is hanging on the edge of their seat for this functionality, post here and i will put the module up for download as is. otherwise i'd like to wait until it's completely ready.

Posts: 128
Joined: 08/12/2007
Bug FinderGetting busy with the Ubercode.

hi,

don't want to be a pain, but i'm really looking forward to this module. as I need it in order to migrate for e-comm to ubercart.

Idan

Posts: 102
Joined: 08/08/2007
Getting busy with the Ubercode.Internationalizationizer

hey arbel, don't worry, i feel your pain. i've made a contrib here:
http://www.ubercart.org/contrib/337

please test it and make sure that it works how you expect it to before making the big jump. looking forward to your feedback! Smiling

Posts: 128
Joined: 08/12/2007
Bug FinderGetting busy with the Ubercode.

Hi,

First of all thank you very much. I installed it and I haven't encountered any problems or bugs.

Just a few questions:

1. I noticed you can have two rules for the same country, and at the end the both apply. is this on purpose?

2. another thing is that there is no consideration for product weight...maybe the rule should have a flat rate like it has now, and a price per weight. (this is really important I think).

3. in the checkout page, there's a section to calculate shipping rates...maybe this should be added there too?

4. Maybe there should be a heirarchy in the rules, I mean if you configure a price for a zone, and then another for the country of that zone, what happens? currently I suspect that both are added. Maybe it should be the lowest in the tree (the zone)?

Anyway...I think this is a great module, but the weight thing I think is very crucial and very missing I think.

I'll keep on testing...

the module works for me with the shipping quotes module, and flat rate, and weight modules.

Posts: 489
Joined: 08/13/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Internationalizationizer

First thanks for your module, it's a very helpfull one.

I join my opinion with arbel especially on the weight consideration. Most of transporter (to not say all) give price table based on the weight and the country destination, so the weight cannot be ignored.

When I say weight, I think weight of the total order, not the weight of each product (Because most of the transporteurs take care about the total weight of the package, they don't open them to weight each products in it.

In addition, some countries have custom tax and a field that allow to add a custom tax for a defined country could be really good and usefull.

Posts: 102
Joined: 08/08/2007
Getting busy with the Ubercode.Internationalizationizer

hi guys,

glad you like the module and that it didn't do anything weird to your system, arbel. now, about your questions:

1. I noticed you can have two rules for the same country...

this is something i didn't think about at all - i guess it's just a check that's missing. i'll look into it last as i think some of the other points raised are more important.

2. another thing is that there is no consideration for product weight...

that's true. since you both mentioned this, i think it's the most important thing. probably more important than getting the module working "per-product" even. so the weight would be grabbed from the individual products and then added together to calculate the total weight of the package as zmove suggests? i can probably pinch this code from the shipping module. i guess the idea would be that we can specify different shipping costs for different weight ranges (0-100g, 100g-500g, etc), adding a rule for each different weight range per country? let me know if that's what you guys had in mind.

3. in the checkout page, there's a section to calculate shipping rates

this would be really cool, but could be beyond my capabilities. i'll take a look after i've worked out the weight thing.

4. Maybe there should be a heirarchy in the rules

yes! i assumed that this would behave the same way as it does in the taxes module (where smaller areas override the rules for larger ones). if it's not working, it's probably something i removed by accident. i'll check it out.

5. comment from zmove about customs tax

would it be better to calculate this with the taxes module? i didn't check how the two modules work together. shall do more testing.

got a few things to do today, but i'll try to take a look at the weight issue either this afternoon or tomorrow and let you know.

Posts: 128
Joined: 08/12/2007
Bug FinderGetting busy with the Ubercode.

Hi,

I think your idea for the weight is great. I'm not sure how this works with shipping companies, but it should probably have a price per weight unit - and multiply it to the weight. And maybe specify a range for this value - under 10kg each kg is $1, over 10kg each kg is $2.

but the first part I think is most important.

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

Actually, smaller area tax rules don't override larger areas any more. That's the way it was originally intended, but it got changed pretty quickly.

The latest tax module does give tax rules a weight, so they're applied in order, but that only matters when you have taxes taxing taxes.

Posts: 67
Joined: 08/10/2007

yes, as far as the weight goes, it would be a much better idea to make it configurable so that the shipping cost is defined for each weight category (0-100g, 100-500g, etc) and then once all the products are added there's an option to either charge shipping according to the weight, or at a flat rate... or, even better, if the weight is over a set amount, then charge flat shipping rate, or something like that.

Posts: 102
Joined: 08/08/2007
Getting busy with the Ubercode.Internationalizationizer

i was working on it yesterday evening (woke up this morning realising a small sql omission, now that is sick) and am making a bit of progress.

it should work so that you can define as many rules as you like for each zone:
australia 0-250g $10 max:$100
australia 250g-500g $20 max:$100
australia 500g-1000g $30 max:$100
australia 1000g-5000g $30 max:n/a

each rule will have its own maximum amount, so in this example all orders to australia over $100 are shipped for free, unless they weigh more than 1000g.

it would be nice if i can figure out how to have a 'no max' weight definition, otherwise the upper weight ranges will have to be defined as very large in order to make the calculation correctly.

a couple of questions:

- i have no idea how this would work for pounds and ounces. how do these quantities usually look? will they have to be converted to a metric amount before calculation?

- the system is returning the weights rounded up. can anyone tell me if ubercart does this automatically, or is this perhaps a bug in this module?

and a question for lyle (or perhaps another phper can explain):

- in line 435 of the taxes.module, this statement appears:

if (($rate = uc_taxes_match_area($rule, $order->delivery_postal_code, $order->delivery_zone, $order->delivery_country)) && eval($conditions)){

i'm wondering about the equals sign. does this work as a comparer like == would work in javascript, or is it doing some php thing here?

Posts: 128
Joined: 08/12/2007
Bug FinderGetting busy with the Ubercode.

hi
here: 0-250g $10 max:$100 will the $10 be a flat rate added or a mulitplier. I think there should be two values to each rule. one a muliplier amount for example $1 for each g, and another a flat rate to add for the range.

In addition, there should be a option to select either one, non of them or both. that way we can control exactly the value according to the shipping company.

as for the weight scale issue, I think in the store settings you define what scale you'll be working in (pounds, grams, etc). so I think you shouldn't address it at all and simply count on the user entering the weight value according to the scale the store is set up in.

about the = sign. it's running the function uc_taxes_match_area() and returning a true/false value to $rate, it's tot a comparer. so basicly the if statement checks if both $rate, and eval($conditions) are true....I think!

Idan

Posts: 102
Joined: 08/08/2007
Getting busy with the Ubercode.Internationalizationizer

thanks for the advice about the weight units (pounds, grams, etc) and the = sign!

i think i'm almost there with the flat rate weight ranges (0-250g = $10, etc) but i have another coding question:

for a few reasons, i'd like the variables for minimum weight, maximum weight and maximum amount to be optional. i've set them so that NULL = yes and DEFAULT = null in the database table, but blank fields are still being set to "0" instead of remaining empty. i suspect this is something in the php? these variables are all "float" and "unsigned". i tried removing floatval, but to no avail. none of them are passing through the validation script, so it can't be that...

Posts: 102
Joined: 08/08/2007
Getting busy with the Ubercode.Internationalizationizer

i've uploaded a new version of this module to the contrib.

i had quite a few hassles with mysql, so i'm sorry to say that the new version will not automatically update the first one. the old one will have to be uninstalled and the new one installed from scratch. or you can update the mysql manually if you're handy like that.

it now has the following features:
- weightless packages ship for free;
- items over a specified amount are shipped for free;
- one rule with no min and no max can be defined, or;
- different rules with different ranges (see contrib for more info).

some if this module's many flaws are:
- no checks for conflicting/overlapping rules;
- no possibility for defining price per unit of weight (e.g.: 200g x 0.10p/g = $20);
- zones smaller do not override larger ones.

for someone like my client (cottage industry), this module works fine, but i really wonder how useful it would be for larger applications. it's so much work to define these rules by hand, it seems that there must be a much more graceful solution.

anyway, i do think it's worth tweaking it a bit more to address some of the flaws i've listed above, just to make it a bit more useful. as of this week, i can't devote too much of my time to this module because i'm on a different contract, but i'll keep checking in to see if anyone needs any help with it and i'll try to work on it a bit on the weekends.

Smiling

Posts: 128
Joined: 08/12/2007
Bug FinderGetting busy with the Ubercode.

Hi,

Great work on the updated module....Is there any chance you might add this:

no possibility for defining price per unit of weight (e.g.: 200g x 0.10p/g = $20);

I really need it for my shipping. I know a bit of php and i've looked at the code of the module, but it seems to be above my knowledge...I don't even know where to start =)

Idan

Posts: 102
Joined: 08/08/2007
Getting busy with the Ubercode.Internationalizationizer

yes, i would like to add this feature and i don't think it will be too much work (fingers crossed). i'll look into it later this week when i get the chance.

Posts: 128
Joined: 08/12/2007
Bug FinderGetting busy with the Ubercode.

Ok, I've modified the module a bit..

I've added another field to indicate whether the rule is to be a flat rate or a per weight muliplication.

It all works well...except that there's a bug. I'm not sure if I created it or it was there before (most likely I did it).

The order page only takes into account the first rule, and adds a line that there was an error in shipping calculation...

I can't find the bug...

AttachmentSize
uc_geoshipping_idan.zip18.2 KB
Posts: 128
Joined: 08/12/2007
Bug FinderGetting busy with the Ubercode.

after another test, I'm starting to think I didn't create the bug....less chance of finding it =(

Posts: 128
Joined: 08/12/2007
Bug FinderGetting busy with the Ubercode.

Ok...I fixed everything and it works now!

I'm uploading it here for megg to take a look and give the ok.

As mentioned in the previous post. I simply added another field when adding a rule, this field allows you to choose whether you'd like the value to be added only once per order, or multiplied against the weight ($1 per kilo for example).
If you wish to use both, simply create two rules.

If you have one for use over a specific weight and the other below it, simply use the min max fields megg created.

I think this is a superb module. Good job megg.

Idan

AttachmentSize
uc_geoshipping_idan.zip18.3 KB
Posts: 128
Joined: 08/12/2007
Bug FinderGetting busy with the Ubercode.

I think the only thing missing now is to have the ability to choose multiple areas for each rule.

I mean if you're prepared to have worldwide shipping, and every country is the same price, you'll have to setup a rule for every country....there needs to be a multiple election rule, or an exlusion rule.

I really don't know how to do that.

Idan

Posts: 102
Joined: 08/08/2007
Getting busy with the Ubercode.Internationalizationizer

wow, idan! you added the price per weight feature - yay for you! Smiling i'm going to install this and test it hopefully thursday.

i totally agree about the multi-country feature. i'm going to see if i can think of a way to do that...

Posts: 128
Joined: 08/12/2007
Bug FinderGetting busy with the Ubercode.

I think the way to do is to have the select country a multiple selection form, and have all the selected countries/zones insert into an array. Then when send the rule to be checked against country you send a the array and loop through it...I tried looking into exactly how to do it but I think it's a bit above me php knowledge.

Idan

Posts: 102
Joined: 08/08/2007
Getting busy with the Ubercode.Internationalizationizer

yes, that's what i was thinking, too. so from the users' perspective, they create their shipping rules (or rule groups, in the case of 0-250g, 250g-500g, etc) and then assign any number of countries/locations to each rule with the multiple select you describe. once assigned to a rule, that country is no longer available in the multiple select, so it can't be assigned twice...

Posts: 128
Joined: 08/12/2007
Bug FinderGetting busy with the Ubercode.

I think the country should stay available for two reasons. first it's simplier =) second if a user wants to create multiple rules for a country, for different weight ranges or to create a flat rate and a per weight rule for the same country.

Idan

Posts: 69
Joined: 08/08/2007
Internationalizationizer

thanks!

Posts: 102
Joined: 08/08/2007
Getting busy with the Ubercode.Internationalizationizer

this weekend i'll take a look at the possibility to define location groups so that rules can be defined for a bunch of countries at once...

Posts: 69
Joined: 08/08/2007
Internationalizationizer

Hi,

I'd ask that you consider two features:

1) make each rule have a flat rate and a per_lb cost
with a 0 default for either coefficient if nothing is entered.
This "linear" rule (y = ax+b) covers a wide range of shipping options.

2) have a default rule that applies for the case when no other
rule has been applied. For example, if there is only a "US",
and a "Canada" rule, then the default rule could apply to every
other country. It'd work great and could bypass in a lot of
cases, the need to enter multiple countries as groups.

Thanks!

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

I'm thinking that this thread is relevant enough for me to cross-post: http://www.ubercart.org/forum/development/212/international_vs_domestic_....

Because of all the talk about doing things the way taxes were done, I wasn't sure if you were using the shipping hooks. If you are, that means you can set geoshipping for international shipments and UPS or whatever to calculate domestic shipments.

Posts: 102
Joined: 08/08/2007
Getting busy with the Ubercode.Internationalizationizer

@ dkashen

yeah, it would be great to have some defaults b/c as it is now, you have to set at least 120 rules (1 per country) in order to use the module. :/

that kind of feature is a bit over my head, though - anyone else like to take a crack at it?

i also had a look at the possibility of creating another database table which would allow the user to assign countries to groups. then the world could be divided into, say, 5 postal zones and only 5 rules would have to be entered.

however, i'm sad to say that it's a bit beyond my skill level at the moment. i gave it a good try, but i could see that it would take me days to work out how to program something like that and i just don't have the time right now.

@ lyle

i'm not sure if this module uses the shipping hooks. i really just adjusted the taxes module on quite a basic level, so if the shipping hooks are used there, they'll be used in geoshipping as well.

i won't be surprised if the geoshipping module has a short life, because there's bound to be a better way to do all this. i see it as more of an interim measure than a longterm solution.

i found one tiny wee mistake in the last zip, so here it is again. i'll also update it in the contrib.

AttachmentSize
uc_geoshipping.zip11.29 KB
Posts: 69
Joined: 08/08/2007
Internationalizationizer

Hi,

Thanks for the update.
I am a php and ubercart newbie as well.
I'd like to know

a) where the rules are implemented, so I can insert a default rule execution,

b) how to debug uncertain code (print statements ?)
and
c) a hint on why when I press the
"estimate shipping cost" button on checkout,
and the "receiving quotes" status bar just spins and spins.

I'm running drupal 5.2, and UC alpha 7b with the latest uc_geoshipping.zip

Thanks,
DK

Posts: 128
Joined: 08/12/2007
Bug FinderGetting busy with the Ubercode.

Megg, does your zip file include my addition for flat rate?

Also, I really think we need to solve the default problem somehow...so there's at least one default shipping value.

Idan

Posts: 128
Joined: 08/12/2007
Bug FinderGetting busy with the Ubercode.

I've been working on creating a rule type that will apply to all shipping purchases.

I've got it to work, but now i'm working on disabling it, if any other rule is used. So when you purchase something, either the default rules work or your specific rules.

Also I found and fixed a bug, in the old version - if you have 10 rules, and only one of them applies to your current purchase, then you'll get a list of the other 9 with $0.00 next to them.

i've hit a small problem,

I need to remove a "row" from an array. this is how I input the data into the array:

PHP Code:

$geoshipping[] = array('id' => $rule->id, 'name' => $rule->name, 'amount' => $rate, 'type' =>$rule->type);

this is run several times, (each time with different values in $rule).

I want run delete all the times $rule->type is equal to 'anywhere'

this is what I tired ,but it didn't really work....i'm a php novice, and well at this point I can' even visualize the array i'm using...so I really need some help:

PHP Code:

function uc_geoshipping_anywhere_check($applied_rules) {
foreach($applied_rules as $check_rules => $type) {
if($type == 'anywere') {
unset($applied_rules[$check_rules]);
}
}
$new_array = array_values($applied_rules);
return $new_array;
}

Posts: 128
Joined: 08/12/2007
Bug FinderGetting busy with the Ubercode.

Well,

Another big update to the module.

Now it has default rules otherwise known as anywhere. Basically when you create a rule, you choose either, country, zone, state or anywhere.

If you choose anywhere, then this rule will affect all shippable purchases.
you can have as many of these rules as you wish, and also create flat rate rules, in addition to per weight rules.

If your purchase falls under the scope of a regular rule, then the default rule will not take affect. Basically it's a shipping rate for everything unless there's another specific shipping rate.

There is one small bug: after you choose the anywhere scope, you go to another page where for other scopes there would be more options, but here I tried to print out some text or even skip it but didn't quite get it to happen. So you get an empty screen and you need to press next again...doesn't affect the script what so ever, just looks weired.

Anyway...attached is the file, megg please take a look.

Idan

AttachmentSize
uc_geoshipping_idan.zip18.94 KB
Posts: 69
Joined: 08/08/2007
Internationalizationizer

Hi ,

I haven't got the beta of this going yet, and I would really like to try it!

I've installed uc_geoshipping directly under the module directory.
and admin/modules has uc_geo.. enabled.

I'm able to setup rules, but my checkout tests still get stuck at the
"receiving quotes" status bar.

What else is there to the setup ?
does any other part of UC have to be told explicitly of uc_geo's existence ?

Thank you,

Posts: 102
Joined: 08/08/2007
Getting busy with the Ubercode.Internationalizationizer

idan, that's fantastic! the "anywhere" location will definitely save us all some typing!

i've had a quick look at it, and although there are no errors, it's not working exactly how i would expect, but i am pretty tired, so i want to take a fresh look at it tomorrow evening and see exactly what's happening. but it looks like it's definitely almost there! Smiling

ps the previous zip i uploaded to contrib does contain your flat rate vs weight rate additions.

Posts: 102
Joined: 08/08/2007
Getting busy with the Ubercode.Internationalizationizer

hi dkashen,

sounds like you've installed it correctly. this module isn't as sophisticated as the other shipping methods used with ubercart. the shipping quote isn't generated and added to the order until the customer clicks "review order", then the price is added.

i know this isn't ideal, but it's the best we could do for now. i'm planning to put a small note somewhere in the checkout process on my site telling customers that their postage will be added at the review stage so that they're not shocked to see their order total increase at the last minute. that's something that won't be included in the manual, but if i figure out how to do it gracefully, i will definitely post here on how to do it.

also, don't forget that we're still developing and testing this module, so if you see anything weird, do let us know, it's very helpful.

hope that helps!

Posts: 69
Joined: 08/08/2007
Internationalizationizer

ah,
so that receiving quotes status bar is disconnected from uc_geo ?
maybe we can just suppress it's on screen display . . .

Posts: 128
Joined: 08/12/2007
Bug FinderGetting busy with the Ubercode.

yes, you can easially remove it with no consequence, and it works great.

Posts: 69
Joined: 08/08/2007
Internationalizationizer

hmm,
I tried
commenting out the ajax in the uc_quote.js code ,
but there were still a few other places where
"click to calculate shipping costs" was visible.

Also, uc_quote is a prerequisite for having an ubercart store
as far as I can tell from the module admin fields.

So,
what's the easiest way to disable the active quoting (for now) ?

Thanks,
DK

Posts: 102
Joined: 08/08/2007
Getting busy with the Ubercode.Internationalizationizer

in my setup, i have disabled the modules "shipping quotes", "shipping" and "flatrate" in the drupal modules interface (www.mysite.com/admin/build/modules) and i don't get an active quoting option during the checkout process...

Posts: 102
Joined: 08/08/2007
Getting busy with the Ubercode.Internationalizationizer

i've been trying for a few hours now to get this module working with the new default setting, but am having no luck. Sad

as far as i can tell, the default "anywhere" setting isn't working correctly because it applies to _all_ countries. so if the calculation hits the "anywhere" rule before it hits any of the specific ones, the calculation stops because it has a rule to apply.

i can't figure out how to loop through an array and then, if certain criteria aren't met (no specific shipping rules for the location selected), to then repeat the calculation based on the "anywhere" rule. by the time the script has figured out that there is no match, the loop has finished and the opportunity to grab any default rules is gone.

an elegant solution would be to figure out how to make geographical locations over-rule each other like we planned to do for postcode, zone and country. so that if there are no postcode settings, zone is used, then if there are no zone settings, country is used, then if there are no country settings, "anywhere" is used. does anyone have any hints on how to do this with php?

Posts: 69
Joined: 08/08/2007
Internationalizationizer

I thought it was working,
but the "anywhere" case isn't working for me either ;-(
the difference is that I cannot get it to apply in any situation.

Posts: 128
Joined: 08/12/2007
Bug FinderGetting busy with the Ubercode.

that's wiered because it's working for me...i'll take another look.

you can take a look at my site here: http://arbel-designs.com/drupal/drupal-5.1

there's a rule for anywhere, two rules for israel, and another rule for Afghanistan. If you ship to either countries, the specific rule is used, if you choose a different country the anywhere rule is used.

Posts: 69
Joined: 08/08/2007
Internationalizationizer

using mozilla firefox 2.0
I went to your store,
and could only get (under payment method)
the default rule
all the world:
to work.
Israel and Afghanistan didn't trigger their own rules.

AttachmentSize
UC_shipping_rule_glitch.jpg17.1 KB
Posts: 69
Joined: 08/08/2007
Internationalizationizer

Hi,
On our own site I have six rules (flat+per_lb) for 3 zones (US,CA, and DF (everywhere else).
(see attached setup screen shot).

I've attached checkoput screen shots that
show the US & CA rules are applying correctly ,
but I haven't been able to get the DF rule to apply

I am using Drupal 5.2 and php 5.0
maybe that makes a difference . .

if I can find the simple "printf" equivalent for PHP,
I can help debug what's happening over&above just reporting
a bad result.

Thanks,
DK

AttachmentSize
UC_shipping_rule_setup.jpg16.92 KB
UC_shipping_rule_germany.jpg11.5 KB
UC_shipping_rule_canada.jpg12.88 KB
UC_shipping_rule_usa.jpg11.89 KB
Posts: 128
Joined: 08/12/2007
Bug FinderGetting busy with the Ubercode.

megg, I think I know what the problem..of the top of my head I see that you have only a billing address and not a shipping address. probably the type of product you purchased...maybe the problem is there, that rule shouldn't be activated. I'll take a closer look.

Idan

Posts: 128
Joined: 08/12/2007
Bug FinderGetting busy with the Ubercode.

ok, after a quick check that's the problem...i'll see about fixing it.

Posts: 128
Joined: 08/12/2007
Bug FinderGetting busy with the Ubercode.

from my testing the module works as follows:

if you purchase a product with no weight then the shipping rules don't take affect.

if you purchase a file product with weight then you only input a billing address (not a shipping address) and the anywhere rule takes affect.

if you purchase a product with a weight then you enter billing and shipping info and the appropriate rule takes a affect.

so far this works well, although I think that a file product with weight shouldn't get the anywhere charge...

I'm not sure how ubercart decides when do you fill in shipping information and when you fill in billing information.

Idan