Support the ongoing development of Laravel.io →
posted 3 weeks ago
Vue.js
Last updated by @mohamed-galdi 2 weeks ago.
0

I found a workaround for this issue! If anyone else is facing the same problem, here’s what worked for me:

I used Inertia’s partial reloads with the navigate event to update the cart data whenever the browser's back button is used. Here’s the code I added to my layout:

import { router } from '@inertiajs/vue3';

router.on('navigate', () => {
    router.reload({ only: ['cart'] });
});

This ensures the cart prop is refreshed without requiring a full page reload. It fixed the stale cart count issue for me. Hope this helps someone!

0
Solution selected by @mohamed-galdi

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.