Ejemplo n.º 1
0
 function onShippingConfiguration(&$element)
 {
     if (!JPluginHelper::isEnabled('hikashopshipping', 'bfmanual')) {
         $lang = JFactory::getLanguage();
         $lang->load('plg_hikashopshipping_bfmanual', JPATH_ADMINISTRATOR);
         JFactory::getApplication()->redirect('index.php?option=com_hikashop&ctrl=plugins', JText::_('PLG_BF_MANUAL_NOT_ENABLED'));
     }
     $this->loadLanguage();
     parent::onShippingConfiguration($element);
 }
 function onShippingConfigurationSave(&$elements)
 {
     parent::onShippingConfigurationSave($element);
 }
Ejemplo n.º 3
0
 function _FEDEXrequestMethods($data, $rate)
 {
     global $fedex_methods;
     $path_to_wsdl = dirname(__FILE__) . DS . 'fedex_rate.wsdl';
     ini_set("soap.wsdl_cache_enabled", "0");
     if (!class_exists('SoapClient')) {
         $app = JFactory::getApplication();
         $app->enqueueMessage('The FEDEX shipping plugin needs the SOAP library installed but it seems that it is not available on your server. Please contact your web hosting to set it up.', 'error');
         return false;
     }
     $client = new SoapClient($path_to_wsdl, array('exceptions' => false));
     $shipment = array();
     foreach ($data['methods'] as $k => $v) {
         $request['WebAuthenticationDetail'] = array('UserCredential' => array('Key' => $data['fedex_api_key'], 'Password' => $data['fedex_api_password']));
         $request['ClientDetail'] = array('AccountNumber' => $data['fedex_account_number'], 'MeterNumber' => $data['fedex_meter_number']);
         $request['TransactionDetail'] = array('CustomerTransactionId' => ' *** Rate Request v10 using PHP ***');
         $request['Version'] = array('ServiceId' => 'crs', 'Major' => '10', 'Intermediate' => '0', 'Minor' => '0');
         $request['ReturnTransitAndCommit'] = true;
         $request['RequestedShipment']['DropoffType'] = 'REGULAR_PICKUP';
         // valid values REGULAR_PICKUP, REQUEST_COURIER, ...
         $request['RequestedShipment']['ShipTimestamp'] = date('c');
         $request['RequestedShipment']['ServiceType'] = $v;
         // valid values STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, ...
         $request['RequestedShipment']['PackagingType'] = $data['packaging_type'];
         // valid values FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ...
         $request['RequestedShipment']['TotalInsuredValue'] = array('Ammount' => $data['total_insured'], 'Currency' => 'USD');
         $request['RequestedPackageDetailType'] = 'PACKAGE_SUMMARY';
         $shipper = array('Contact' => array('PersonName' => $data['sender_company'], 'CompanyName' => $data['sender_company'], 'PhoneNumber' => $data['sender_phone']), 'Address' => array('StreetLines' => array($data['sender_address']), 'City' => $data['sender_city'], 'StateOrProvinceCode' => $data['sender_state'], 'PostalCode' => $data['sender_postcode'], 'CountryCode' => $data['country']));
         $recipient_StateOrProvinceCode = '';
         if (isset($data['recipient']->address_state->zone_code_2) && strlen($data['recipient']->address_state->zone_code_2) == 2) {
             $recipient_StateOrProvinceCode = $data['recipient']->address_state->zone_code_2;
         } elseif (strlen($data['recipient']->address_state->zone_code_3) == 2) {
             $recipient_StateOrProvinceCode = $data['recipient']->address_state->zone_code_3;
         }
         $recipient = array('Contact' => array('PersonName' => $data['recipient']->address_title . " " . $data['recipient']->address_firstname . " " . $data['recipient']->address_lastname, 'CompanyName' => $data['recipient']->address_company, 'PhoneNumber' => $data['recipient']->address_telephone), 'Address' => array('StreetLines' => array($data['recipient']->address_street), 'City' => $data['recipient']->address_city, 'StateOrProvinceCode' => $recipient_StateOrProvinceCode, 'PostalCode' => $data['recipient']->address_post_code, 'CountryCode' => $data['recipient']->address_country->zone_code_2, 'Residential' => true));
         if (@$rate->shipping_params->destination_type == 'res') {
             $recipient['Address']['Residential'] = true;
         }
         if (@$rate->shipping_params->destination_type == 'com' || @$rate->shipping_params->destination_type == 'auto' && $v == 'FEDEX_GROUND') {
             $recipient['Address']['Residential'] = false;
         }
         $shippingChargesPayment = array('PaymentType' => 'SENDER', 'Payor' => array('AccountNumber' => $data['fedex_account_number'], 'CountryCode' => $data['country']));
         $pkg_values = $this->xml2array('<root>' . $data['XMLpackage'] . '</root>');
         $pkg_values = $pkg_values['root'];
         $pkg_count = count($pkg_values);
         $request['RequestedShipment']['Shipper'] = $shipper;
         $request['RequestedShipment']['Recipient'] = $recipient;
         $request['RequestedShipment']['ShippingChargesPayment'] = $shippingChargesPayment;
         $request['RequestedShipment']['RateRequestTypes'] = 'ACCOUNT';
         if (empty($rate->shipping_params->rate_types) || $rate->shipping_params->rate_types != 'ACCOUNT') {
             $request['RequestedShipment']['RateRequestTypes'] = 'LIST';
         }
         $request['RequestedShipment']['PackageCount'] = $pkg_count;
         $request['RequestedShipment']['RequestedPackageLineItems'] = $this->addPackageLineItem($pkg_values);
         if (@$rate->shipping_params->debug) {
             echo "<br/> Request {$v} : <br/>";
             echo '<pre>' . var_export($request, true) . '</pre>';
         }
         $response = $client->getRates($request);
         if (isset($response->HighestSeverity) && $response->HighestSeverity == "ERROR") {
             static $notif = false;
             if (!$notif && isset($response->Notifications->Message) && $response->Notifications->Message == 'Authentication Failed') {
                 $app = JFactory::getApplication();
                 $app->enqueueMessage('FEDEX Authentication Failed');
                 $notif = true;
             }
             if (!$notif && !empty($response->Notifications->Message) && strpos($response->Notifications->Message, 'Service is not allowed') === FALSE) {
                 $app = JFactory::getApplication();
                 $app->enqueueMessage('The FedEx request failed with the message : ' . $response->Notifications->Message);
             }
         }
         if (@$rate->shipping_params->debug) {
             echo "<br/> Response {$v} : <br/>";
             echo '<pre>' . var_export($response, true) . '</pre>';
         }
         if (!empty($response->HighestSeverity) && ($response->HighestSeverity == "SUCCESS" || $response->HighestSeverity == "NOTE" || $response->HighestSeverity == "WARNING")) {
             $code = '';
             $notes = array();
             if ($response->HighestSeverity == "NOTE" || $response->HighestSeverity == "WARNING") {
                 $notes = $response->Notifications;
             }
             foreach ($this->fedex_methods as $k => $v) {
                 if ($v['code'] == $response->RateReplyDetails->ServiceType) {
                     $code = $v['code'];
                 }
             }
             $delayType = hikashop_get('type.delay');
             if (!empty($response->RateReplyDetails->DeliveryTimestamp)) {
                 $timestamp = strtotime($response->RateReplyDetails->DeliveryTimestamp);
             } else {
                 $timestamp = 0;
                 $response->RateReplyDetails->DeliveryTimestamp = 0;
             }
             $totalNetPrice = 0;
             $discountAmount = 0;
             if (is_array($response->RateReplyDetails->RatedShipmentDetails)) {
                 $totalNetPrice = $response->RateReplyDetails->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount;
                 if ($request['RequestedShipment']['RateRequestTypes'] != 'ACCOUNT') {
                     $discountAmount = $response->RateReplyDetails->RatedShipmentDetails[0]->ShipmentRateDetail->TotalFreightDiscounts->Amount;
                 }
                 $shipment[] = array('value' => $totalNetPrice + $discountAmount, 'code' => $code, 'delivery_timestamp' => $timestamp, 'day' => $response->RateReplyDetails->DeliveryTimestamp, 'delivery_day' => date("m/d/Y", $timestamp), 'delivery_delay' => parent::displayDelaySECtoDAY($timestamp - strtotime('now'), 2), 'delivery_time' => date("H:i:s", $timestamp), 'currency_code' => $response->RateReplyDetails->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Currency, 'old_currency_code' => $response->RateReplyDetails->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Currency, 'notes' => $notes);
             } else {
                 if (is_object($response->RateReplyDetails->RatedShipmentDetails)) {
                     $totalNetPrice = $response->RateReplyDetails->RatedShipmentDetails->ShipmentRateDetail->TotalNetCharge->Amount;
                     if ($request['RequestedShipment']['RateRequestTypes'] != 'ACCOUNT') {
                         $discountAmount = $response->RateReplyDetails->RatedShipmentDetails->ShipmentRateDetail->TotalFreightDiscounts->Amount;
                     }
                     $shipment[] = array('value' => $totalNetPrice + $discountAmount, 'code' => $code, 'delivery_timestamp' => $timestamp, 'day' => $response->RateReplyDetails->DeliveryTimestamp, 'delivery_day' => date("m/d/Y", $timestamp), 'delivery_delay' => parent::displayDelaySECtoDAY($timestamp - strtotime('now'), 2), 'delivery_time' => date("H:i:s", $timestamp), 'currency_code' => $response->RateReplyDetails->RatedShipmentDetails->ShipmentRateDetail->TotalNetCharge->Currency, 'old_currency_code' => $response->RateReplyDetails->RatedShipmentDetails->ShipmentRateDetail->TotalNetCharge->Currency, 'notes' => $notes);
                 }
             }
         } else {
             if (!empty($response->HighestSeverity) && $response->HighestSeverity == "ERROR") {
                 static $errorsDisplayed = array();
                 $acceptedCodes = array(836);
                 if (!empty($response->Notifications)) {
                     foreach ($response->Notifications as $notif) {
                         if (!is_object($notif)) {
                             continue;
                         }
                         $errorCode = $notif->Code;
                         if (!in_array($errorCode, $acceptedCodes)) {
                             if (!isset($errorsDisplayed[$errorCode])) {
                                 $app = JFactory::getApplication();
                                 $app->enqueueMessage($notif->Message);
                             }
                             $errorsDisplayed[$errorCode] = true;
                         }
                     }
                 }
             }
         }
     }
     return $shipment;
 }
Ejemplo n.º 4
0
 function onShippingConfigurationSave(&$element)
 {
     $app = JFactory::getApplication();
     if (empty($element->shipping_params->usps_user_id)) {
         $app->enqueueMessage(JText::sprintf('ENTER_INFO', 'USPS', ' WebTools User ID'));
     }
     if (empty($element->shipping_params->post_code)) {
         $app->enqueueMessage(JText::sprintf('ENTER_INFO', 'USPS', JText::_('POST_CODE')));
     }
     if (isset($element->shipping_params->services)) {
         $element->shipping_params->PRIORITY = in_array('PRIORITY', $element->shipping_params->services);
         $element->shipping_params->MEDIA = in_array('MEDIA', $element->shipping_params->services);
         $element->shipping_params->EXPRESS = in_array('EXPRESS', $element->shipping_params->services);
         $FIRSTCLASS = 'FIRST CLASS';
         $element->shipping_params->{$FIRSTCLASS} = in_array('FIRST CLASS', $element->shipping_params->services);
         $element->shipping_params->INTERNATIONAL = in_array('INTERNATIONAL', $element->shipping_params->services);
         $element->shipping_params->PRIORITYINTSMALL = in_array('PRIORITYINTSMALL', $element->shipping_params->services);
         $element->shipping_params->PRIORITYINTDVD = in_array('PRIORITYINTDVD', $element->shipping_params->services);
         $element->shipping_params->PRIORITYINTLARGEVIDEO = in_array('PRIORITYINTLARGEVIDEO', $element->shipping_params->services);
         $element->shipping_params->PRIORITYINTMEDIUM = in_array('PRIORITYINTMEDIUM', $element->shipping_params->services);
         $element->shipping_params->PRIORITYINTLARGE = in_array('PRIORITYINTLARGE', $element->shipping_params->services);
         $element->shipping_params->EXPRESSINTBOX = in_array('EXPRESSINTBOX', $element->shipping_params->services);
         $element->shipping_params->EXPRESSINT = in_array('EXPRESSINT', $element->shipping_params->services);
         $element->shipping_params->FIRSTCLASSINT = in_array('FIRSTCLASSINT', $element->shipping_params->services);
         $element->shipping_params->ENVELOPE = in_array('ENVELOPE', $element->shipping_params->services);
     } else {
         $app->enqueueMessage(JText::sprintf('CHOOSE_SHIPPING_SERVICE'));
     }
     if (!empty($element->shipping_params->machinableCheck)) {
         $element->shipping_params->MACHINABLE = in_array('MACHINABLE', $element->shipping_params->machinableCheck);
     }
     parent::onShippingConfigurationSave($element);
 }
Ejemplo n.º 5
0
 function _getShippingMethods(&$rate, &$order, &$warehouse, $null)
 {
     $data = array();
     $data['destCity'] = $null->shipping_address->address_city;
     $data['destState'] = $null->shipping_address->address_state;
     $data['destZip'] = $null->shipping_address->address_post_code;
     $data['destCountry'] = $null->shipping_address->address_country->zone_code_2;
     $data['units'] = $warehouse->units;
     $data['zip'] = $warehouse->zip;
     $totalPrice = 0;
     if (!$rate->shipping_params->group_package || $rate->shipping_params->group_package == 0) {
         $data['weight'] = 0;
         $data['height'] = 0;
         $data['length'] = 0;
         $data['width'] = 0;
         $data['price'] = 0;
         $data['quantity'] = 0;
         $data['name'] = '';
         foreach ($order->products as $product) {
             if ($product->product_parent_id == 0) {
                 if (isset($product->variants)) {
                     foreach ($product->variants as $variant) {
                         $data['units'] = 'kg';
                         $caracs = parent::_convertCharacteristics($variant, $data);
                         $data['weight'] = round($caracs['weight'], 2) * $variant->cart_product_quantity;
                         $data['height'] = round($caracs['height'], 2) * $variant->cart_product_quantity;
                         $data['length'] = round($caracs['length'], 2) * $variant->cart_product_quantity;
                         $data['width'] = round($caracs['width'], 2) * $variant->cart_product_quantity;
                         $data['price'] = $variant->prices[0]->unit_price->price_value_with_tax * $variant->cart_product_quantity;
                         $data['name'] = $variant->main_product_name . ' :' . $variant->characteristics_text;
                         $data['quantity'] = $variant->cart_product_quantity;
                         $data['XMLpackage'][] = $this->_createPackage($data, $product, $rate, $order);
                     }
                 } else {
                     $data['units'] = 'kg';
                     $caracs = parent::_convertCharacteristics($product, $data);
                     $data['weight'] = round($caracs['weight'], 2) * $product->cart_product_quantity;
                     $data['height'] = round($caracs['height'], 2) * $product->cart_product_quantity;
                     $data['length'] = round($caracs['length'], 2) * $product->cart_product_quantity;
                     $data['width'] = round($caracs['width'], 2) * $product->cart_product_quantity;
                     $data['price'] = $product->prices[0]->price_value_with_tax * $product->cart_product_quantity;
                     $data['name'] = $product->product_name;
                     $data['quantity'] = $product->cart_product_quantity;
                     $data['XMLpackage'][] = $this->_createPackage($data, $product, $rate, $order);
                 }
             }
         }
         $usableMethods = $this->_RequestMethods($data, $data['XMLpackage']);
         return $usableMethods;
     } else {
         $data['weight'] = 0;
         $data['height'] = 0;
         $data['length'] = 0;
         $data['width'] = 0;
         $data['price'] = 0;
         $data['quantity'] = 1;
         $data['name'] = 'grouped package';
         $this->package_added = 0;
         $this->nbpackage = 0;
         $limitation = array('length' => 50, 'weight' => 10, 'width' => 50, 'height' => 50);
         if (!empty($rate->shipping_params->dim_approximation_l)) {
             $l_length = $rate->shipping_params->dim_approximation_l;
             $l_weight = $rate->shipping_params->dim_approximation_kg;
             $l_height = $rate->shipping_params->dim_approximation_h;
             $l_width = $rate->shipping_params->dim_approximation_w;
         }
         if ($l_length > 0 && $limitation['length'] > $l_length) {
             $limitation['length'] = $l_length;
         }
         if ($l_weight > 0 && $limitation['weight'] > $l_weight) {
             $limitation['weight'] = $l_weight;
         }
         if ($l_height > 0 && $limitation['height'] > $l_height) {
             $limitation['height'] = $l_height;
         }
         if ($l_width > 0 && $limitation['width'] > $l_width) {
             $limitation['width'] = $l_width;
         }
     }
     foreach ($order->products as $product) {
         if ($product->product_parent_id != 0) {
             continue;
         }
         if (isset($product->variants)) {
             foreach ($product->variants as $variant) {
                 for ($i = 0; $i < $variant->cart_product_quantity; $i++) {
                     $data['units'] = 'kg';
                     $caracs = parent::_convertCharacteristics($variant, $data);
                     $current_package = parent::groupPackages($data, $caracs);
                     if ($data['weight'] + round($caracs['weight'], 2) > $limitation['weight'] || $current_package['tmpWidth'] > $limitation['length'] || $current_package['tmpHeight'] > $limitation['height'] || $current_package['tmpLength'] > $limitation['width']) {
                         if ($this->package_added == 0) {
                             $this->nbpackage++;
                         }
                         $data['XMLpackage'] .= $this->_createPackage($data, $product, $rate, $order);
                         $data['weight'] = round($caracs['weight'], 2);
                         $data['height'] = $current_package['y'];
                         $data['length'] = $current_package['z'];
                         $data['width'] = $current_package['x'];
                         $data['price'] = $variant->prices[0]->unit_price->price_value_with_tax;
                     } else {
                         $data['weight'] += round($caracs['weight'], 2);
                         $data['height'] = max($data['height'], $current_package['y']);
                         $data['length'] = max($data['length'], $current_package['z']);
                         $data['width'] += $current_package['x'];
                         $data['price'] += $variant->prices[0]->unit_price->price_value_with_tax;
                     }
                 }
             }
         } else {
             for ($i = 0; $i < $product->cart_product_quantity; $i++) {
                 $data['units'] = 'kg';
                 $caracs = parent::_convertCharacteristics($product, $data);
                 $current_package = parent::groupPackages($data, $caracs);
                 if ($data['weight'] + round($caracs['weight'], 2) > $limitation['weight'] || $current_package['tmpWidth'] > $limitation['length'] || $current_package['tmpHeight'] > $limitation['height'] || $current_package['tmpLength'] > $limitation['width']) {
                     if ($this->package_added == 0) {
                         $this->nbpackage++;
                     }
                     $data['XMLpackage'] .= $this->_createPackage($data, $product, $rate, $order);
                     $data['weight'] = round($caracs['weight'], 2);
                     $data['height'] = $current_package['y'];
                     $data['length'] = $current_package['z'];
                     $data['width'] = $current_package['x'];
                     $data['price'] = $product->prices[0]->price_value_with_tax;
                 } else {
                     $data['weight'] += round($caracs['weight'], 2);
                     $data['height'] = max($data['height'], $current_package['y']);
                     $data['length'] = max($data['length'], $current_package['z']);
                     $data['width'] += $current_package['x'];
                     $data['price'] += $product->prices[0]->price_value_with_tax;
                 }
             }
         }
     }
     if ($data['weight'] + $data['height'] + $data['length'] + $data['width'] > 0 && $this->package_added == 0) {
         $this->package_added = 1;
         $this->nbpackage++;
         $data['XMLpackage'][] = $this->_createPackage($data, $product, $rate, $order);
     }
     $usableMethods = $this->_RequestMethods($data, $data['XMLpackage']);
     return $usableMethods;
 }
Ejemplo n.º 6
0
    function _createPackage(&$data, &$product, &$rate, &$order, $includeDimension = false)
    {
        if (@$rate->shipping_params->exclude_dimensions == 1) {
            $includeDimension = false;
        }
        if (empty($data['weight'])) {
            $caracs = parent::_convertCharacteristics($product, $data);
            $data['weight_unit'] = $caracs['weight_unit'];
            $data['dimension_unit'] = $caracs['dimension_unit'];
            $data['weight'] = round($caracs['weight'], 2);
            $data['height'] = round($caracs['height'], 2);
            $data['length'] = round($caracs['length'], 2);
            $data['width'] = round($caracs['width'], 2);
        }
        $currencyClass = hikashop_get('class.currency');
        $config =& hikashop_config();
        $this->main_currency = $config->get('main_currency', 1);
        $currency = hikashop_getCurrency();
        if (isset($data['price'])) {
            $price = $data['price'];
        } else {
            $price = $product->prices[0]->unit_price->price_value;
        }
        if ($this->shipping_currency_id != $data['currency']) {
            $price = $currencyClass->convertUniquePrice($price, $this->shipping_currency_id, $data['currency']);
        }
        if (!empty($rate->shipping_params->weight_approximation)) {
            $data['weight'] = $data['weight'] + $data['weight'] * $rate->shipping_params->weight_approximation / 100;
        }
        if ($data['weight'] < 0.1) {
            $data['weight'] = 0.1;
        }
        if (!empty($rate->shipping_params->dim_approximation)) {
            $data['height'] = $data['height'] + $data['height'] * $rate->shipping_params->dim_approximation / 100;
            $data['length'] = $data['length'] + $data['length'] * $rate->shipping_params->dim_approximation / 100;
            $data['width'] = $data['width'] + $data['width'] * $rate->shipping_params->dim_approximation / 100;
        }
        $options = '';
        $dimension = '';
        if ($rate->shipping_params->include_price) {
            $options = '
	<PackageServiceOptions>
		<InsuredValue>
			<CurrencyCode>' . $data['currency_code'] . '</CurrencyCode>
			<MonetaryValue>' . $price . '</MonetaryValue>
		</InsuredValue>
	</PackageServiceOptions>';
        }
        if ($includeDimension) {
            $dimension = '
	<Dimensions>
		<UnitOfMeasurement>
			<Code>' . $data['dimension_unit'] . '</Code>
		</UnitOfMeasurement>
		<Length>' . round($data['length'], 2) . '</Length>
		<Width>' . round($data['width'], 2) . '</Width>
		<Height>' . round($data['height'], 2) . '</Height>
	</Dimensions>';
        }
        $xml = '
<Package>
	<PackagingType>
		<Code>02</Code>
	</PackagingType>
	<Description>Shop</Description>
' . $dimension . '
	<PackageWeight>
		<UnitOfMeasurement>
			<Code>' . $data['weight_unit'] . '</Code>
		</UnitOfMeasurement>
		<Weight>' . $data['weight'] . '</Weight>
	</PackageWeight>
' . $options . '
</Package>';
        return $xml;
    }
Ejemplo n.º 7
0
 function onShippingConfiguration(&$element)
 {
     $this->aupost2 = JRequest::getCmd('name', 'aupost2');
     $this->categoryType = hikashop_get('type.categorysub');
     $this->categoryType->type = 'tax';
     $this->categoryType->field = 'category_id';
     parent::onShippingConfiguration($element);
 }
 /**
  *
  */
 function onShippingConfigurationSave(&$element)
 {
     parent::onShippingConfigurationSave($element);
     if (!$this->init()) {
         return false;
     }
     $app = JFactory::getApplication();
     $db = JFactory::getDBO();
     $methods = array();
     if (empty($element->shipping_params->emc_login) || empty($element->shipping_params->emc_password) || empty($element->shipping_params->api_key) || empty($element->shipping_params->sender_lastname) || empty($element->shipping_params->sender_firstname) || empty($element->shipping_params->sender_email) || empty($element->shipping_params->sender_company) || empty($element->shipping_params->sender_phone) || empty($element->shipping_params->sender_address) || empty($element->shipping_params->sender_city) || empty($element->shipping_params->sender_postcode) || empty($element->shipping_params->sender_country)) {
         $app->enqueueMessage(JText::sprintf('ENTER_INFO', 'Envoimoinscher', JText::_('SENDER_INFORMATIONS') . ' (' . JText::_('HIKA_LOGIN') . ', ' . JText::_('HIKA_PASSWORD') . ', ' . JText::_('FEDEX_API_KEY') . ', ' . JText::_('LASTNAME') . ', ' . JText::_('FIRSTNAME') . ', ' . JText::_('HIKA_EMAIL') . ', ' . JText::_('COMPANY') . ', ' . JText::_('TELEPHONE') . ', ' . JText::_('ADDRESS') . ', ' . JText::_('CITY') . ', ' . JText::_('POST_CODE') . ', ' . JText::_('COUNTRY') . ')'));
     }
     // TODO : Refactor ! (use JRequest...)
     if (isset($_REQUEST['data']['shipping_methods'])) {
         foreach ($_REQUEST['data']['shipping_methods'] as $method) {
             foreach ($this->envoimoinscher_methods as $envoimoinscherMethod) {
                 $name = $envoimoinscherMethod['name'];
                 if ($name == $method['name']) {
                     $obj = new stdClass();
                     $methods[strip_tags($method['name'])] = strip_tags($envoimoinscherMethod['code']);
                 }
             }
         }
     } else {
         $app->enqueueMessage(JText::sprintf('CHOOSE_SHIPPING_SERVICE'));
     }
     $element->shipping_params->methodsList = serialize($methods);
     // we call the function of the library to get all the product categories and we display
     //
     if (!empty($element->shipping_params->emc_login) && !empty($element->shipping_params->emc_password) && !empty($element->shipping_params->api_key)) {
         $contentCl = new Env_ContentCategory(array('user' => @$element->shipping_params->emc_login, 'pass' => @$element->shipping_params->emc_password, 'key' => @$element->shipping_params->api_key));
         $config = hikashop_config();
         $contentCl->setPlatformParams('hikashop', $config->get('version'), $config->get('version'));
         $contentCl->setEnv($element->shipping_params->environment);
         $contentCl->getCategories();
         @$contentCl->getContents();
         $element->shipping_params->contentCl = array('categories' => $contentCl->categories, 'contents' => $contentCl->contents);
         if (!empty($contentCl->curlErrorText)) {
             $app->enqueueMessage($contentCl->curlErrorText, 'error');
         }
         if (!empty($contentCl->respErrorsList)) {
             foreach ($contentCl->respErrorsList as $err) {
                 $app->enqueueMessage('[ ' . $err['code'] . ' ] ' . $err['message'], 'error');
             }
         }
     }
     $czone_code = @$element->shipping_params->sender_country;
     if (!empty($czone_code)) {
         $query = 'SELECT zone_id, zone_code_2 FROM ' . hikashop_table('zone') . ' WHERE zone_namekey = ' . $db->Quote($czone_code);
         $db->setQuery($query);
         $czone = $db->loadObject();
         $country = $czone->zone_code_2;
         if ($country == 'FX') {
             $country = 'FR';
         }
         // To display the drop off points for each service in the config
         $lpCl = new Env_ListPoints(array('user' => $element->shipping_params->emc_login, 'pass' => $element->shipping_params->emc_password, 'key' => $element->shipping_params->api_key));
         $config = hikashop_config();
         $lpCl->setPlatformParams('hikashop', $config->get('version'), $config->get('version'));
         // environment 'test' or 'prod'
         $lpCl->setEnv($element->shipping_params->environment);
         foreach ($methods as $name => $code) {
             $params = array('srv_code' => $name, 'collecte' => 'exp', 'pays' => $country, 'cp' => $element->shipping_params->sender_postcode, 'ville' => $element->shipping_params->sender_city);
             $lpCl->getListPoints($code, $params);
             if (!$lpCl->curlError && !$lpCl->respError) {
                 $element->shipping_params->envoimoinscher_dropoff[$code] = $lpCl->listPoints;
                 unset($lpCl->listPoints);
                 $lpCl->listPoints = array();
             }
         }
         if (!empty($lpCl->curlErrorText)) {
             $app->enqueueMessage($lpCl->curlErrorText, 'error');
         }
         if (!empty($lpCl->respErrorsList)) {
             foreach ($lpCl->respErrorsList as $err) {
                 $app->enqueueMessage('[ ' . $err['code'] . ' ] ' . $err['message'], 'error');
             }
         }
     }
     return true;
 }
Ejemplo n.º 9
0
 function onShippingConfiguration(&$element)
 {
     $app = JFactory::getApplication();
     $app->enqueueMessage('That Australia Post shipping version is deprecated and is using the old Australia post API, Please start using the new Australia Post v2 shipping method');
     $this->aupost = JRequest::getCmd('name', 'aupost');
     $this->categoryType = hikashop_get('type.categorysub');
     $this->categoryType->type = 'tax';
     $this->categoryType->field = 'category_id';
     parent::onShippingConfiguration($element);
 }
Ejemplo n.º 10
0
 function processPackageLimit($limit_key, $limit_value, $product, $qty, $package, $units)
 {
     switch ($limit_key) {
         case 'length_width_height':
             $divide = $product['x'] + $product['y'] + $product['z'];
             if (!$divide || $divide > $limit_value) {
                 return false;
             }
             return (int) floor($limit_value / $divide);
             break;
         case 'length_girth':
             $divide = $product['z'] + ($product['x'] + $product['y']) * 2;
             if (!$divide || $divide > $limit_value) {
                 return false;
             }
             return (int) floor($limit_value / $divide);
             break;
     }
     return parent::processPackageLimit($limit_key, $limit_value, $product, $qty, $package, $units);
 }