I started with quantity.inc as my partner but found that some items need to be adjusted (small items slightly less, large items slightly more), so I created adjustedquantity.inc (see attachment).

Each product has the option to create an additional charge for each product. For less shipping, use a negative number, for additional shipping, use a positive number. If there is more than one item in the cart, the negative numbers are not factored in.

Also, the settings have a threshold setting, so it will charge the base rate unless the quantity is above the threshold, at which point it will charge the set amount for each multiple of that threshold. For example, say your threshold is set to 5, the base rate is $4 and the additional rate is $2. If you have a quantity of 1-5, the shipping would be $4, the base rate. If you have a quantity of 6-10, the shipping would be $6, base rate + additional. If you have a quantity of 11-15, the shipping would be $8, base rate + $2 + $2, for going over the threshold twice.

It also has three region settings as per quantity.inc

try it out
alynner

Comments

alynner’s picture

StatusFileSize
new13.76 KB

Sorry that one didn't work out the threshold properly, please see use the one attached to this post instead.

I just realized there are some problems with this though, it doesn't actually factor in the adjustments when the threshold is exceeded. I'll keep working on it.

alynner’s picture

Sorry, I realized there are a lot more problems with this file. Please ignore this post for now, I will post the file when I have it working properly.

alynner

alynner’s picture

StatusFileSize
new14.18 KB

Okay, it is working now, please test it out.

Here is an example configuration:

A store sells DVD's, T-Shirt and Backpacks

regular(base) rates:
US=$5
CA=$15
INT'L=$20

- DVD's get charged $5 less when shipped to CA and INT"L if it is the only item in the cart, or it is part of a dynamic_parcel.

- Backpacks always charge $5 more to US and CA

- If there is a DVD and an item of clothing, the regular rate would apply.

- If there are more than 5 items in the cart, an extra $5 will be charged in Canada and US. Essentially, for every 5 items, and extra $5 will be applied, so if someone orders 12 items, they would be charged an extra $10.

I don't know if this makes sense, if you have any questions please post them here.

alynner

alynner’s picture

Title: Base Rate +/- extra charges for each product and quantity threshold » Shipcalc - base rate +/- extra charges

Base Rate +/- extra charges for each product and quantity threshold

has anyone tried this?

lunas’s picture

I recently implemented your code and it looks like what I need. However, I am having a problem getting it to pick the right region. It seems to pick region 3 even though I'm trying to ship to Canada. The shipping address is to Canada, however Canada is region 1 and it is seeing it as region 3. Any idea why?

lunas’s picture

Further testing shows that it doesn't matter what country it is I'm trying to ship to, it always defaults to region 3.

alynner’s picture

I can't seem to find the problem or re-create it, the only thing I can think is if somehow the transaction country code is different than the region codes. Have you changed the country codes in any way in your address module or this module?
Another option is perhaps the regions aren't getting saved. You can see what is saved in the variables by creating a page with this php code:

  $region1 = variable_get('shipcalc_adjustdq_region_1_countries', '');
  $region2 = variable_get('shipcalc_adjustdq_region_2_countries', '');
  print_r($region1);
  print_r($region2):

let me know what you get.
-alynner

lunas’s picture

Hi, made a page with that in it - php input filter and it doesn't return anything. There is no content. I have the devel module installed and checked the object structure on the checkout page. The shipping and billing country is listed as ca (Canada) in the array.

lunas’s picture

And no, I haven't changed anything in your module or the ecommerce/address module in general...

lunas’s picture

Alrighty, figured out a couple of things, first being the function you gave me was wrong...changing it to

$region1 = variable_get('shipcalc_q_adjust_region_1_countries', '');
$region2 = variable_get('shipcalc_q_adjust_region_2_countries', '');
print_r($region1);
print_r($region2);

then gives me the following:

Array ( [ca] => ca ) Array ( [us] => us )

So, it looks like the regions are getting saved correctly and ca is the same as what is given in the address module...

lunas’s picture

I figured out the problem...for anyone else who is having problems with shipping modules, and it may not just be this one, but ensure that shipping is after the address collection in the store/settings/cart section. Kind of obvious, it needs to know what the country is before the shipping gets calculated, but that was my stupid mistake for the last couple of days. Damn, so much wasted time.

sime’s picture

Status: Needs review » Fixed

housekeeping

Anonymous’s picture

Status: Fixed » Closed (fixed)
alynner’s picture

Status: Closed (fixed) » Active

sorry to reopen after you have done your housekeeping, but I am just curious why this wouldn't get considered for CVS, its a really good partner for shipcalc, I think people might find it handy...
cheers
alynner

sime’s picture

Hi. Sorry I get quite brief when I'm going through lots of tickets.

Nedjo's original conception of shipcalc is that it should be solely for API-based shipping partners. Initially I disagreed until I actually worked up the code to go in shipcalc. Clearly, to me, this is suited to flexicharge.

I encourage you to look at Flexicharge's progress, there are some docs here: http://drupal.org/node/122769

alynner’s picture

Status: Active » Closed (fixed)

thanks for the explanation. I probably won't look at flexicharge at this point in time, because this does the job for me and I don't actually have the time, but I understand what you are saying.

cheers
alynner