Forums / All Other Contributions/Addons / Programming Problem...Really Weird UPS Problem

Programming Problem...Really Weird UPS Problem

Started by g2ktcf on 2 May 2011, 4:36 PM · Views: 1,143

Results 1 to 7 of 7
2 May 2011, 4:36 PM
#1
g2ktcf avatar

g2ktcf

Totally Zenned

Join Date:
Feb 2011
Location:
Lumberton, TX
Posts:
635
Plugin Contributions:
0

Programming Problem...Really Weird UPS Problem

I have written several new classes for a much improved UPS shipping module. I have tested them with isolated scripts and they perform as expected. I have matched the return types with that from the ups.php getquote().

The new classes work for the checkout page Step 1 0f 3. However, ANY CHANGES AT ALL seem to prevent a successful Step 2 of 3. This only happens if you select one of the UPS shipping options. The entire new class script is run (used numerous echo commands to be sure) but the page never shows. The simple "require_once" statement below is enough to stop things from working even though the full class script executes. I am at a loss of where to go from here. The code works for shopping the rates, but will go no farther.

   if ($method) $this->_upsAction('3'); // return a single quote

    $this->_upsProduct($prod);

    // ups doesnt accept zero weight send 1 ounce (0.0625) minimum
    $ups_shipping_weight = ($shipping_weight <= 0 ? 0.0625 : $shipping_weight);

	require_once (DIR_WS_CLASSES . 'upsRateClass.php');

	$country_name = zen_get_countries(SHIPPING_ORIGIN_COUNTRY, true);
    $this->_upsOrigin(SHIPPING_ORIGIN_ZIP, $country_name['countries_iso_code_2']);
    $this->_upsDest($order->delivery['postcode'], $order->delivery['country']['iso_code_2']);
    $this->_upsRate(MODULE_SHIPPING_UPS_PICKUP);
    $this->_upsContainer(MODULE_SHIPPING_UPS_PACKAGE);
    $this->_upsWeight($ups_shipping_weight);
    $this->_upsRescom(MODULE_SHIPPING_UPS_RES);
    $upsQuote = $this->_upsGetQuote();
2 May 2011, 8:51 PM
#2
g2ktcf avatar

g2ktcf

Totally Zenned

Join Date:
Feb 2011
Location:
Lumberton, TX
Posts:
635
Plugin Contributions:
0

Re: Programming Problem...Really Weird UPS Problem

I am still learning.....

white spaces after ?> can create this. Had to clean up all the class files and now all is well....I can get back to work now!

I am not new to programming...just new to PHP. So I am still in the "stupid stage".

Symptoms....White page with no response. Looked in zencart/cache for myDEBUG error logs.

[02-May-2011 13:44:25] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/.../zencart/includes/classes/upsRateClass.php:289) in /home/...zencart/includes/functions/functions_general.php on line 45

Found the extra lines in upsRateClass.php line 289.

3 May 2011, 12:49 AM
#3
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,722
Plugin Contributions:
0

Re: Programming Problem...Really Weird UPS Problem

Thanks for posting the solution. You may have helped someone else in a similar situation.

Related FAQ: https://www.zen-cart.com/tutorials/index.php?article=87

Please do not PM for support issues: a private solution doesn't benefit the community.

Be careful with unsolicited advice via email or PM - Make sure the person you are talking to is a reliable source.

3 May 2011, 2:45 PM
#4
lankeeyankee avatar

lankeeyankee

Totally Zenned

Join Date:
Jan 2007
Posts:
1,514
Plugin Contributions:
1

Re: Programming Problem...Really Weird UPS Problem

I am really looking forward to seeing your work because we really need more sophistication to UPS than the current module offers including commercial/residential, negotiated rates, and dimensional input. Particularly curious how you have managed with the dimensional issue, does it figure out dimensions based on entire cart contents or just adding dimensional values together product by product?


Zen Cart and it's community are the best!!

3 May 2011, 3:02 PM
#5
g2ktcf avatar

g2ktcf

Totally Zenned

Join Date:
Feb 2011
Location:
Lumberton, TX
Posts:
635
Plugin Contributions:
0

Re: Programming Problem...Really Weird UPS Problem

lankeeyankee:

I am really looking forward to seeing your work because we really need more sophistication to UPS than the current module offers including commercial/residential, negotiated rates, and dimensional input. Particularly curious how you have managed with the dimensional issue, does it figure out dimensions based on entire cart contents or just adding dimensional values together product by product?

That is the tough part of the algorithm.....

  1. check the weight of the cart
  2. check the volume of the cart using product dimensions (go through the cart and do the math)
  3. If the total volume meets the "dimensional weight" requirements, then calculate the dimensional weight via UPS procedures (diff one for intl vs domestic)
  4. Compare the two and take the larger weight.
  5. Get the correct quote (neg, COM vs RES and so on).

Now the real killer is larger packages when the packages have to be different. I am thinking of a routine to split the cart into shippable blocks then run the quoting as a multi-package shipment. The XML side of my UPS class handles multiple packages (or did until I broke it yesterday). So I just need logic to "pack a box" lol. I have already added a table to the db for shipping boxes as most of us only use a few. Updates will come lol

3 May 2011, 7:36 PM
#6
rstevenson avatar

rstevenson

Totally Zenned

Join Date:
Nov 2006
Location:
Dartmouth, NS Canada
Posts:
2,400
Plugin Contributions:
0

Re: Programming Problem...Really Weird UPS Problem

I'm not sure if you've thought of this possibility...

Some stores sell large objects that are already boxed. A single item may ship in two or three separate boxes, so simply calculating the largest box that will hold all of the item, let alone all of an order that may contain more than one such item, won't work in those cases.

An example is a store I worked on last year which sells fountains. Each fountain may come with a base and maybe with a column, and possibly with a light, or a motor/pump, or both. And each of those partial items (some of which can't be sold separately) may already be in its own shipping container. So a single item order can end up being sent in two, three or even four boxes.

Did I make your day? :laugh:

Rob

Breakfast: the most important donut of the day.

3 May 2011, 7:55 PM
#7
g2ktcf avatar

g2ktcf

Totally Zenned

Join Date:
Feb 2011
Location:
Lumberton, TX
Posts:
635
Plugin Contributions:
0

Re: Programming Problem...Really Weird UPS Problem

rstevenson:

I'm not sure if you've thought of this possibility...

Some stores sell large objects that are already boxed. A single item may ship in two or three separate boxes, so simply calculating the largest box that will hold all of the item, let alone all of an order that may contain more than one such item, won't work in those cases.

An example is a store I worked on last year which sells fountains. Each fountain may come with a base and maybe with a column, and possibly with a light, or a motor/pump, or both. And each of those partial items (some of which can't be sold separately) may already be in its own shipping container. So a single item order can end up being sent in two, three or even four boxes.

Did I make your day? :laugh:

Rob

Actually, I have a boolean value in each product called "IsShipable". This is one item in the cart that can get a package by itself.