Post by ncrsystems » Fri Sep 10, 2010 2:08 pm

Hi,

this is my first post here and i hope someone can help :]

im in the proccess of setting up an online store for my business, and i need to ship via tnt post, i have a shipping module, the only thing is, it was made for 1.3.4, and i am running 1.4.9. i go onto the dashboard and go to edit it, and i get the error
Fatal error: Call to a member function http() on a non-object in /home/ncrsys/public_html/ncrsystems.com.au/admin/controller/shipping/tntpost.php on line 79
what can i do, i really need this to work on 1.4.9 or im screwed.

Thank you all!

ive uploaded the extension if anyone needs to look at it.

Attachments

TNT Shipping Module (Australian)


Newbie

Posts

Joined
Fri Sep 10, 2010 1:58 pm
Location - Australia

Post by yiannipapz95 » Sun Sep 19, 2010 11:22 am

The person that made this linked common/home when it isn't even installed with OpenCart?
Where did you get this from?

Newbie

Posts

Joined
Fri Aug 13, 2010 10:46 pm

Post by yiannipapz95 » Sun Sep 19, 2010 11:32 am

Upload this http://solidfiles.com/d/d12d/ . It should solve your problem, but I removed 'common/home' in tntpost.php . I'm not sure if it was anything important, but if it causes any problems, don't hold me responsible :|.

Newbie

Posts

Joined
Fri Aug 13, 2010 10:46 pm

Post by ncrsystems » Mon Sep 20, 2010 11:21 pm

excellent thanks for that, i can now modify it properly, i have also modified some other files so it would work when saving settings ect. i have ran into a problem tho, when it gets to the checkout page that shows shipping cost i get an error at the top of the page
Warning: Missing argument 2 for ModelShippingTntpost::getQuote(), called in /home/ncrsys/public_html/ncrsystems.com.au/catalog/controller/checkout/guest_step_2.php on line 107 and defined in /home/ncrsys/public_html/ncrsystems.com.au/catalog/model/shipping/tntpost.php on line 21Warning: Missing argument 3 for ModelShippingTntpost::getQuote(), called in /home/ncrsys/public_html/ncrsystems.com.au/catalog/controller/checkout/guest_step_2.php on line 107 and defined in /home/ncrsys/public_html/ncrsystems.com.au/catalog/model/shipping/tntpost.php on line 21Notice: Undefined variable: zone_id in /home/ncrsys/public_html/ncrsystems.com.au/catalog/model/shipping/tntpost.php on line 33Notice: Undefined index: shipping_address_id in /home/ncrsys/public_html/ncrsystems.com.au/catalog/model/shipping/tntpost.php on line 55Notice: Undefined variable: postcode in /home/ncrsys/public_html/ncrsystems.com.au/catalog/model/shipping/tntpost.php on line 61
my tnt post account is in the proccess of being finalised "waiting on them", could this be the cause?

Newbie

Posts

Joined
Fri Sep 10, 2010 1:58 pm
Location - Australia

Post by dyl4n3 » Thu Sep 23, 2010 9:01 pm

i tried the above and it didnt work :(

Newbie

Posts

Joined
Sat Sep 11, 2010 2:13 pm

Post by ncrsystems » Thu Sep 23, 2010 9:35 pm

okay i have managed to get the error down to this
Notice: Undefined variable: country_id in /home/ncrsys/public_html/ncrsystems.com.au/catalog/model/shipping/tntpost.php on line 43Notice: Undefined index: shipping_address_id in /home/ncrsys/public_html/ncrsystems.com.au/catalog/model/shipping/tntpost.php on line 46Notice: Undefined variable: postcode in /home/ncrsys/public_html/ncrsystems.com.au/catalog/model/shipping/tntpost.php on line 52
the code from line 40 to 54 is:

Code: Select all

      if ($status) {
        
        $this->load->model('localisation/country');
        $country_info = $this->model_localisation_country->getCountry($country_id);

        $this->load->model('account/address');
        $shipping_address = $this->model_account_address->getAddress($this->session->data['shipping_address_id']);        
        
        $quote_data = array();
      
        $error = FALSE;

        if (! preg_match('/^[0-9]{4}$/', $postcode)) {
          $error = 'Your postcode is not valid in Australia';
        } else {

is that coded wrong or whats the deal with it? anyone?

cheers!

Newbie

Posts

Joined
Fri Sep 10, 2010 1:58 pm
Location - Australia

Post by ncrsystems » Thu Sep 23, 2010 10:02 pm

ive edited the code hoping to get rid of the error, i think all the errors are gone now, but when i try to calculate shipping i get the error: 004 The account number supplied is invalid or not assigned to this login.

heres a pic

Image

my account details are all correct..

ive attached the TNT API i got a copy of.

also this is the full code that im trying to fix:

Code: Select all

<?php
/**
 * TNT Express Post Shipping Module for OpenCart v1.3.4}$/
 *
 * @package OpenCart
 */
/**
 * TNTPost Model
 */
  class ModelShippingTntpost extends Model {

/**
 * Return quotation details across all TNT shipping methods
 *
 * @param int $country_id
 * @param int $zone_id
 * @param int $postcode
 * @return array Quotation details
 */
	function getQuote($address) {
		$this->load->language('shipping/tntpost');
		
		if ($this->config->get('tntpost_status')) {
      		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('tntpost_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");
		
      		if (!$this->config->get('tntpost_geo_zone_id')) {
        		$status = TRUE;
      		} elseif ($query->num_rows) {
        		$status = TRUE;
      		} else {
        		$status = FALSE;
      		}
		} else {
			$status = FALSE;
		}

		$method_data = array();
      
      if ($status) {
			$this->load->model('localisation/country');

			$quote_data = array();

        if (!preg_match('/^[0-9]{4}$/', $address['postcode'])) {
          $error = 'Your postcode is not valid in Australia';
        } else {


          // tomorrow morning, 9am
          $tomorrow = mktime('9', 0, 0 ,date('m'), date('d') + 1, date('Y'));
          // is it a weekend?
          if (date('D', $tomorrow) == 'Sat') {
            $add_days = 2;
          } elseif (date('D', $tomorrow) == 'Sun') {
            $add_days = 1;
          } else {
            $add_days = 0;
          }
          
          $ship_date = date('Y-m-d', $tomorrow + (3600 * 24 * $add_days));
          $timestamp = date('Y-m-d\TH:i:s', time());

    // start to build XML
    $Xml = '
    <enquiry xmlns="https://www.tntexpress.com.au/interaction/asps/login.asp">
      <ratedTransitTimeEnquiry>
        <cutOffTimeEnquiry>
          <collectionAddress>
            <suburb>'.$this->config->get('tntpost_collect_suburb').'</suburb>
            <postCode>'.$this->config->get('tntpost_collect_pcode').'</postCode>
            <state>'.$this->config->get('tntpost_collect_state').'</state>
          </collectionAddress>
          <deliveryAddress>
            <suburb>' . $shipping_address['city'] . '</suburb>
            <postCode>' . $shipping_address['postcode'] . '</postCode>
            <state>' . $shipping_address['zone_code'] . '</state>
          </deliveryAddress>
          <shippingDate>'.$ship_date.'</shippingDate>
          <userCurrentLocalDateTime>' . $timestamp . '</userCurrentLocalDateTime>
          <dangerousGoods>
            <dangerous>false</dangerous>
          </dangerousGoods>
          <packageLines packageType="N">';
        
          foreach ($this->cart->getProducts() as $product) {
            $option_data = array();

    $Xml .= '
          <packageLine>
              <numberOfPackages>'.$product['quantity'].'</numberOfPackages>
              <dimensions unit="cm">
              <length>'.round($product['length'] == '0' ? '70' : $product['length']).'</length>
              <width>'.round($product['width'] == '0' ? '70' : $product['width']).'</width>
              <height>'.round($product['height'] == '0' ? '70' : $product['height']).'</height>
              </dimensions>
              <weight unit="kg">
              <weight>'.round($product['weight']).'</weight>
              </weight>
            </packageLine>';
            
          }
     
    $Xml .= '
        </packageLines>
      </cutOffTimeEnquiry>
      <termsOfPayment>
        <senderAccount>'.$this->config->get('tntpost_tnt_customer_code').'</senderAccount>
        <payer>S</payer>
      </termsOfPayment>
    </ratedTransitTimeEnquiry>
  </enquiry>';

            $Request = rawurlencode($Xml);
            $CurlURL = 'https://www.tntexpress.com.au/Rtt/inputRequest.asp';
            $CurlQuery = 'Username='.$this->config->get('tntpost_tnt_user').'&Password='.$this->config->get('tntpost_tnt_password').'&XMLRequest=' . $Request;
            $ch = curl_init();
               
            curl_setopt($ch, CURLOPT_URL, $CurlURL);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $CurlQuery);
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION  ,1);
            curl_setopt($ch, CURLOPT_HEADER, 0);  // DO NOT RETURN HTTP HEADERS
            curl_setopt($ch, CURLOPT_RETURNTRANSFER  ,1);  // RETURN THE CONTENTS OF THE CALL
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // Needs to be included if no *.crt is available to verify SSL certificates
            curl_setopt($ch,CURLOPT_SSLVERSION,3);  
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

            $result = curl_exec($ch);
            curl_close($ch);
            
            if ($result) {
              ## catch libxml errors
              libxml_use_internal_errors(true);
              $quote_xml = @simplexml_load_string($result);
              
              if ($quote_xml) {

                ## process error from TNT
                if (isset($quote_xml->error)) {
                  $error = $quote_xml->error->code . ' ' . $quote_xml->error->description;
                } else {

                  // did we get any ratings?
                  if (isset($quote_xml->ratedTransitTimeResponse->ratedProducts)) {
                    foreach($quote_xml->ratedTransitTimeResponse->ratedProducts->ratedProduct as $option) {
                  
                      ## send quote data for enabled modules
                      if ($this->config->get('tntpost_' . $option->product->code)) {
                        $quote_data['tntpost_' . $option->product->code] = array(
                          'id'           => 'tntpost.tntpost_' . $option->product->code,
                          'title'        => (string)($option->product->description),
                          'cost'         => (string)$option->quote->price,
                          'tax_class_id' => $this->config->get('tntpost_tax_class_id'),
                          'text'         => '$' . sprintf('%.2f', ($this->tax->calculate((string)$option->quote->price, $this->config->get('tntpost_tax_class_id'), $this->config->get('config_tax')))),
                          'estimated_delivery_date' => ($this->config->get('tntpost_display_estimate') ? date('l, jS F', strtotime($option->estimatedDeliveryDateTime)) : false)
                        );
                      }
                    
                    }            
                  } else {
                    // no ratings, process broken rules
                    
                    if (isset($quote_xml->ratedTransitTimeResponse->brokenRules)) {
                      $error = $quote_xml->ratedTransitTimeResponse->brokenRules->brokenRule->description;
                    } else {
                      $error = 'An undetermined error has occurred. Please check TNT module configuration.';
                    }
                  
                  
                  }
                }
                  
                  
              } else {           

                  $error = "Failed loading XML";
                  foreach(libxml_get_errors() as $xml_error) {
                    $error .= $xml_error->message;
                  }
              }
              
            } else {
              $error = 'Error in response from TNT. Please check module configuration.';
            }
          
        } ## postcode error
        
        $method_data = array(
          'id'         => 'tntpost',
          'title'      => $this->language->get('text_title'),
          'quote'      => $quote_data,
          'sort_order' => $this->config->get('tntpost_sort_order'),
          'error'      => $error //$error 
        );    
    

      }
      
      
        return $method_data;      
      
    }
  }

Attachments


Newbie

Posts

Joined
Fri Sep 10, 2010 1:58 pm
Location - Australia

Post by maxkool » Wed Jan 19, 2011 7:13 pm

Did you finally manage to get this module working properly? I'm looking at purchasing the same module for TNT Shipping but I wouldn't want to have to iron bugs out of it from the get-go.

Thanks

Newbie

Posts

Joined
Tue Jan 04, 2011 7:44 pm

Post by Blurry » Mon Feb 07, 2011 12:10 pm

Hello,

Does anyone have an update on this? Anyone willing to fix it? (free or otherwise)

That module would be very handy as I would also like to use it.

Please contact me.

Thanks,
Blurry

Newbie

Posts

Joined
Sun Jan 30, 2011 12:10 pm

Post by rbrasier » Tue Mar 13, 2012 7:12 am

Hi,

I am looking for a solution to this now as well. Has anyone got this working?

Or know where I could purchase a working module for TNT Express Australia?

Thanks
Richard

Newbie

Posts

Joined
Tue Mar 13, 2012 7:10 am
Who is online

Users browsing this forum: No registered users and 13 guests