Product packages: some products ship all in one box, some in individual boxes

Posts: 55
Joined: 08/17/2007

I have several products that are shipped in their individual package, but I also have some products that ship in one box if someone orders multiple quantities. Is there a way to choose this shipping option for certain products? If a person attempts to order 10 small items from my store the UPS quote is around $40 when the actual price is around $15.

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

In the product edit form, there is a field called "Package quantity". This field tells the shipping modules how many of that product fit into one package. The UPS module (and others like it) will make a quote for as many boxes as needed to hold those products. Note that each quoted package contains one type of product. If you put lots of different things into one package, you may try the setting in the UPS quote method page. This can significantly underestimate your shipping costs if the customer buys the wrong things, so test it out a bit before you decide to use it.

Posts: 55
Joined: 08/17/2007

Thanks Lyle, but it appears the UPS module doesn't seem to like the package field very much. I get this error when I try grouping some of my products into a package of 5, 10, 20, and 50.

<?xml version="1.0"?>
<RatingServiceSelectionResponse>
  <Response>
    <TransactionReference>
      <CustomerContext>
        Complex Rate Request
      </CustomerContext>
      <XpciVersion>
        1.0001
      </XpciVersion>
    </TransactionReference>
    <ResponseStatusCode>
      0
    </ResponseStatusCode>
    <ResponseStatusDescription>
      Failure
    </ResponseStatusDescription>
    <Error>
      <ErrorSeverity>
        Hard
      </ErrorSeverity>
      <ErrorCode>
        10002
      </ErrorCode>
      <ErrorDescription>
        The XML document is well formed but the document is not valid
      </ErrorDescription>
      <ErrorLocation>
        <ErrorLocationElementName>
          RatingServiceSelectionRequest/Shipment/Package
        </ErrorLocationElementName>
      </ErrorLocation>
    </Error>
  </Response>
</RatingServiceSelectionResponse>

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

Alright, let's take a look at the Package, then.

Posts: 55
Joined: 08/17/2007

Ok

Package quantity: 50
Weight: 50
Units of measurement: Pounds
Units of measurement: Inches
12x6x6

Package type: Customer supplied package

<?xml version="1.0" encoding="UTF-8"?>
<RatingServiceSelectionRequest xml:lang="en-US">
  <Request>
    <TransactionReference>
      <CustomerContext>Complex Rate Request</CustomerContext>
      <XpciVersion>1.0001</XpciVersion>
    </TransactionReference>
    <RequestAction>Rate</RequestAction>
    <RequestOption>rate</RequestOption>
  </Request>
  <PickupType>
    <Code>01</Code>
  </PickupType>
  <Shipment>
    <Shipper>
      <ShipperNumber>[shipping number]</ShipperNumber>
      <Address>
        <City>Miami</City>
        <StateProvinceCode>FL</StateProvinceCode>
        <PostalCode>33178</PostalCode>
        <CountryCode>US</CountryCode>
      </Address>
    </Shipper>
    <ShipTo>
      <Address>
        <StateProvinceCode></StateProvinceCode>
        <PostalCode>33166</PostalCode>
        <CountryCode>US</CountryCode>
      </Address>
    </ShipTo>
    <ShipFrom>
      <Address>
        <StateProvinceCode>FL</StateProvinceCode>
        <PostalCode>33178</PostalCode>
        <CountryCode>US</CountryCode>
      </Address>
    </ShipFrom>
    <ShipmentWeight>
      <UnitOfMeasurement>
        <Code>LBS</Code>
      </UnitOfMeasurement>
      <Weight>0</Weight>
    </ShipmentWeight>
    <Service>
      <Code>12</Code>
      <Description>UPS 3-Day Select</Description>
    </Service>
    </Shipment>
</RatingServiceSelectionRequest>

I tried different Package quantity and weight combinations
Package quantity: 10
Weight: 50lbs

    <ShipmentWeight>
      <UnitOfMeasurement>
        <Code>LBS</Code>
      </UnitOfMeasurement>
      <Weight>500</Weight>
    </ShipmentWeight>

Package quantity: 50
Weight: 10lbs

    <ShipmentWeight>
      <UnitOfMeasurement>
        <Code>LBS</Code>
      </UnitOfMeasurement>
      <Weight>0</Weight>
    </ShipmentWeight>

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

OK, so the real problem is that there isn't a <Package> tag in the Request. That doesn't make sense to me though. I also don't see why the ShipmentWeight would be 500 pounds sometimes but 0 others.

Posts: 55
Joined: 08/17/2007

My apologies, I forgot to mention I was doing the checkout with 10 items. Thats why the shipping weight comes out to 500, there are 10 items each weighing in at 50 lbs.

Here are some more tests:

This works:
Items in Cart: 10
Package quantity: 10
Weight: 1

<ShipmentWeight>
  <UnitOfMeasurement>
    <Code>LBS</Code>
  </UnitOfMeasurement>
  <Weight>10</Weight>
</ShipmentWeight>
<Service>
  <Code>03</Code>
  <Description>UPS Ground</Description>
</Service>

<Package>
  <PackagingType>
    <Code>02</Code>
  </PackagingType>
  <Dimensions>
    <UnitOfMeasurement>
      <Code>IN</Code>
    </UnitOfMeasurement>
    <Length>12</Length>
    <Width>6</Width>
    <Height>6</Height>
  </Dimensions>
  <PackageWeight>
    <UnitOfMeasurement>
      <Code>LBS</Code>
      <Description>Pounds</Description>
    </UnitOfMeasurement>
    <Weight>10</Weight>
  </PackageWeight>
  <PackageServiceOptions>
    <InsuredValue>
      <CurrencyCode>USD</CurrencyCode>
      <MonetaryValue>79.9</MonetaryValue>
    </InsuredValue>
  </PackageServiceOptions>
</Package>

This does not work:
Items in Cart: 7
Package quantity: 10
Weight: 1
[Package] appears to be missing

    <ShipmentWeight>
      <UnitOfMeasurement>
        <Code>LBS</Code>
      </UnitOfMeasurement>
      <Weight>0</Weight>
    </ShipmentWeight>
    <Service>
      <Code>03</Code>
      <Description>UPS Ground</Description>
    </Service>
    </Shipment>
</RatingServiceSelectionRequest>

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

The problem's on line 802 of uc_ups.module. Change it to

<?php
      $remaining_qty
= $product->qty % $product->pkg_qty;
?>

to make it work right again.

Posts: 55
Joined: 08/17/2007

Odd, line 802 on my uc_ups.module is different. I have never once opened the module until now so it should be the same as the one released with alpha7e.

Lines 772-835 has the function uc_ups_fulfill_order_submit($form_id, $form_values){

Line 802:
     $_SESSION['ups']['ship_date'] = $form_values['ship_date'];

Line 504 has function uc_ups_quote in it which contains:

Line 542:
else{
543 foreach ($products as $product){
      if (!$product->pkg_qty){
        $product->pkg_qty = 1;
      }
      $num_of_pkgs = (int)($product->qty / $product->pkg_qty);
      if ($num_of_pkgs){
        $package = drupal_clone($product);
        $package->weight = $product->weight * $product->pkg_qty;
        $package->price = $product->price * $product->pkg_qty;
        $package->qty = $num_of_pkgs;
        $package->pkg_type = $product->ups['pkg_type'];
        $packages[] = $package;
      }
556   $remaining_qty = $product->qty % $product->ups['qty'];
      if ($remaining_qty){
        $package = drupal_clone($product);
        $package->description = $product->model;
560     $package->weight = $product->weight * $remaining_qty;
561        $package->price = $product->price * $remaining_qty;
        $package->qty = 1;
        $package->pkg_type = $product->ups['pkg_type'];
        $packages[] = $package;
      }
    }
  }

Do I replace line 556?

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

Yeah, change line 556. I've been working on the UPS module recently, and didn't think about the line numbers being different.