fix cart item prices when not on default currency
This commit is contained in:
52
core/lib/Thelia/Core/Event/Currency/CurrencyChangeEvent.php
Normal file
52
core/lib/Thelia/Core/Event/Currency/CurrencyChangeEvent.php
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -184,7 +184,7 @@ abstract class BaseLoop
|
||||
'%name' => $loopName
|
||||
]
|
||||
);
|
||||
} else if ($value === '') {
|
||||
} elseif ($value === '') {
|
||||
if (!$argument->empty) {
|
||||
/* check if empty */
|
||||
$faultActor[] = $argument->name;
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user