// Merge -> revision 9124
This commit is contained in:
@@ -39,7 +39,7 @@ switch (Tools::getValue('method'))
|
||||
die(Tools::jsonEncode($carrierCompare->getStatesByIdCountry((int)Tools::getValue('id_country'))));
|
||||
break;
|
||||
case 'getCarriers':
|
||||
die(Tools::jsonEncode($carrierCompare->getCarriersListByIdZone((int)Tools::getValue('id_country'), (int)Tools::getValue('id_state', 0))));
|
||||
die(Tools::jsonEncode($carrierCompare->getCarriersListByIdZone((int)Tools::getValue('id_country'), (int)Tools::getValue('id_state', 0), Tools::safeOutput(Tools::getValue('zipcode', 0)))));
|
||||
break;
|
||||
case 'saveSelection':
|
||||
$errors = $carrierCompare->saveSelection((int)Tools::getValue('id_country'), (int)Tools::getValue('id_state', 0), Tools::getValue('zipcode', 0), (int)Tools::getValue('id_carrier', 0));
|
||||
|
||||
@@ -51,7 +51,7 @@ function updateCarriersList()
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: baseDir + 'modules/carriercompare/ajax.php',
|
||||
data: 'method=getCarriers&id_country=' + $('#id_country').val()+'&id_state=' + $('#id_state').val(),
|
||||
data: 'method=getCarriers&id_country=' + $('#id_country').val() + '&id_state=' + $('#id_state').val() + '&zipcode=' + $('#zipcode').val(),
|
||||
dataType: 'json',
|
||||
success: function(json) {
|
||||
$('#carriers_list').children().remove();
|
||||
@@ -135,4 +135,4 @@ $(document).ready(function() {
|
||||
});
|
||||
updateStateByIdCountry();
|
||||
updateCarriersList();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -34,7 +34,7 @@ class CarrierCompare extends Module
|
||||
{
|
||||
$this->name = 'carriercompare';
|
||||
$this->tab = 'shipping_logistics';
|
||||
$this->version = '1.0';
|
||||
$this->version = '1.1';
|
||||
$this->author = 'PrestaShop';
|
||||
$this->need_instance = 0;
|
||||
|
||||
@@ -96,8 +96,15 @@ class CarrierCompare extends Module
|
||||
/*
|
||||
** Get carriers by country id, called by the ajax process
|
||||
*/
|
||||
public function getCarriersListByIdZone($id_country, $id_state = 0)
|
||||
public function getCarriersListByIdZone($id_country, $id_state = 0, $zipcode = 0)
|
||||
{
|
||||
// cookie saving/updating
|
||||
$this->context->cookie->id_country = $id_country;
|
||||
if ($id_state != 0)
|
||||
$this->context->cookie->id_state = $id_state;
|
||||
if ($zipcode != 0)
|
||||
$this->context->cookie->postcode = $zipcode;
|
||||
|
||||
$id_zone = 0;
|
||||
if ($id_state != 0)
|
||||
$id_zone = State::getIdZone($id_state);
|
||||
@@ -106,7 +113,7 @@ class CarrierCompare extends Module
|
||||
|
||||
$carriers = Carrier::getCarriersForOrder((int)$id_zone);
|
||||
|
||||
return (sizeof($carriers) ? $carriers : array());
|
||||
return (count($carriers) ? $carriers : array());
|
||||
}
|
||||
|
||||
public function saveSelection($id_country, $id_state, $zipcode, $id_carrier)
|
||||
@@ -128,7 +135,7 @@ class CarrierCompare extends Module
|
||||
return $errors;
|
||||
|
||||
$ids_carrier = array();
|
||||
foreach (self::getCarriersListByIdZone($id_country, $id_state) as $carrier)
|
||||
foreach (self::getCarriersListByIdZone($id_country, $id_state, $zipcode) as $carrier)
|
||||
$ids_carrier[] = $carrier['id_carrier'];
|
||||
if (!in_array($id_carrier, $ids_carrier))
|
||||
$errors[] = $this->l('This carrier ID isn\'t available for your selection');
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
|
||||
<p>
|
||||
<label for="zipcode">{l s='Zipcode' mod='carriercompare'}</label>
|
||||
<input type="text" name="zipcode" id="zipcode" value="{$zipcode|escape:'htmlall':'UTF-8'}"/>
|
||||
<input type="text" name="zipcode" id="zipcode" value="{$zipcode|escape:'htmlall':'UTF-8'}"/> ({l s='Needed for certain carriers' mod='carriercompare'})
|
||||
</p>
|
||||
|
||||
<div id="availableCarriers" style="display: none;">
|
||||
@@ -88,8 +88,8 @@
|
||||
<p class="warning center" id="noCarrier" style="display: none;">{l s='No carrier is available for this selection' mod='carriercompare'}</p>
|
||||
|
||||
<p class="center">
|
||||
<input class="exclusive_large" id="carriercompare_submit" type="submit" name="carriercompare_submit" value="{l s='Update my shipping option' mod='carriercompare'}"/>
|
||||
<input class="exclusive_large" id="carriercompare_submit" type="submit" name="carriercompare_submit" value="{l s='Refresh' mod='carriercompare'}"/>
|
||||
</p>
|
||||
</fieldset>
|
||||
</form>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<module>
|
||||
<name>carriercompare</name>
|
||||
<displayName><![CDATA[Shipping Estimation]]></displayName>
|
||||
<version><![CDATA[1.0]]></version>
|
||||
<version><![CDATA[1.1]]></version>
|
||||
<description><![CDATA[Module to compare carrier possibilities before using the checkout process]]></description>
|
||||
<author><![CDATA[PrestaShop]]></author>
|
||||
<tab><![CDATA[shipping_logistics]]></tab>
|
||||
|
||||
Reference in New Issue
Block a user