Regions

Contrib type: 
Module
Status: 
Awaiting moderation
Compatibility: 
Ubercart Alpha 7c

Helper module for the world quotes module.

Allows you to define regions which are one or more countries.

installation instructions:
unzip into modules/ubercart/shipping/

configuration is under home>administer>store administration>configuration>methods

AttachmentSize
uc_regions.zip4.06 KB

Re: Regions

Hi, thanks for this module !

I have errors on install : see worldquote post

Edit :

In addition, I think there is a little error in your .install file :

you have db_query("CREATE TABLE {uc_wolrdquote_regions}

it should be db_query("CREATE TABLE {uc_regions} ( no ?

I tried to change it, but it doesn't remove the SQL error on the linked post.

Edit 2 : I find the problem for the worldquote module, but I think the patch to make above is still active no ?

Re: Re: Regions

yeh, the install had a small bug, updated the zip file...I don't quite understand the edit 2.

Idan

Regions module review

Regions module review
This is just based on looking at the code. I haven't actually installed or tested it yet. That said, it looks like it should work properly. Good job.

Things to fix:

  • Table name in uc_regions_install() is 'uc__regions', should have only one underscore.
  • The calls to db_query() on lines 182 and 193 are open to an SQL Injection Attack. Parameterize the data.
  • The unit conversion constants are define()d in uc_store.module, and do not need to be here.
  • MENU_CALLBACK_ITEM is not defined, MENU_CALLBACK is. My fault for writing modules that way before.
  • I think it's a good idea to remove the version and CVS information added by Drupal in the .info file. We've had version confusion because of that.
  • Please style the code according to the Drupal coding standards. Specifically, use two spaces instead of tabs to indent code. This keeps indentations consistent across text editors.
  • Remove extra files from the .zip archive (.M, .php). I was a little confused by them. *shrug*

Re: Regions module review

thanks, like with the worldquote, updated everything other than the sql injection thing...need help sorting that out.

Re: Re: Regions module review

The modules does not create database tables on alpha7e

Still no error is reported at install time.

After converting line endings to Linux style (from WIN), diabling module, uninstalling module, installing again it seams to work.

Seams to me line-ending problem. Switching to LINUX stype wold resolv the problem for all platforms.

Hi, I'm really not sure what

Hi,

I'm really not sure what that means, a bit of an amature coder...

I've updated the file with a new version, fixed sql injection risk.

Let me know what you think and if there are any bugs, and i'll fix them asap.

Idan

Re: Hi, I'm really not sure what

Traditionally, files created and used by DOS and Windows used "\r\n" to denote line endings (carriage return + new line). Unix used "\n", and Macintosh used "\r".

Decent text editors will let you change which characters are used when you hit the Enter key. Programmers are nearly always taught to use "\n" as the newline, and it's become the standard for multi-platform applications. Like Drupal. Smiling

Re: Re: Hi, I'm really not sure what

I used dreamweaver to edit this...i'll take a look and see if I can file that setup somewhere.

Missing CSS

On line 44 of the module you have:

    drupal_add_css(drupal_get_path('module', 'uc_regions') .'/uc_regions.css');

There is no such file in the distribution, and all this works without any error, until you try and use the mimemail.module, which assume all the files added by 'drupal_add_css()' exists - and an error is generated.

While mimemail.module needs to do better checks against the file system, I suggest to remove that line if the CSS file does not exist.

Re: Regions

I was having problems just entering a value in the regions. I looked at the code and the form seemed to be a 'multistep' form but there was only one step. Drupals handling of multi-step forms is ... problematic as I found out doing the 'uc_import_csv' module so changed it to a simple form, added a TAPIr table and some other little bits and pieces. My version is attached. Perhaps you can merge with the main version if you like it.

Also, the uc_regions table is a bit ugly in that the 'countries' column should be replaced with its own table which would just be a join between the 'uc_countires' table and the 'uc_regions' table.

This module needs some cleaning up database wise. I hope my changes are a step in the right direction.

AttachmentSize
uc_regions.module9.57 KB

Re: Re: Regions

Hey guys, I wanted to download this contrib, but the .module file is nothing but this:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /files/uc_regions.module
on this server.</p>
<hr>
<address>Apache Server at www.ubercart.org Port 80</address>
</body></html>

Halp! Smiling

Re: Re: Re: Regions

Looks like the ubercart.org site is not letting you download it Sad Maybe Ryan has something to say about it?

Re: Re: Re: Re: Regions

It's Drupal's .htaccess. If you could zip that up and reattach it to your comment, it should be fine.

Re: Re: Re: Re: Re: Regions

Thanks Ryan, will do. See attachment. I also added a verion number to make tracking bugs easier.

AttachmentSize
uc_regions_v1.0.zip5.48 KB

very nice the regions a bug

very nice the regions

a bug I have is that editing a region doesn't edit it but adds another new region.

Re: very nice the regions a bug

oh that seemed a small bug but it is big.. because I updated a region adding a country... it created a new region... so I said.. ok let's delete the previous one since the name is the same... but it didn't work... because the calculations are based on the ID of the region not on the displayed name... so I had to change the ID in the database manually to be the same as in the worldquote settings. That wouldn't have been a problem if editing a region edits it without adding a new one...

Any update on this ?

Has there been any update on this ? Which version of uc_regions should we install ?

V3

Well if you would like to be somewhat of a guinea pig Smiling you can install this version.
I've replaced the pipe separated countries field with a join table.
If you notice any bugs that you can't/don't want to fix, let me know and i'll try to correct them.

Is this module in CVS yet? I haven't really gotten into contributing on CVS, but if it hasn't been done I could have a go.

AttachmentSize
uc_regions_v3.zip5.11 KB

Re: V3

guinea pig is my middle name. Thanks ! Can we also re-enable the older stable version please ?

Defining Regions

Hello,

Is it possible to define a region that consists of states instead of countries? I need to set up shipping costs based on quantity (or weight if necessary), state where the order will be shipped and type of shipping (air or ground). Multiple states fall into the same shipping rate so I would like to set up different regions which contain the one or more states. For example

Region1 = CA
Region2 = OR,NV
Region3 = AZ,CO,ID,MT,NM,WA,WY

Ground
Qty Region1 Region2 Region3
1 $12.62 $12.99 $13.16
2 $13.45 $14.21 $14.50
3 $14.67 $15.33 $15.67

Air
Qty Region1 Region2 Region3
1 $14.35 $16.80 $17.50
2 $18.00 $21.95 $22.65
3 $21.80 $27.25 $28.00

Thanks for your help,

Patrick