[ic] Shipping label printer

Jason Kohles email@jasonkohles.com
Thu, 15 Feb 2001 16:36:33 -0700

Here is a little code and some instructions on how to add a link to the view
order page, which prints a shipping label on a Dymo LabelWriter
(http://www.dymo.com/) connected to your computer when you click it.

First, you need to create a label template...
  Launch 'Dymo Label' (the software that came with the label printer).
  Select 'File->New Label' from the menu.
  Pick the right label type for the kind of labels you are using.
  Using the design tools available, add whatever information you want to the
    label, but make sure that it contains one, and only one 'Address' object,
    this is where the address will be filled in when printing labels (just use
    'Text' objects for return addresses, not 'Address' objects.
  Select 'File->Save As' from the menu.
  Enter a file name, and make sure it is being saved as a template (.LWT), also
    make sure you know the complete path to where the template is being saved,
    you will need it in a minute.  If you will be printing labels from more
    than one computer, they all need to have this template saved in the exact
    same location.

Next you need to configure interchange...
  Apply the patch below to lib/UI/pages/admin/order_view.html
  Go to the admin section of your store.
  Click 'Administration'.
  Click 'Knar'.
  Click 'New Entry'.
  Enter 'SHIPPING_LABEL' under 'Variable name'.
  Enter the path to your label template under 'Variable'.
    (something like: 'C:\Program Files\Dymo Label\Label Files\yourlabel.LWT')
  Enter 'Shipping' under 'Preferences area'.
  Restart interchange.

Last, you need to configure internet explorer to allow this...
  Launch Internet Explorer.
  Select 'Tools->Internet Options' from the menu.
  Click the 'Security' tab.
  Click 'Trusted Sites'.
  Click the 'Sites...' button.
  Uncheck 'Require server verification for sites in this zone'.
  Add 'http://yourservername/yourstore.cgi/admin' to the zone.
  Click 'OK'.
  Click 'Custom Level...'
  Set 'Initialize and script ActiveX controls not marked as safe' to 'enable'.
  Click 'OK'.
  Click 'OK' again.

You are done!  Now when you view an order in the admin section, there ill
be a link underneath the shipping address that will print a label to your
labelwriter when you click on it.

*** order_view.html	Mon Nov  6 10:42:25 2000
--- order_view.html.new	Thu Feb 15 15:22:33 2001
*** 161,166 ****
--- 161,181 ----
  [scratch ship_address]
+ [if variable SHIPPING_LABEL]
+ Sub Btn1_onclick()
+ Dim DymoAddIn, DymoLabel
+ Set DymoAddIn = CreateObject("DYMO.DymoAddIn")
+ Set DymoLabel = CreateObject("DYMO.DymoLabels")
+ DymoAddIn.Open "__SHIPPING_LABEL__"
+ DymoLabel.SetAddress 1,[perl]my @l = (); foreach(split("\n",$Scratch->{'ship_address'})) { s/"//g; s/\<br\>//gi; next unless $_; push(@l,"\"$_\""); }; join("+chr(10)+",@l);[/perl]
+ DymoAddIn.Print 1, TRUE
+ End Sub
+ (<A HREF="#" onClick="Btn1_onclick()">print shipping label</A>)
+ [/if]

Jason S Kohles                 (801)322-5512
jason@jasonkohles.com          http://www.jasonkohles.com/