Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / How do I pass the Shipping Address into the shipping module?

How do I pass the Shipping Address into the shipping module?

Locked

Views: 907

Results 1 to 2 of 2
This thread is locked. New replies are disabled.
10 Feb 2009, 10:21 AM
#1
lightnb avatar

lightnb

New Zenner

Join Date:
May 2008
Posts:
17
Plugin Contributions:
0

How do I pass the Shipping Address into the shipping module?

Hi everyone,

I've created a new Page Module (By creating a folder in "includes/modules/pages", and adding a "header_php.php" file there.)

It loads when I go to "index.php?main_page=my_page".

On that page, I would like to display rate quotes from the installed shipping modules. (Code listed below)

I'm getting errors back from the shipping APIs, because I haven't set the shipping address anywhere.

UPS:

We are unable to obtain a rate quote for UPS shipping.
Please contact the store if no other alternative is shown.

USPS:

-2147219080 - Missing value for Country.

I have the full shipping address already, in a variable. What I don't know, is how to pass that variable into the shipping class (or wherever it needs to go) to make it work.

I'm using this code:

function GetShippingMethods()
{   
   
// $MyZip = '12345';
// $MyCountry = 'Some Country';
// etc...
// Somehow, I need to setup the shipping address here, 
// so that the shipping module can find it!

   $total_weight = $_SESSION['cart']->show_weight();
   $total_count = $_SESSION['cart']->count_contents();   
   
   // load all enabled shipping modules
   require_once(DIR_WS_CLASSES . 'http_client.php');
   require(DIR_WS_CLASSES . 'shipping.php');
   $shipping_modules = new shipping;
   
   $Quotes = $shipping_modules->quote();
   foreach($Quotes AS $Quote)
   {            
      $HTML .= '<div style="border:1px solid gray; margin:10px;">';
      if(isset($Quote['error']))
      {
         $HTML .= $Quote['error'];
      }
      else
      {
         $HTML .= $Quote['module'];
         foreach($Quote['methods'] AS $Method)
         {
            $HTML .= $Method['cost'] . $Method['title'] . $Method['id'];        
         }
      }
      $HTML .= '</div>';
   }
   echo 'var HTML = "'.rawurlencode($HTML).'";';
}

Thanks,

Nick

17 Feb 2009, 10:49 PM
#2
lightnb avatar

lightnb

New Zenner

Join Date:
May 2008
Posts:
17
Plugin Contributions:
0

Re: How do I pass the Shipping Address into the shipping module?

  • bump *