本文整理汇总了PHP中SoapClient::CalculateRate方法的典型用法代码示例。如果您正苦于以下问题:PHP SoapClient::CalculateRate方法的具体用法?PHP SoapClient::CalculateRate怎么用?PHP SoapClient::CalculateRate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoapClient
的用法示例。
在下文中一共展示了SoapClient::CalculateRate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postAction
public function postAction()
{
$account = Mage::getStoreConfig('aramexsettings/settings/account_number');
$country_code = Mage::getStoreConfig('aramexsettings/settings/account_country_code');
$post = $this->getRequest()->getPost();
$country = Mage::getModel('directory/country')->loadByCode($country_code);
$response = array();
$clientInfo = Mage::helper('aramexshipment')->getClientInfo();
try {
if (empty($post)) {
$response['type'] = 'error';
$response['error'] = $this->__('Invalid form data.');
print json_encode($response);
die;
}
$params = array('ClientInfo' => $clientInfo, 'Transaction' => array('Reference1' => $post['reference']), 'OriginAddress' => array('StateOrProvinceCode' => html_entity_decode($post['origin_state']), 'City' => html_entity_decode($post['origin_city']), 'PostCode' => $post['origin_zipcode'], 'CountryCode' => $post['origin_country']), 'DestinationAddress' => array('StateOrProvinceCode' => html_entity_decode($post['destination_state']), 'City' => html_entity_decode($post['destination_city']), 'PostCode' => $post['destination_zipcode'], 'CountryCode' => $post['destination_country']), 'ShipmentDetails' => array('PaymentType' => $post['payment_type'], 'ProductGroup' => $post['product_group'], 'ProductType' => $post['service_type'], 'ActualWeight' => array('Value' => $post['text_weight'], 'Unit' => $post['weight_unit']), 'ChargeableWeight' => array('Value' => $post['text_weight'], 'Unit' => $post['weight_unit']), 'NumberOfPieces' => $post['total_count']));
$baseUrl = Mage::helper('aramexshipment')->getWsdlPath();
$soapClient = new SoapClient($baseUrl . 'aramex-rates-calculator-wsdl.wsdl', array('trace' => 1));
try {
$results = $soapClient->CalculateRate($params);
if ($results->HasErrors) {
if (count($results->Notifications->Notification) > 1) {
$error = "";
foreach ($results->Notifications->Notification as $notify_error) {
$error .= $this->__('Aramex: ' . $notify_error->Code . ' - ' . $notify_error->Message) . "<br>";
}
$response['error'] = $error;
} else {
$response['error'] = $this->__('Aramex: ' . $results->Notifications->Notification->Code . ' - ' . $results->Notifications->Notification->Message);
}
$response['type'] = 'error';
} else {
$response['type'] = 'success';
$amount = "<p class='amount'>" . $results->TotalAmount->Value . " " . $results->TotalAmount->CurrencyCode . "</p>";
$text = "Local taxes - if any - are not included. Rate is based on account number {$account} in " . $country->getName();
$response['html'] = $amount . $text;
}
} catch (Exception $e) {
$response['type'] = 'error';
$response['error'] = $e->getMessage();
}
} catch (Exception $e) {
$response['type'] = 'error';
$response['error'] = $e->getMessage();
}
print json_encode($response);
die;
}
示例2: array
<?php
$params = array('ClientInfo' => array('AccountCountryCode' => 'EG', 'AccountEntity' => 'CAI', 'AccountNumber' => '239584', 'AccountPin' => '216216', 'UserName' => 'mohamed.amer2050@gmail.com', 'Password' => 'asd654321', 'Version' => 'v1.0'), 'Transaction' => array('Reference1' => '001'), 'OriginAddress' => array('City' => 'Nasr City', 'State Or Province Code' => 'egypt', 'CountryCode' => 'EG'), 'DestinationAddress' => array('City' => 'Tanta', 'State Or Province Code' => 'egypt', 'CountryCode' => 'EG'), 'ShipmentDetails' => array('PaymentType' => 'P', 'ProductGroup' => 'DOM', 'ProductType' => 'OND', 'ActualWeight' => array('Value' => 7.25, 'Unit' => 'KG'), 'ChargeableWeight' => array('Value' => 7.25, 'Unit' => 'KG'), 'NumberOfPieces' => 7));
$soapClient = new SoapClient('http://ws.aramex.net/ShippingAPI/RateCalculator/Service_1_0.svc?wsdl', array('trace' => 1));
//$soapClient = new SoapClient('http://ws.dev.aramex.net/shippingapi/shipping/service_1_0.svc?wsdl', array('trace' => 1));
$results = $soapClient->CalculateRate($params);
echo '<pre>';
print_r($results);
echo "</br></br></br></br>";
$array = json_decode(json_encode($results), True);
echo '<pre>';
print_r($array['TotalAmount']['Value']);
echo '</pre>';
示例3: _getAramexQuotes
public function _getAramexQuotes()
{
$r = $this->_rawRequest;
$pkgWeight = $r->getWeightPounds();
$pkgQty = $r->getPackageQty();
$product_group = 'EXP';
$allowed_methods_key = 'allowed_international_methods';
$allowed_methods = Mage::getSingleton('aramex/carrier_aramex_source_internationalmethods')->toKeyArray();
if (Mage::getStoreConfig('aramexsettings/shipperdetail/country') == $r->getDestCountryId()) {
$product_group = 'DOM';
$allowed_methods = Mage::getSingleton('aramex/carrier_aramex_source_domesticmethods')->toKeyArray();
$allowed_methods_key = 'allowed_domestic_methods';
}
$admin_allowed_methods = explode(',', $this->getConfigData($allowed_methods_key));
$admin_allowed_methods = array_flip($admin_allowed_methods);
$allowed_methods = array_intersect_key($allowed_methods, $admin_allowed_methods);
$baseUrl = Mage::helper('aramexshipment')->getWsdlPath();
$clientInfo = Mage::helper('aramexshipment')->getClientInfo();
$OriginAddress = array('StateOrProvinceCode' => Mage::getStoreConfig('aramexsettings/shipperdetail/state'), 'City' => Mage::getStoreConfig('aramexsettings/shipperdetail/city'), 'PostCode' => Mage::getStoreConfig('aramexsettings/shipperdetail/postalcode'), 'CountryCode' => Mage::getStoreConfig('aramexsettings/shipperdetail/country'));
$DestinationAddress = array('StateOrProvinceCode' => $r->getDestState(), 'City' => $r->getDestCity(), 'PostCode' => Mage_Usa_Model_Shipping_Carrier_Abstract::USA_COUNTRY_ID == $r->getDestCountryId() ? substr($r->getDestPostal(), 0, 5) : $r->getDestPostal(), 'CountryCode' => $r->getDestCountryId());
$ShipmentDetails = array('PaymentType' => 'P', 'ProductGroup' => $product_group, 'ProductType' => '', 'ActualWeight' => array('Value' => $pkgWeight, 'Unit' => 'KG'), 'ChargeableWeight' => array('Value' => $pkgWeight, 'Unit' => 'KG'), 'NumberOfPieces' => $pkgQty);
$params = array('ClientInfo' => $clientInfo, 'OriginAddress' => $OriginAddress, 'DestinationAddress' => $DestinationAddress, 'ShipmentDetails' => $ShipmentDetails);
//SOAP object
$soapClient = new SoapClient($baseUrl . 'aramex-rates-calculator-wsdl.wsdl');
$priceArr = array();
foreach ($allowed_methods as $m_value => $m_title) {
$params['ShipmentDetails']['ProductType'] = $m_value;
try {
$results = $soapClient->CalculateRate($params);
if ($results->HasErrors) {
if (count($results->Notifications->Notification) > 1) {
$error = "";
foreach ($results->Notifications->Notification as $notify_error) {
$error .= 'Aramex: ' . $notify_error->Code . ' - ' . $notify_error->Message . ' ';
}
$response['error'] = $error;
} else {
$response['error'] = 'Aramex: ' . $results->Notifications->Notification->Code . ' - ' . $results->Notifications->Notification->Message . ' ';
}
$response['type'] = 'error';
} else {
$response['type'] = 'success';
$priceArr[$m_value] = array('label' => $m_title, 'amount' => $results->TotalAmount->Value);
}
} catch (Exception $e) {
$response['type'] = 'error';
$response['error'] = $e->getMessage();
}
}
$result = Mage::getModel('shipping/rate_result');
$defaults = $this->getDefaults();
if (empty($priceArr)) {
$error_msg = $this->getConfigData('specificerrmsg');
if (isset($response['error'])) {
$error_msg = $response['error'];
}
$error = Mage::getModel('shipping/rate_result_error');
$error->setCarrier($this->_code);
$error->setCarrierTitle($this->getConfigData('title'));
$error->setErrorMessage($error_msg);
$result->append($error);
} else {
foreach ($priceArr as $method => $values) {
$rate = Mage::getModel('shipping/rate_result_method');
$rate->setCarrier($this->_code);
$rate->setCarrierTitle($this->getConfigData('title'));
$rate->setMethod($method);
$rate->setMethodTitle($values['label']);
$rate->setCost($values['amount']);
$rate->setPrice($values['amount']);
$result->append($rate);
}
}
return $result;
}
示例4: GetCost
public function GetCost($city, $sum)
{
$params = array('ClientInfo' => array('AccountCountryCode' => 'EG', 'AccountEntity' => 'CAI', 'AccountNumber' => '239584', 'AccountPin' => '216216', 'UserName' => 'mohamed.amer2050@gmail.com', 'Password' => 'asd654321', 'Version' => 'v1.0'), 'Transaction' => array('Reference1' => '001'), 'OriginAddress' => array('City' => 'Nasr City', 'State Or Province Code' => 'egypt', 'CountryCode' => 'EG'), 'DestinationAddress' => array('City' => $city, 'State Or Province Code' => 'egypt', 'CountryCode' => 'EG'), 'ShipmentDetails' => array('PaymentType' => 'P', 'ProductGroup' => 'DOM', 'ProductType' => 'OND', 'ActualWeight' => array('Value' => $sum, 'Unit' => 'KG'), 'ChargeableWeight' => array('Value' => $sum, 'Unit' => 'KG'), 'NumberOfPieces' => 7));
$soapClient = new \SoapClient('http://ws.aramex.net/ShippingAPI/RateCalculator/Service_1_0.svc?wsdl', array('trace' => 1));
//$soapClient = new SoapClient('http://ws.dev.aramex.net/shippingapi/shipping/service_1_0.svc?wsdl', array('trace' => 1));
$results = $soapClient->CalculateRate($params);
$array = json_decode(json_encode($results), True);
return $array['TotalAmount']['Value'];
}