Skip to content

Performance issue duplicate query when use cart() helper #22

@vanthao03596

Description

@vanthao03596

Describe the bug
cart() helper hit database query every time.
example:
protected function getCartDetails() { return [ 'items' => cart()->items($displayCurrency = true), 'totals' => cart()->totals(), ]; }
This function will hit database multiple times.
To Reproduce
Steps to reproduce the behavior:

  1. Clone demo
  2. Install debugbar
  3. We will see duplicate query

Expected behavior
No duplicate query during request

Screenshots
1

Additional context
Suguest fix: Change bind to singleton in CartManagerServiceProvider

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions