Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Evie's avatar
Level 3

Changing currency on blade

Hi,

I am using stripe for ecommerce, in my settings I have changed the currency to display GBP instead USD which works great for billing but on the membership page where I am displaying a list of memberships it still displays in dollars.


    <div class="row justify-content-center">
        <div class="col-md-12">
            <div class="card">
               

                  @if(!auth()->user()->subscription('main'))
                    <div class="card-header">Memberships (Your current plan: {{$profile->membership->name}})</div>
                  @else
                      @if(!auth()->user()->subscription('main')->cancelled())
                        <div class="card-header">Memberships (Your are subscribed to {{$profile->membership->name}})</div>
                      @elseif(auth()->user()->subscription('main')->onGracePeriod())
                        <div class="card-header">Memberships (Your have changed your plan from {{$profile->membership->name}} to Free)</div>
                      @elseif(auth()->user()->subscription('main')->ended())
                        <div class="card-header">Memberships (Your current plan: {{$profile->membership->name}}) (it has ENDED)</div>
                      @endif
                  @endif

                <div class="card-body">
                    <ul class="list-group">
                        @foreach($memberships as $membership)
                        <li class="list-group-item clearfix">
                            <div class="pull-left">
                                <h1>{{$membership->name }}</h1>
                                <h1>${{$membership->cost}}</h1>
                                <ul style="padding: 2%;">
                                  @if (!empty($membership->desc_1))<li>{{$membership->desc_1 }}</li> @endif
                                  @if (!empty($membership->desc_2))<li>{{$membership->desc_2 }}</li> @endif
                                  @if (!empty($membership->desc_3))<li>{{$membership->desc_3 }}</li> @endif
                                  @if (!empty($membership->desc_4))<li>{{$membership->desc_4 }}</li> @endif
                                  @if (!empty($membership->desc_5))<li>{{$membership->desc_5 }}</li> @endif
                                  @if (!empty($membership->desc_6))<li>{{$membership->desc_6 }}</li> @endif
                                  @if (!empty($membership->desc_7))<li>{{$membership->desc_7 }}</li> @endif
                                </ul> 

                                @if(!auth()->user()->subscription('main'))

                                  <a href="/membership/{{$membership->slug}}" class="text-capitalize btn btn-primary btn-cta-read rounded-0 btn-lg pull-right">Choose</a>
                                @else
                                  @if(!auth()->user()->subscription('main')->cancelled())
                                      <a href="/membership/{{$membership->slug}}/edit" class="text-capitalize btn btn-primary btn-cta-read rounded-0 btn-lg pull-right">Update Plan</a>
                                  @else
                                    <a href="/membership/{{$membership->slug}}" class="text-capitalize btn btn-primary btn-cta-read rounded-0 btn-lg pull-right">Choose</a>

                                  @endif
                                @endif

                            </div>
                        </li>
                        @endforeach
                    </ul>
                </div>
            </div>
        </div>
    </div>

I have looked into localization for laravel but it only seems to have information about languages I can't seem to find much on currency or at least a solution that works.

Has anyone come across this issue?

0 likes
6 replies
steve_laracasts's avatar

Did you set:

Laravel\Cashier\Cashier::useCurrency('eur', '€'

in your booted method of your App\Providers\SparkServiceProvide

Evie's avatar
Level 3

I don't have App\Providers\SparkServiceProvide I have tried that in my App\Providers\AppServiceProvider and it seemed to break the ecommerce side of things completely

steve_laracasts's avatar
Level 7

Sorry, I totally read Stripe as Spark!!

Looking at the code it would seem that the currency symbol is contained in ${{$membership->cost}}

In which case, just try swapping the first $ for a £?

It's kinda subtle, it reads like a variable at first, but it's not, it's a currency symbol!

deansatch's avatar

YOu could try just using app()->isLocale($locale) or app()->getLocale() to compare against a locale column in a locale_settings database table. i.e. you can have a table with columns locale, currency, currency_symbol, vat_rat etc...

e.g. (in a very basic sense)


$localesettings = LocaleSetting::where('locale', app()->getLocale() )->first();
return $localesettings->currency_symbol;

Alternatively you could hard code it in the config/laravellocaization.php file. So just add the currency & symbol to each uncommented country in the array...that way you have access to them with...


$locales = \LaravelLocalization::getSupportedLocales();

            foreach ($locales as $key => $val) {
                if ($key == app()->getLocale() ) {
                    $currency_symbol = $val['currency_symbol'];
                    break;
                }
            }

Evie's avatar
Level 3

@DEANSATCH - thanks for taking the time to look at my code reply...I think I tried something similar to that but of course it didn't work as the $ symbol seemed to be actually hard coded as pointed out by @kel_

Please or to participate in this conversation.