Colissimo fix routing.xml, thelia.sql and adding "Activate free shipping" option

new file:   local/modules/Colissimo/AdminIncludes/module-config-js.html
	modified:   local/modules/Colissimo/AdminIncludes/module_configuration.html
	modified:   local/modules/Colissimo/Colissimo.php
	modified:   local/modules/Colissimo/Config/config.xml
	modified:   local/modules/Colissimo/Config/routing.xml
	new file:   local/modules/Colissimo/Config/schema.xml
	modified:   local/modules/Colissimo/Config/thelia.sql
	new file:   local/modules/Colissimo/Controller/FreeShipping.php
	new file:   local/modules/Colissimo/Form/FreeShipping.php
	modified:   local/modules/Colissimo/I18n/en_US.php
	modified:   local/modules/Colissimo/I18n/fr_FR.php
	new file:   local/modules/Colissimo/Model/Base/ColissimoFreeshipping.php
	new file:   local/modules/Colissimo/Model/Base/ColissimoFreeshippingQuery.php
	new file:   local/modules/Colissimo/Model/ColissimoFreeshipping.php
	new file:   local/modules/Colissimo/Model/ColissimoFreeshippingQuery.php
	new file:   local/modules/Colissimo/Model/Map/ColissimoFreeshippingTableMap.php
This commit is contained in:
Benjamin Perche
2014-02-19 11:49:04 +01:00
parent d00bc84cd5
commit ce9a1bb519
16 changed files with 2642 additions and 115 deletions

View File

@@ -23,6 +23,7 @@
namespace Colissimo;
use Colissimo\Model\ColissimoFreeshippingQuery;
use Propel\Runtime\Connection\ConnectionInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
@@ -59,34 +60,38 @@ class Colissimo extends BaseModule implements DeliveryModuleInterface
*/
public static function getPostageAmount($areaId, $weight)
{
$prices = self::getPrices();
$freeshipping = ColissimoFreeshippingQuery::create()->getLast();
$postage=0;
if(!$freeshipping) {
$prices = self::getPrices();
/* check if Colissimo delivers the asked area */
if(!isset($prices[$areaId]) || !isset($prices[$areaId]["slices"])) {
throw new OrderException("Colissimo delivery unavailable for the chosen delivery country", OrderException::DELIVERY_MODULE_UNAVAILABLE);
}
/* check if Colissimo delivers the asked area */
if(!isset($prices[$areaId]) || !isset($prices[$areaId]["slices"])) {
throw new OrderException("Colissimo delivery unavailable for the chosen delivery country", OrderException::DELIVERY_MODULE_UNAVAILABLE);
}
$areaPrices = $prices[$areaId]["slices"];
ksort($areaPrices);
$areaPrices = $prices[$areaId]["slices"];
ksort($areaPrices);
/* check this weight is not too much */
end($areaPrices);
$maxWeight = key($areaPrices);
if($weight > $maxWeight) {
throw new OrderException(sprintf("Colissimo delivery unavailable for this cart weight (%s kg)", $weight), OrderException::DELIVERY_MODULE_UNAVAILABLE);
}
$postage = current($areaPrices);
while(prev($areaPrices)) {
if($weight > key($areaPrices)) {
break;
/* check this weight is not too much */
end($areaPrices);
$maxWeight = key($areaPrices);
if($weight > $maxWeight) {
throw new OrderException(sprintf("Colissimo delivery unavailable for this cart weight (%s kg)", $weight), OrderException::DELIVERY_MODULE_UNAVAILABLE);
}
$postage = current($areaPrices);
}
while(prev($areaPrices)) {
if($weight > key($areaPrices)) {
break;
}
$postage = current($areaPrices);
}
}
return $postage;
}
public function setRequest(Request $request)