Colissimo in progress
This commit is contained in:
@@ -279,12 +279,13 @@ class Order extends BaseAction implements EventSubscriberInterface
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::CART_CLEAR, new CartEvent($this->getCart($this->getRequest())));
|
||||
|
||||
/* call pay method */
|
||||
$paymentModuleReflection = new \ReflectionClass($paymentModule->getFullNamespace());
|
||||
/*$paymentModuleReflection = new \ReflectionClass($paymentModule->getFullNamespace());
|
||||
$paymentModuleInstance = $paymentModuleReflection->newInstance();
|
||||
|
||||
$paymentModuleInstance->setRequest($this->getRequest());
|
||||
$paymentModuleInstance->setDispatcher($this->getDispatcher());
|
||||
$paymentModuleInstance->setDispatcher($this->getDispatcher());*/
|
||||
|
||||
$paymentModuleInstance = $this->container->get(sprintf('module.%s', $paymentModule->getCode()));
|
||||
$paymentModuleInstance->pay($placedOrder);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,8 +84,10 @@ class OrderController extends BaseFrontController
|
||||
}
|
||||
|
||||
/* get postage amount */
|
||||
$moduleReflection = new \ReflectionClass($deliveryModule->getFullNamespace());
|
||||
$moduleInstance = $moduleReflection->newInstance();
|
||||
/*$moduleReflection = new \ReflectionClass($deliveryModule->getFullNamespace());
|
||||
$moduleInstance = $moduleReflection->newInstance();*/
|
||||
|
||||
$moduleInstance = $this->container->get(sprintf('module.%s', $deliveryModule->getCode()));
|
||||
$postage = $moduleInstance->getPostage($deliveryAddress->getCountry());
|
||||
|
||||
$orderEvent = $this->getOrderEvent();
|
||||
|
||||
@@ -25,8 +25,10 @@ namespace Thelia\Core\Template\Loop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Exception\OrderException;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Module\BaseModule;
|
||||
use Thelia\Module\DeliveryModuleInterface;
|
||||
|
||||
/**
|
||||
* Class Delivery
|
||||
@@ -63,14 +65,24 @@ class Delivery extends BaseSpecificModule
|
||||
foreach ($loopResult->getResultDataCollection() as $deliveryModule) {
|
||||
$loopResultRow = new LoopResultRow($deliveryModule);
|
||||
|
||||
$moduleReflection = new \ReflectionClass($deliveryModule->getFullNamespace());
|
||||
if ($moduleReflection->isSubclassOf("Thelia\Module\DeliveryModuleInterface") === false) {
|
||||
$moduleInstance = $this->container->get(sprintf('module.%s', $deliveryModule->getCode()));
|
||||
|
||||
if (false === $moduleInstance instanceof DeliveryModuleInterface) {
|
||||
throw new \RuntimeException(sprintf("delivery module %s is not a Thelia\Module\DeliveryModuleInterface", $deliveryModule->getCode()));
|
||||
}
|
||||
$moduleInstance = $moduleReflection->newInstance();
|
||||
|
||||
$moduleInstance->setRequest($this->request);
|
||||
$moduleInstance->setDispatcher($this->dispatcher);
|
||||
try {
|
||||
$postage = $moduleInstance->getPostage($country);
|
||||
} catch(OrderException $e) {
|
||||
switch($e->getCode()) {
|
||||
case OrderException::DELIVERY_MODULE_UNAVAILABLE:
|
||||
/* do not show this delivery module */
|
||||
continue(2);
|
||||
break;
|
||||
default:
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
$loopResultRow
|
||||
->set('ID', $deliveryModule->getId())
|
||||
@@ -78,7 +90,7 @@ class Delivery extends BaseSpecificModule
|
||||
->set('CHAPO', $deliveryModule->getVirtualColumn('i18n_CHAPO'))
|
||||
->set('DESCRIPTION', $deliveryModule->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set('POSTSCRIPTUM', $deliveryModule->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set('POSTAGE', $moduleInstance->getPostage($country))
|
||||
->set('POSTAGE', $postage)
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
|
||||
@@ -26,6 +26,7 @@ use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Module\BaseModule;
|
||||
use Thelia\Module\PaymentModuleInterface;
|
||||
|
||||
/**
|
||||
* Class Payment
|
||||
@@ -47,14 +48,11 @@ class Payment extends BaseSpecificModule implements PropelSearchLoopInterface
|
||||
foreach ($loopResult->getResultDataCollection() as $paymentModule) {
|
||||
$loopResultRow = new LoopResultRow($paymentModule);
|
||||
|
||||
$moduleReflection = new \ReflectionClass($paymentModule->getFullNamespace());
|
||||
if ($moduleReflection->isSubclassOf("Thelia\Module\PaymentModuleInterface") === false) {
|
||||
$moduleInstance = $this->container->get(sprintf('module.%s', $paymentModule->getCode()));
|
||||
|
||||
if (false === $moduleInstance instanceof PaymentModuleInterface) {
|
||||
throw new \RuntimeException(sprintf("payment module %s is not a Thelia\Module\PaymentModuleInterface", $paymentModule->getCode()));
|
||||
}
|
||||
$moduleInstance = $moduleReflection->newInstance();
|
||||
|
||||
$moduleInstance->setRequest($this->request);
|
||||
$moduleInstance->setDispatcher($this->dispatcher);
|
||||
|
||||
$loopResultRow
|
||||
->set('ID', $paymentModule->getId())
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace Thelia\Core;
|
||||
use Propel\Runtime\Connection\ConnectionWrapper;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
@@ -134,7 +135,7 @@ class Thelia extends Kernel
|
||||
|
||||
$defintion = new Definition();
|
||||
$defintion->setClass($module->getFullNamespace());
|
||||
$defintion->addMethodCall("setContainer", array('service_container'));
|
||||
$defintion->addMethodCall("setContainer", array(new Reference('service_container')));
|
||||
|
||||
$container->setDefinition(
|
||||
"module.".$module->getCode(),
|
||||
|
||||
@@ -38,6 +38,7 @@ class OrderException extends \RuntimeException
|
||||
const CART_EMPTY = 100;
|
||||
|
||||
const UNDEFINED_DELIVERY = 200;
|
||||
const DELIVERY_MODULE_UNAVAILABLE = 201;
|
||||
|
||||
public function __construct($message, $code = null, $arguments = array(), $previous = null)
|
||||
{
|
||||
|
||||
@@ -112,4 +112,18 @@ class Cart extends BaseCart
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
public function getWeight()
|
||||
{
|
||||
$weight = 0;
|
||||
|
||||
foreach($this->getCartItems() as $cartItem) {
|
||||
$itemWeight = $cartItem->getProductSaleElements()->getWeight();
|
||||
$itemWeight *= $cartItem->getQuantity();
|
||||
|
||||
$weight += $itemWeight;
|
||||
}
|
||||
|
||||
return $weight;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user