Author Topic: DHL Shipping and printing shipping labels  (Read 83243 times)

durian

  • Beginner
  • *
  • Posts: 49
DHL Shipping and printing shipping labels
« on: January 04, 2006, 18:10:59 pm »
I'm working on a DHL shipping module.  I've got the shipping rate estimates pretty much working (one
outstanding question regarding international shipments), but would like to extend things a bit.

The DHL XML API also provides a mechanism for printing shipping labels.  I thought it might be useful
to implement that too, but I think I'm going to need an extra database table to do it properly and
databases just aren't my thing.

In order to properly print a label, I need to record some information about the shipping rate selected
by the customer.  This way I'll be able to correctly print a label that matches the shipping estimate,
even if some configuration values change.  In particular, I need to track shipping method, special services,
duty rate, insurance rate, domestic/international (I could recompute this, but if I'm recording the other
information I might as well record this too).  The actual address I can pull out of _order_user_info.

I had initially though to stick this information into shipping_rate_id, but that's not persistant, is it?

Then I've got to figure out what to do with the label image that comes back from DHL.  Again, I think
I'll need to stick this in a database so it can be view and reprinted later if necessary.  I'll also need to
store the waybill number along with the image so the label can be voided.

So those are my database issues.  If anyone can provide any advice on how to set up the table and
populate it, I'd be much appreciative.  I think it would need to be done through some script so any
other VirtueMart user's wanting to use the DHL module could easily integrate it into their system.
Even better would be an "official" new database table for this sort of thing, as I wouldn't be surprised
if other shipping methods can be expanded to print shipping labels.

Then there are the user interface issues.  I think I'll need to add Print Label and Void Label actions
to the orderinformation screen.  I can probably muddle through this, but advice might help.

The last step will involve getting the image into a pop-up window so the browser can print it.  Like
my database skills, my HTML skills are lacking.  I do think the image data needs to be inlined somehow.
Or failing that, there needs to be a way to detect when the user is done viewing/printing the label
so the temporary file containing the image can be removed - even if the user's browser closes accidentally.
We don't want any image files slowly eating up disk space.  Inline data seems like the best bet to me,
but as I said, I don't really know the ins-and-outs of this type of HTML.

Thanks,
mike

durian

  • Beginner
  • *
  • Posts: 49
Re: DHL Shipping and printing shipping labels
« Reply #1 on: January 05, 2006, 21:42:18 pm »
Following up to my own post.

I have resolved most of my issues except one, so my question is a bit more focused.
I need a way of accessing an html/something.php file that will return raw PNG data.
I will be using it as the img src URL of the shipping label image.

If I try hardcoding the URL directly, I just get dumped at my site's home page.  I assume
this is because I'm missing session information or something.  So then I tried using
$sess->url() to generate my URL, but it throws a lot of extra HTML into the output before
my script even gets a chance to write the raw PNG data.

So, How do I generate a URL to my script that won't prepend any extraneous HTML
(or append either - I don't want the "Check for latest VirtueMart" stuff either)?

Thanks,
mike

antcomp

  • Beginner
  • *
  • Posts: 25
Re: DHL Shipping and printing shipping labels
« Reply #2 on: January 18, 2006, 01:23:06 am »
I'm just wondering. How will this work with the label printing? will it ask the customer to print the label or will it show up in the admin panel or in your account on DHL.com? If it shows up after the customer places an order and asks them to print it don't bother it makes no scence to do this. I think it may be for large companies with a DHL ship server so the can do it all automated.

durian

  • Beginner
  • *
  • Posts: 49
Re: DHL Shipping and printing shipping labels
« Reply #3 on: January 18, 2006, 01:41:51 am »
You print a label from the administration area.  When you are viewing orders, if the customer selected DHL shipping for his order, you (as an administrator) will have the option of printing the DHL label.  You can then stick it on your package and either call DHL for pick-up or drop it in a DHL box somewhere.  You can also track shipments from the labels you create.

mike

deneb

  • Sr. Member
  • ****
  • Posts: 654
Re: DHL Shipping and printing shipping labels
« Reply #4 on: January 18, 2006, 04:00:51 am »
Hey durian, have you found a solution yet? I'd like to see this mod in the next VM!

maybe this'l help...

Quote
$sess->url() to generate my URL, but it throws a lot of extra HTML into the output before
my script even gets a chance to write the raw PNG data.

All $sess->url() does is append the "option=com_virtuemart" and "Itemid=X" to the supplied url. So, your code is probably not set up for the resulting output from that function.

Quote
So, How do I generate a URL to my script that won't prepend any extraneous HTML
(or append either - I don't want the "Check for latest VirtueMart" stuff either)?

I assume you want just a clean new window without any Joomla or VM headers/footers? make the link to the pop-up window (with just the label showing) by creating your html page that pulls the image out of your DB and displays it first.

then try using a java link to your script page (window.open)  and use index2.php as the main page. like so:
Code: [Select]
a href="javascript:void window.open(\'<?php echo $mosConfig_live_site."/index2.php?page=script_page...
**see attached file as an example of a full java link that I use in my custom mods/hacks.
(this forum chops html code...so i put in file)

Just substitute "script_page" in the "page=script_page" parameter to your file (without the suffix) in the /html folder for the VM component. Notice the "menubar=yes" param, so you can access your browser print menu stuff.

Also see my hack for a "Top Products" report. It has a java "Print View" link like the above...
http://virtuemart.net/index.php?option=com_smf&Itemid=71&topic=14666.0

durian

  • Beginner
  • *
  • Posts: 49
Re: DHL Shipping and printing shipping labels
« Reply #5 on: January 18, 2006, 16:23:39 pm »
The code is mostly done.  I just need to do a bit more testing and finish the signature retrieval bit (part of tracking).  DHL doesn't have a test case for signature retrieval, so I'm waiting for an order to come in on our new site that uses DHL.  Once I get a real tracking number and the package gets delivered, I'll be able to finish the signature bit.

I've sent some preliminary code to Soeren, since there are a number of patches to the base system code and a new database.  I'll release the code to the general masses when I finish that signature stuff.

I did figure out my problem with pop-up windows and HTML-less data.  The trick to the later is to add no_html=1 to the URL and also tweak admin.virtuemart.php to observe the flag (without a patch it ignores the no_html setting and appends a footer).

mike

mike

Soeren

  • Administrator
  • Hero Member
  • *
  • Posts: 3106
  • VirtueMart Starter
    • virtuemart.net
Re: DHL Shipping and printing shipping labels
« Reply #6 on: January 18, 2006, 20:35:12 pm »
I'm sure that this module sets a new level for shipping modules in general for VirtueMart.
It's a good idea to implement the changes from durian's DHL implementation, so other shipping modules can be used that comfortable too.

ciao, Soeren
The future of eCommerce: VirtueMart & Joomla!
http://virtuemart.net

antcomp

  • Beginner
  • *
  • Posts: 25
Re: DHL Shipping and printing shipping labels
« Reply #7 on: January 19, 2006, 05:18:17 am »
You print a label from the administration area.  When you are viewing orders, if the customer selected DHL shipping for his order, you (as an administrator) will have the option of printing the DHL label.  You can then stick it on your package and either call DHL for pick-up or drop it in a DHL box somewhere.  You can also track shipments from the labels you create.

mike

Thats a nice feature! it will make it eaiser to process shippments (no more paperwork). Keep up the good work, I agree with Soren this would be great for the next release

durian

  • Beginner
  • *
  • Posts: 49
Re: DHL Shipping and printing shipping labels
« Reply #8 on: January 24, 2006, 18:45:48 pm »
Here's a starting point for the DHL module.  I have been testing with it and it seems to be working, but it is a bit more complex than other shipping modules and I'm sure there are still issues. Also, keep in mind that I implemented this DHL module to meet my needs.  My needs are almost certainly not the same as your needs. You might need to customize things a bit to meet your requirements.

There is a README inside that tarball that explains what the DHL module does and what the files in the tarball do.  It also covers the steps involved in getting certified by DHL.  I wish that process were simpler. To get certified, you will need to create test cases and make small modifications to the code (uncomment some debugging lines). You'll also need to manually adjust your database to insert special tracking numbers for testing.  I've found phpMyAdmin to be useful in this task.

Here's a portion of the README that covers what the DHL module does:

  • Prints shipping labels.  There is a new function available on the Order List page.  If an order was placed using DHL (or in general, if a shipping module supporting print labels), you can click on a link to display a image of a DHL shipping label that you can then print and use.
  • Voids shipping labels.  Related to printing shipping labels.  If you've created a label and then need to void it, you can do that.
  • Tracking.  You can track any labels you've created.
  • Signature Retrieval.  When you track a package, if it has been delivered, you'll also see the delivery signature.  Or delivery codes if the package was left without a signature.
  • Domestic and International.  The DHL module supports both domestic (meaning US - the DHL API is US centric) and international shipping.
  • Duty values that are different from the retail price of an order.  International shipments require duties.  Sometimes you are shipping an item that cost significantly more that the value of the tangible good.  Software might be an example: you might charge a fair amount for software, but the value of the item you ship is just a burned CD-ROM, a printed manual and maybe a dongle or something.  You might want to calculate duties on just the physical goods.

    The duty value is calculated by defining a special Shopper Group for duty prices.  The DHL module will look for a price using this group (which you can define) and use that price if found.  If a special duty price is not found, it use the normal retail price.
  • Insurance values.  Similar to duty values.  A special shopping group is used to hold the insurance value for a given item.  If the sum of the insurance on all the goods is greater than the default insurance value (configurable) the insurance is used when generating the shipping label.  This applies to both domestic and international.
  • Too late.  You can set a time at which it is too late for items to ship the same day.  This also affects if Saturday Delivery is available as a shipping option.  If it is too late to go out on a Thursday, the Saturday delivery option is listed just as if it were a Friday.
  • Configurable list of shipping options.  You can select which domestic and international shipping options are available.  Express, Next Afternoon, Second Day, Ground, Express 10:30am, Saturday Delivery and International Express.
  • Packaging weight.  You can configure a value that is added to the weight of the individual items to cover the packaging weight.

mike

durian

  • Beginner
  • *
  • Posts: 49
Re: DHL Shipping and printing shipping labels
« Reply #9 on: January 25, 2006, 22:11:31 pm »
Good news.  The DHL people say other users of this shipping module do not need to go through the certification process.  It is sufficient that you tell them you are using the "VirtueMart DHL shipping module originally authored by Mike Durian."  This will take a lot of the pain out of getting up and running.

I have also updated the tarball to include an ApplicationForm.doc file.  After creating a normal DHL shipping account on DHL's website, fill out this form and mail it to XMLRequests@dhl.com and mention you are using this shipping module.  They'll send you an ID, password and shipping keys.  Much less painful than sending them sample XML requests for each transaction type.

I have updated the README file to reflect the simplified procedure.

mike

deneb

  • Sr. Member
  • ****
  • Posts: 654
Re: DHL Shipping and printing shipping labels
« Reply #10 on: January 26, 2006, 02:12:02 am »
Durian,
You r the man!

Good to see coders actively working on expanding this project. :)

durian

  • Beginner
  • *
  • Posts: 49
Re: DHL Shipping and printing shipping labels
« Reply #11 on: January 27, 2006, 19:08:00 pm »
DHL has provided an application form specific for VirtueMart users.  The form replaces the one in the tarball.

So, who ever is adding this DHL code to VirtueMart, can you please include this DHL application form, not the other one.  And for any of you who are already patching your own source tree to add DHL shipping, please use this application form.

Thanks,
mike

holsum

  • Beginner
  • *
  • Posts: 45
Re: DHL Shipping and printing shipping labels
« Reply #12 on: February 08, 2006, 18:20:22 pm »
Mike,
   How difficult would it be to convert this into a Fedex ship and print module?  I have a very keen interest in getting this done and would be willing to "do my part" to get this feature implemented for Fedex. 

-Holsum

durian

  • Beginner
  • *
  • Posts: 49
Re: DHL Shipping and printing shipping labels
« Reply #13 on: February 08, 2006, 18:35:50 pm »
I don't have a clue what would be involved in adding similar features to the FedEx shipping module.  I have no knowledge of the FedEx API.  When I wrote the DHL module, I tried to generalize the label database such that other modules could also use it, but it's difficult to generalize from a single data point.  The label database might or might not meet your needs when you start modifying the FedEx module.  I also tried to create a structure for the label functions in the DHL so that their definition might translate to other modules.  But, as they say, your mileage may vary.  The README file with the DHL code might help explain what the DHL label functions do.

And, of course, a key factor in adding label support to the FedEx module will be what features FedEx makes available to you through their API.

I guess I'd recommend you get all the information you can from FedEx on their API and come up to speed on it.  Then start reading the DHL code and README file and see if there are any similarities.

While I can answer specific questions about the DHL code, I afraid you're on your own when it comes to adding new features to the FedEx module.  I'm pretty swamped with my normal work and don't really have need for a FedEx module myself since I have the DHL stuff.  But if you have questions regarding why I did something a certain way in the DHL module, I'll be glad to field them.

mike

holsum

  • Beginner
  • *
  • Posts: 45
Re: DHL Shipping and printing shipping labels
« Reply #14 on: February 14, 2006, 00:15:32 am »
Dorian,
   How do you instal your DHL shipping madule?  Is it a manual install or is there a UI within virtuemart that I am supposed to use?
-Holsum

VirtueMart Forum

Re: DHL Shipping and printing shipping labels
« Reply #14 on: February 14, 2006, 00:15:32 am »