I want to sell two types of products on my site:
1. CDs, for which I want to charge shipping/handling
2. Concert tickets, for which I don't want to charge shipping/handling

For the CDs, I created "tangible" products. For the concert tickets, I created "generic" products.

When my cart contains only "generic" products, no shipping charge is added--good. When my cart contains only "tangible" products, shipping charges are added based upon either the number of items, or the total dollar value of items in the cart--good.

The problem arises when I have both "tangible" and "generic" products in my shopping cart. In this case, shipping charges are calculated and added as if the "generic" products are actually tangible, shippable products.

What I would like, and what I believe is the correct behavior, is for "generic" items to be ignored when calculating shipping costs.

Incidentally, products categorized as "donations," when in the same cart as "tangible" items also exhibit this behavior.

(I know that there were several CVS updates today (6/22/2005), and this bug may have been resolved with those, but I'm away from my testing machine and wanted to get this filed.)

CommentFileSizeAuthor
#16 shippable.patch629 bytesbjornarneson

Comments

bjornarneson’s picture

Regarding my comment above, this bug is still effective with the latest 4.6 maintenance release (as of 6/23/2005).

bjornarneson’s picture

Any ideas about this issue?

matt westgate’s picture

Assigned: Unassigned » matt westgate

This is indeed a bug. Assigning this to myself.

bjornarneson’s picture

Matthias,

Is this bug fixable in the 4.6 release? I'm willing to send some funds1 your way to bring this issue to the top of your "to-do" list.

1 This functionality is needed by my non-profit [read: cash-poor] employer (homepage at http://nlca.com).

moshe weitzman’s picture

it seems that shipping module is required even for a donation only site. without it, i see "Fatal error: Call to undefined function: shipping_calculate_cost() in /home/weitzman/contributions/modules/ecommerce/cart/cart.module on line 264".

a donation is not tangible (at least on this site), and thus I don't need to collect shipping info. same for address.module. i don't need it, but i get error sif not enabled - "Call to undefined function: address_get_address() in /home/weitzman/contributions/modules/ecommerce/cart/cart.module on line 474"

bjornarneson’s picture

The scope of this bug seems to be expanding in the 4.6 ecommerce package.

With today's ecommerce.tar.gz, shipping calculations/costs are now being applied to *all* items, regardless of whether they are "non-shippable" or "donation", etc.... This behavior occurs even when non-shippable or donation items are the only ones in the cart.

arthurf’s picture

Title: generic/donation items affecting shipping costs » Turn on address module! generic/donation items affecting shipping costs

I had this problem, then I turned on the address module and things started working again. It would be nice if we could "group" the ecommerce modules together- perhaps make a prefix for them so that it would be obvious that some are needed to have the store functionality.

bjornarneson’s picture

Title: Turn on address module! generic/donation items affecting shipping costs » generic/donation items affecting shipping costs

I have the address module turned on. Can't seem to shake this bug.

cparrish817’s picture

I'm running into the same bug. a donation of $25.00 is showing a total of $30.00. Also for me the order isn't making it all the way though.

cparrish817’s picture

I was able to solve this by keeping the shipping mod enabled but setting it to not calculate shipping.

bjornarneson’s picture

What then if I have tangible/shippable items that require shipping charges?

alext-1’s picture

Is there a possible time line on this? will there be a fix for this on 4.6?

alext-1’s picture

I am not getting an error on drupal 4.6.5, only 4.7 with generics... I will be using 4.6.5 thx

bjornarneson’s picture

OK. I'm no php whiz, but it doesn't look to me like the following function, located at line 330 of shipping.module 4.6 accounts for any way to determine whether $item is shippable. Can someone smarter check on this?

function shipping_calculate($items) {

  $type = variable_get("shipping_method", "");
  $pivot_element = 0;
  $cost = 0;

  if ($type == "subtotal") {
    foreach ($items as $item) {
      $pivot_element += $item->qty * $item->price;
    }
  }
  else {
    foreach ($items as $item) {
      $pivot_element += $item->qty;
    }
  }

  $function = $type. "_load";
  $ship = $function();
  $numset = count($ship['ship_item_slot']);
  for ($i = 0; $i < $numset; $i++) {
    $item       = $ship['ship_item_slot'][$i];
    $price      = $ship['ship_price_slot'][$i];

    /* Check for range match */
    if (strstr($item, '-')) {
      list($low, $high) = explode('-', $item);
      if ($pivot_element >= $low and $pivot_element <= $high) {
        $cost = $price;
      }
    }
    /* Check for exact item quantity match */
    elseif ($item == $pivot_element) {
      $cost = $price;
    }
  }

  return $cost;
}
bjornarneson’s picture

I think I've fixed this bug!

Replace the entire IF/ELSE function at line 330 in shipping.module with this code:

if ($type == "subtotal") {
    foreach ($items as $item) {
      if (product_is_shippable($item->nid)) {
        $pivot_element += $item->qty * $item->price;
      }
    }
  }
  else {
    foreach ($items as $item) {
      if (product_is_shippable($item->nid)) {
        $pivot_element += $item->qty;
      }
    }
  }

Basically, without the check to if(product_is_shippable), *all* items in the cart, regardless of their "shippability" were being added to the $pivot_element total.

Sorry, I don't know how to properly generate a patch. Hopefully somebody will be able to whip this up and get it committed.

bjornarneson’s picture

Status: Active » Needs review
StatusFileSize
new629 bytes

OK. So I did a little homework and have submitted my first patch.... See attached. This patch is for Ecommerce 4.6.

gordon’s picture

Version: 4.6.x-1.x-dev » master
Status: Needs review » Fixed

Commited to cvs

Anonymous’s picture

Status: Fixed » Closed (fixed)