Download the PHP package slim-gee/dbcart-laravel without Composer

On this page you can find all versions of the php package slim-gee/dbcart-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package dbcart-laravel

DBCart

Shopping Cart library for Laravel > 5.5 and Laravel 6 that uses database instead of sessions to store carts.

Features

Before installation

if you already use dbcart by Hassansin, please skip DB migrations and publishing configuration. This package is fully compatible.

Installation

  1. Install the package via composer:

    The package will automatically register itself.

  2. Publish database migrations(IF YOU USE dbcart:

    After the migration has been published you can create the cart and cart_lines tables by running the migrations:

Configuration

Optionally, you can publish package config file:

Now, update config/cart.php if required

Usage

Get Cart Instance:

Get the current cart instance. It returns a singleton cart instance:

or,

alternatively, you can avoid singleton instance and use the model class to load the cart instance from database everytime:

The idea of using singleton cart is that the cart object will be available globally throughout your app (e.g. controllers/models/views/view composers etc) for a single request. Also as you manipulate cart items, $cart->item_count and $cart->total_price would get updated.

Add an Item: $cart->addItem($attributes)

which is equivalent to $cart->items()->create($attributes)

Get Items: $cart->items

Since $cart is eloquent model instance, you can use any of the eloquent methods to get items

Update an Item: $cart->updateItem($where, $attributes)

which is equivalent to $cart->items()->where($where)->first()->update($attributes)

Remove an Item: $cart->removeItem($where)

which is equivalent to $cart->items()->where($where)->first()->delete()

Clear Cart Items: $cart->clear()

Remove all items from the cart

Checkout cart: $cart->checkout()

This method only updates status and placed_at column values. status is set to pending

Move item(s) between carts:

To move all items from one cart to another cart instance:

To move a single item between carts:

Get Cart Attributes

Cart Statuses

Supports several cart statuses:

Working with Multiple Cart Instances

By default, cart instances are named as default. You can load other instances by providing a name:

or, without singleton carts:

To get carts other than default:

Delete Expired Carts:

The guest carts depend on the session lifetime. They are valid as long as the session is not expired. You can increase session lifetime in config/session.php to increase cart lifetime. When a session expires, a new cart instance will be created in database and the old one will no longer be used. Over time, these expired carts could pile-up in database.

Laravel Task Scheduler comes to the rescue. To enable scheduler just add following to the crontab in your server:

* * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1 

That's it. The module will now check for expired carts in every hour and delete them. This won't affect the carts for loggedin users.

Other features:

Get Cart User: $cart->user

Get Item Product: $item->product

Is Cart Empty: $cart->isEmpty()

If an item exists in cart: $cart->hasItem(['id' => 10])

Expire the cart: cart->expire();

Set to completed status: $cart->complete();

Extending Cart Model

It's easy to extend DBCart. You can extend base DBCart model and add your own methods or columns. Follow these steps to extend the cart model:

  1. Create a model by extending NabeelAlalmai\DBcart\Models\Cart:

  2. Update cart_model in config/cart.php with the fully qualified class name of the extended model.

  3. That's it, you can now load the cart as usual:

You can also follow the above steps and create your own CartLine model by extending NabeelAlalmai\DBcart\Models\CartLine. Be sure to update config/cart.php to reflect your changes.

Disclaimer

I was using dbcart by Hassansin but it doesn't support Laravel 6. So, I re-wrote the package to support Laravel > 5.5. If you use dbcart by Hassansin you can use this package and it should work with no conflicts.

Support

Reach out to me at one of the following places!



All versions of dbcart-laravel with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2
illuminate/support Version ~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package slim-gee/dbcart-laravel contains the following files

Loading the files please wait ....