# Switch Currency According to customer country.

**URL:** <https://forum.shopware.com/t/switch-currency-according-to-customer-country/60753>\
**Category:** Programming (EN)\
**Created:** [31. Juli 2019 um 07:08 UTC](https://forum.shopware.com/t/switch-currency-according-to-customer-country/60753 "2019-07-31T07:08:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shakil2nd](https://avatars.discourse-cdn.com/v4/letter/s/2acd7d/32.png) [@shakil2nd](https://forum.shopware.com/u/shakil2nd)\
**Post date:** [31. Juli 2019 um 07:08 UTC](https://forum.shopware.com/t/switch-currency-according-to-customer-country/60753/1 "2019-07-31T07:08:32Z")

</div>

I am making a plugin which ensure currency according to country when customer logged in. Currently, I am facing an issue, I have register a subscriber and try to find “CUSTOMER\_LOGIN\_EVENT” but when I logged in, My plugin has not been able to trigger that event.

Can anybuddy help me on this.

![](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/a/a144095162878f5b3c6e1cbdba1434ebf5948ea7.png)

 ![](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/a/a0e7e589d9b8f53dcd37a4df096f20b7748819ea.png)

&nbsp;

 ![](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/6/6c4dd1270fbc0c61165d7e7eb5c770671ee3e691.png)

---

<div class="post-metadata">

**Author:** ![Michael\_Telgmann](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/michael_telgmann/32/20289_2.png) [@Michael\_Telgmann](https://forum.shopware.com/u/Michael_Telgmann)\
**Post date:** [31. Juli 2019 um 08:41 UTC](https://forum.shopware.com/t/switch-currency-according-to-customer-country/60753/2 "2019-07-31T08:41:39Z")

</div>

Hello,  
did you ensured that your plugin is installed and activated correctly? Try also to clear the cache after you activated your plugin. The code looks good for me.&nbsp;

Best regards from Schöppingen

![cool](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/1X/86c57fbace799dd4eb1f1b8a2d3bdc1733f0aea1.png "cool")&nbsp;Michael Telgmann

---

<div class="post-metadata">

**Author:** ![shakil2nd](https://avatars.discourse-cdn.com/v4/letter/s/2acd7d/32.png) [@shakil2nd](https://forum.shopware.com/u/shakil2nd)\
**Post date:** [31. Juli 2019 um 10:55 UTC](https://forum.shopware.com/t/switch-currency-according-to-customer-country/60753/3 "2019-07-31T10:55:56Z")

</div>

Hello Michael,

**Git Hub link**

[https://github.com/shakil2nd/switch-currency-plugin](https://github.com/shakil2nd/switch-currency-plugin)

**Core Idea of Plugin**

I need to make that plugin to switch currency according to the country when customer logged in to his/her&nbsp; account. if customer logged in with the his/her default&nbsp;country USA so customer see defult currency dollar and if customer logged in using his/her default&nbsp;country Germany so customer see Euro as a default currency.

**What I did**

I selected to use ‘CUSTOMER\_LOGIN\_EVENT’ but when I logged in to my account it&nbsp;did not&nbsp;trigger that event so my function which I added on subscrivber not working.&nbsp;

Kindly, also help me out how to updated and selected default currency which is on the top header section using that subscriber event when customer logged in.

Thanks,

Shakeel

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![Michael\_Telgmann](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/michael_telgmann/32/20289_2.png) [@Michael\_Telgmann](https://forum.shopware.com/u/Michael_Telgmann)\
**Post date:** [31. Juli 2019 um 12:17 UTC](https://forum.shopware.com/t/switch-currency-according-to-customer-country/60753/4 "2019-07-31T12:17:11Z")

</div>

Hello Shakeel,

the event name you subscribed to, was wrong. Also the typehint on your callback method. Here is the fix:

```
namespace Bc\BrandCrockCurrencySwitch\Subscriber;

use Shopware\Core\Checkout\Customer\Event\CustomerLoginEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class MySubscriber implements EventSubscriberInterface
{
    public static function getSubscribedEvents(): array
    {
        return[
            CustomerLoginEvent::class => 'onAccountLoaded'
        ];
    }

    public function onAccountLoaded(CustomerLoginEvent $event)
    {
        echo 'MySubscriber.php Zeile: 21';
        dd($event);

        // ...
    }
}

```

In most cases we only dispatch the event object through the Symfony EventDispatcher, therefore you have to subscribe to the class name of the event.&nbsp;

Best regards from Schöppingen

![cool](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/1X/86c57fbace799dd4eb1f1b8a2d3bdc1733f0aea1.png "cool")&nbsp;Michael Telgmann

---

<div class="post-metadata">

**Author:** ![shakil2nd](https://avatars.discourse-cdn.com/v4/letter/s/2acd7d/32.png) [@shakil2nd](https://forum.shopware.com/u/shakil2nd)\
**Post date:** [4. August 2019 um 21:27 UTC](https://forum.shopware.com/t/switch-currency-according-to-customer-country/60753/5 "2019-08-04T21:27:55Z")

</div>

Hi,

Need help to resolve this task.

I am trying to get address update event (When any one change his/her addresses). How can I get that event on subscriber?&nbsp;

Please Help me out on this

Example (just for assumption i gave this example):

```
public static function getSubscribedEvents(): array {

return[CustomerAddressUpdateEvent::class => 'onCustomerAdressUpdated'];

}

```

 ![](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/7/74afe5515b932b9f2b6c257a47323a38270e167f.png)

Thanks,

Shakeel
