Skip to content

Commit a7439a9

Browse files
committed
updated docs for multi cart instance
1 parent 6c0974c commit a7439a9

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,8 +599,50 @@ $this->app['wishlist'] = $this->app->share(function($app)
599599
$session_key
600600
);
601601
});
602+
603+
// for 5.4 or newer
604+
use Darryldecode\Cart\Cart;
605+
use Illuminate\Support\ServiceProvider;
606+
607+
class WishListProvider extends ServiceProvider
608+
{
609+
/**
610+
* Bootstrap the application services.
611+
*
612+
* @return void
613+
*/
614+
public function boot()
615+
{
616+
//
617+
}
618+
/**
619+
* Register the application services.
620+
*
621+
* @return void
622+
*/
623+
public function register()
624+
{
625+
$this->app->singleton('wishlist', function($app)
626+
{
627+
$storage = $app['session'];
628+
$events = $app['events'];
629+
$instanceName = 'cart_2';
630+
$session_key = '88uuiioo99888';
631+
return new Cart(
632+
$storage,
633+
$events,
634+
$instanceName,
635+
$session_key,
636+
config('shopping_cart')
637+
);
638+
});
639+
}
640+
}
602641
```
603642

643+
IF you are having problem with multiple cart instance, please see the codes on
644+
this demo repo here: [DEMO](https://github.com/darryldecode/laravelshoppingcart-demo)
645+
604646
## Exceptions
605647

606648
There are currently only two exceptions.

0 commit comments

Comments
 (0)