I had purchased a module awhile back, and had a problem, the developer was going to get back to me, but I am sad to say it appears he has passed away.
Can anyone help me with this?
There are 2 sets of code, 1 for the quick estimate part of the shipping (which works correctly), and one for the full estimate in the checkout (which does not work).
Does work
Code: Select all
// Set for Debug Information
$submission_type = "Submitted Using: Quick Estimate";
// Set stdClass and Array for Purolator Response
$request = new stdClass();
$request->ReceiverAddress = new stdClass();
$request->TotalWeight = new stdClass();
$request->Shipment = new stdClass();
$request->Shipment->PackageInformation = new stdClass();
$request->Shipment->PackageInformation->OptionsInformation = new stdClass();
$request->Shipment->PackageInformation->OptionsInformation->Options = new stdClass();
$request->Shipment->PackageInformation->OptionsInformation->Options->OptionIDValuePair = new stdClass();
$response = new stdClass();
$response->ShipmentEstimates = new stdClass();
$response->ShipmentEstimates->ShipmentEstimate = new stdClass();
$response->ShipmentEstimates->ShipmentEstimate->Surcharges = new stdClass();
$response->ShipmentEstimates->ShipmentEstimate->Surcharges->Surcharge = new stdClass();
$response->ResponseInformation = new stdClass();
$response->ResponseInformation->Errors = new stdClass();
$return_error = FALSE;
$purolator_title = $this->language->get('heading_title');
$purolator_sort_order = $this->config->get('purolator_sort_order');
// Customer information checked for compatibility with the Backend Order Entry System
if (!$this->config->get('purolator_test')) {
if (isset($this->session->data['customer_info'])) {
$wsdl = str_replace("/admin/", "", DIR_APPLICATION) . '/wsdl/development/EstimatingService.wsdl';
} else {
$wsdl = './wsdl/development/EstimatingService.wsdl';
}
$server_call = 'https://devwebservices.purolator.com/PWS/V1/Estimating/EstimatingService.asmx';
} else {
if (isset($this->session->data['customer_info'])) {
$wsdl = str_replace("/admin/", "", DIR_APPLICATION) . '/wsdl/production/EstimatingService.wsdl';
} else {
$wsdl = './wsdl/production/EstimatingService.wsdl';
}
$server_call = 'https://webservices.purolator.com/PWS/V1/Estimating/EstimatingService.asmx';
}
//Create a SOAP Client
/** Purpose : Creates a SOAP Client in Non-WSDL mode with the appropriate authentication and
* header information
*
* Provided by Purolator: https://devwebservices.purolator.com/EWS/V1/Estimating/EstimatingService.asmx?wsdl
**/
//Set the parameters for the Non-WSDL mode SOAP communication with your Development/Production credentials
$client = new SoapClient( $wsdl,
array (
'trace' => true,
'location' => $server_call,
'uri' => "http://purolator.com/pws/datatypes/v1",
'login' => $this->config->get('purolator_key'),
'password' => $this->config->get('purolator_keyPassword')
)
);
//Define the SOAP Envelope Headers
$headers[] = new SoapHeader ( 'http://purolator.com/pws/datatypes/v1',
'RequestContext',
array (
'Version' => '1.3',
'Language' => 'en',
'GroupID' => 'xxx',
'RequestReference' => 'Rating Example'
)
);
//Apply the SOAP Header to your client
$client->__setSoapHeaders($headers);
//Populate the Billing Account Number
$request->BillingAccountNumber = $this->config->get('purolator_accountNumber');
//Populate the Origin Information
$request->SenderPostalCode = $this->config->get('purolator_originPostalCode');
//Populate the Desination Information
$request->ReceiverAddress->Province = $address['zone_code'];
$request->ReceiverAddress->Country = $address['iso_code_2'];
$request->ReceiverAddress->PostalCode = $receiver_postalcode;
//Populate the Package Information
$request->PackageType = "CustomerPackaging";
//Populate the Shipment Weight
$request->TotalWeight->Value = $weight;
$request->TotalWeight->WeightUnit = $weight_code;
//Execute the request and capture the response
$response = $client->GetQuickEstimate($request);
} // END OF QUICK ESTIMATE
Does not work
Code: Select all
// Set for Debug Information
$submission_type = "Submitted Using: Full Estimate";
// Set stdClass and Array for Purolator Request
$request = new stdClass();
$request->ShowAlternativeServicesIndicator = new stdClass();
$request->Shipment = new stdClass();
$request->Shipment->PackageInformation = new stdClass();
$request->Shipment->PackageInformation->OptionsInformation = new stdClass();
$request->Shipment->PackageInformation->OptionsInformation->Options = new stdClass();
$request->Shipment->PackageInformation->OptionsInformation->Options->OptionIDValuePair = new stdClass();
$request->Shipment->PackageInformation->TotalWeight = new stdClass();
$request->Shipment->PickupInformation = new stdClass();
$request->Shipment->PaymentInformation = new stdClass();
$request->Shipment->PaymentInformation->PaymentType = new stdClass();
$request->Shipment->SenderInformation = new stdClass();
$request->Shipment->SenderInformation->Address = new stdClass();
$request->Shipment->ReceiverInformation = new stdClass();
$request->Shipment->ReceiverInformation->Address = new stdClass();
// Set stdClass and Array for Purolator Response
$response = new stdClass();
$response->ShipmentEstimates = new stdClass();
$response->ShipmentEstimates->ShipmentEstimate = new stdClass();
$response->ShipmentEstimates->ShipmentEstimate->Surcharges = new stdClass();
$response->ShipmentEstimates->ShipmentEstimate->Surcharges->Surcharge = new stdClass();
$response->ShipmentEstimates->ShipmentEstimate->Surcharges->Surcharge->Amount = new stdClass();
$response->ResponseInformation = new stdClass();
$response->ResponseInformation->Errors = new stdClass();
$client = new stdClass();
$purolator_title = $this->language->get('heading_title');
$purolator_sort_order = $this->config->get('purolator_sort_order');
// Customer information checked for compatibility with the Backend Order Entry System
if (!$this->config->get('purolator_test')) {
if (isset($this->session->data['customer_info'])) {
$wsdl = str_replace("/admin/", "", DIR_APPLICATION) . '/wsdl/development/EstimatingService.wsdl';
} else {
$wsdl = './wsdl/development/EstimatingService.wsdl';
}
$server_call = 'https://devwebservices.purolator.com/PWS/V1/Estimating/EstimatingService.asmx';
} else {
if (isset($this->session->data['customer_info'])) {
$wsdl = str_replace("/admin/", "", DIR_APPLICATION) . '/wsdl/production/EstimatingService.wsdl';
} else {
$wsdl = './wsdl/production/EstimatingService.wsdl';
}
$server_call = 'https://webservices.purolator.com/PWS/V1/Estimating/EstimatingService.asmx';
}
//Create a SOAP Client
/** Purpose : Creates a SOAP Client in Non-WSDL mode with the appropriate authentication and
* header information
*
* Provided by Purolator: https://devwebservices.purolator.com/EWS/V1/Estimating/EstimatingService.asmx?wsdl
**/
//Set the parameters for the Non-WSDL mode SOAP communication with your Development/Production credentials
$client = new SoapClient( $wsdl,
array (
'trace' => true,
'location' => $server_call,
'uri' => "http://purolator.com/pws/datatypes/v1",
'login' => $this->config->get('purolator_key'),
'password' => $this->config->get('purolator_keyPassword')
)
);
//Define the SOAP Envelope Headers
$headers[] = new SoapHeader ( 'http://purolator.com/pws/datatypes/v1',
'RequestContext',
array (
'Version' => '1.3',
'Language' => 'en',
'GroupID' => 'xxx',
'RequestReference' => 'Rating Example'
)
);
//Apply the SOAP Header to your client
$client->__setSoapHeaders($headers);
//Populate the Origin Information
$request->Shipment->SenderInformation->Address->Name = $this->config->get('config_name');
$request->Shipment->SenderInformation->Address->StreetNumber = "";
$request->Shipment->SenderInformation->Address->StreetName = $this->config->get('purolator_originAddress1');
$request->Shipment->SenderInformation->Address->City = $this->config->get('purolator_originCity');
$request->Shipment->SenderInformation->Address->Province = $this->config->get('purolator_originProvince');
$request->Shipment->SenderInformation->Address->Country = "CA"; // CURRENTLY HARDCODED - PUROLATOR IS A CANADIAN COURIER.
$request->Shipment->SenderInformation->Address->PostalCode = $this->config->get('purolator_originPostalCode');
//Populate the Desination Information
$request->Shipment->ReceiverInformation->Address->Name = $address['firstname'] . ' ' . $address['lastname'];
$request->Shipment->ReceiverInformation->Address->StreetNumber = "";
$request->Shipment->ReceiverInformation->Address->StreetName = $address['address_1'];
$request->Shipment->ReceiverInformation->Address->City = $address['city'];
$request->Shipment->ReceiverInformation->Address->Province = $address['zone_code'];
$request->Shipment->ReceiverInformation->Address->Country = $address['iso_code_2'];
$request->Shipment->ReceiverInformation->Address->PostalCode = $receiver_postalcode;
//Populate the Package Information
$request->Shipment->PackageInformation->TotalWeight->Value = $weight;
$request->Shipment->PackageInformation->TotalWeight->WeightUnit = $weight_code;
$request->Shipment->PackageInformation->TotalPieces = $vbox; //$cart_count;
if($address['iso_code_2'] == "CA") {
$request->Shipment->PackageInformation->ServiceID = "PurolatorExpress";
} elseif($address['iso_code_2'] == "US") {
$request->Shipment->PackageInformation->ServiceID = "PurolatorExpressU.S.";
} else {
$request->Shipment->PackageInformation->ServiceID = "PurolatorExpressInternational";
}
//Populate the Payment Information
$request->Shipment->PaymentInformation->PaymentType = "Sender";
$request->Shipment->PaymentInformation->BillingAccountNumber = $this->config->get('purolator_accountNumber');;
$request->Shipment->PaymentInformation->RegisteredAccountNumber = $this->config->get('purolator_accountNumber');;
//Populate the Pickup Information
$request->Shipment->PickupInformation->PickupType = "DropOff";
$request->ShowAlternativeServicesIndicator = "true";
//Define OptionsInformation
if($address['iso_code_2'] == "CA") {
//ResidentialSignatureDomestic
$request->Shipment->PackageInformation->OptionsInformation->Options->OptionIDValuePair->ID = "ResidentialSignatureDomestic";
$request->Shipment->PackageInformation->OptionsInformation->Options->OptionIDValuePair->Value = "true";
//OriginSignatureNotRequired
$request->Shipment->PackageInformation->OptionsInformation->Options->OptionIDValuePair->ID = "OriginSignatureNotRequired";
$request->Shipment->PackageInformation->OptionsInformation->Options->OptionIDValuePair->Value = "true";
}
//Execute the request and capture the response
$response = $client->GetFullEstimate($request);
} // END OF LOGGED IN CHECK