fix cart item prices when not on default currency

This commit is contained in:
Julien Chanséaume
2014-04-25 16:52:05 +02:00
parent cb42c17d25
commit b86ac88ce4
13 changed files with 193 additions and 24 deletions

View File

@@ -0,0 +1,52 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Core\Event\Currency;
use Thelia\Core\HttpFoundation\Request;
use Thelia\Model\Currency;
/**
* Class CurrencyChangeEvent
* @package Thelia\Core\Event\Currency
* @author Julien Chanséaume <jchanseaume@openstudio.fr>
*/
class CurrencyChangeEvent extends CurrencyEvent
{
/** @var Request $request */
protected $request;
public function __construct(Currency $currency = null, Request $request = null)
{
parent::__construct($currency);
$this->setRequest($request);
}
/**
* @param Request $request
*/
public function setRequest(Request $request)
{
$this->request = $request;
return $this;
}
/**
* @return Request
*/
public function getRequest()
{
return $this->request;
}
}

View File

@@ -184,7 +184,7 @@ abstract class BaseLoop
'%name' => $loopName
]
);
} else if ($value === '') {
} elseif ($value === '') {
if (!$argument->empty) {
/* check if empty */
$faultActor[] = $argument->name;

View File

@@ -50,11 +50,11 @@ class TemplateHelper
/**
* Check if a template definition is the current active template
*
* @param TemplateDefinition $tplDefinition
* @return bool true is the given template is the active template
* @param TemplateDefinition $tplDefinition
* @return bool true is the given template is the active template
*/
public function isActive(TemplateDefinition $tplDefinition) {
public function isActive(TemplateDefinition $tplDefinition)
{
switch ($tplDefinition->getType()) {
case TemplateDefinition::FRONT_OFFICE:
$tplVar = 'active-front-template';

View File

@@ -22,7 +22,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Session;
use Thelia\Core\Event\Currency\CurrencyEvent;
use Thelia\Core\Event\Currency\CurrencyChangeEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Model;
@@ -142,7 +142,7 @@ class TheliaHttpKernel extends HttpKernel
if ($request->query->has("currency")) {
$currency = Model\CurrencyQuery::create()->findOneByCode($request->query->get("currency"));
if ($currency) {
$this->container->get("event_dispatcher")->dispatch(TheliaEvents::CHANGE_DEFAULT_CURRENCY, new CurrencyEvent($currency));
$this->container->get("event_dispatcher")->dispatch(TheliaEvents::CHANGE_DEFAULT_CURRENCY, new CurrencyChangeEvent($currency, $request));
}
} else {
$currency = $request->getSession()->getCurrency(false);