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!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community