Download the PHP package baklysystems/laravel-shop-extended without Composer

On this page you can find all versions of the php package baklysystems/laravel-shop-extended. 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 laravel-shop-extended

LARAVEL SHOP (Laravel 5.1 Package)

Latest Stable Version Total Downloads Latest Unstable Version License

Laravel Shop is flexible way to add shop functionality to Laravel 5.1. Aimed to be the e-commerce solution for artisans.

Laravel shop adds shopping cart, orders and payments to your new or existing project; letting you transform any model into a shoppable item.

Supports

PayPal Omnipay

Contents

Scope

Current version includes:

On the horizon:

Installation

With composer

Or add

to your composer.json. Then run composer install or composer update.

Then in your config/app.php add

in the providers array.

Then add

in the aliases array.

Configuration

Set the configuration values in the config/auth.php file. This package will use them to refer to the user table and model.

Publish the configuration for this package to further customize table names, model namespaces, currencies and other values. Run the following command:

A shop.php file will be created in your app/config directory.

Database Setup

Generate package migration file:

The command below will generate a new migration file with database commands to create the cart and item tables. The file will be located in database/migrations. Add additional fields if needed to fill your software needs.

The command will also create a database seeder to fill shop catalog of status and types.

Create schema in database:

Add the seeder to database/seeds/DatabaseSeeder.php:

Run seeder (do composer dump-autoload first):

Models

The following models must be created for the shop to function, these models can be customizable to fir your needs.

Item

Create a Item model:

This will create the model file app/Item.php, edit it and make it look like (take in consideration your app's namespace):

The Item model has the following main attributes:

Business definition: Item used as a cart item or an order item.

Cart

Create a Cart model:

This will create the model file app/Cart.php, edit it and make it look like (take in consideration your app's namespace):

The Item model has the following main attributes:

Order

Create a Order model:

This will create the model file app/Order.php, edit it and make it look like (take in consideration your app's namespace):

The Order model has the following main attributes:

Transaction

Create a Transaction model:

This will create the model file app/Transaction.php, edit it and make it look like (take in consideration your app's namespace):

The Order model has the following main attributes:

User

Use the ShopUserTrait trait in your existing User model. By adding use BaklySystems\LaravelShop\Traits\ShopUserTrait and use ShopUserTrait like in the following example:

This will enable the relation with Cart and shop needed methods and attributes.

Existing Model Conversion

Laravel Shop package lets you convert any existing Eloquent model to a shoppable item that can be used within the shop without sacrificing any existing functionality. This feature will let the model be added to carts or orders. The will require two small steps:

Use the ShopItemTrait in your existing model. By adding use BaklySystems\LaravelShop\Traits\ShopItemTrait and use ShopItemTrait like in the following example:

Add sku (string) and price (decimal, 20, 2) fields to your model's table. You can also include name (string), tax (decimal, 20, 2) and shipping (decimal, 20, 2), although these are optional. You can do this by creating a new migration:

Define migration to look like the following example:

Run the migration:

Item name

By default, Laravel Shop will look for the name attribute to define the item's name. If your exisintg model has a different attribute assigned for the name, simply define it in a property within your model:

Item url

You can define the URL attribute of the item by setting itemRouteName and itemRouteParams class properties. In the following example the url defined to show the product's profile is product/{slug}, the following changes must be applied to the model:

Dump Autoload

Dump composer autoload

Payment Gateways

Installed payment gateways can be configured and added in the gateways array in the shop.php config file, like:

PayPal

Laravel Shop comes with PayPal support out of the box. You can use PayPal's Direct Credit Card or PayPal Express payments.

To configure PayPal and know how to use the gateways, please visit the PayPal Gateway Package page.

Omnipay

Install Omnipay Gateway to enable other payment services like 2Checkout, Authorize.net, Stripe and to name a few.

You might need to get some extra understanding about how Omnipay works.

Usage

Shop

Shop methods to consider:

Format prices or other values to the price format specified in config:

Purchase Flow

With Laravel Shop you can customize things to work your way, although we recommend standarize your purchase or checkout flow as following (will explain how to use the shop methods below):

Purchase Flow

Payment Gateway

Before any shop method is called, a payment gateway must be set:

You can access the gateway class object as well:

Checkout

Once a payment gateway has been selected, you can call cart to checkout like this:

This will call the onCheckout function in the payment gateway and perform validations. This method will return a bool flag indication if operation was successful.

Order Placement

Once a payment gateway has been selected and user has checkout, you can call order placement like:

NOTE: placeOrder() will create an order, relate all the items in cart to the order and empty the cart. The Order model doen't include methods to add or remove items, any modification to the cart must be done before the order is placed. Be aware of this when designing your checkout flow.

This will call the onCharge function in the payment gateway and charge the user with the orders' total amount. placeOrder() will return an Order model with which you can verify the status and retrieve the transactions generated by the gateway.

Payments

Payments are handled gateways, this package comes with PayPal out of the box.

You can use PayPal's Direct Credit Card or PayPal Express payments.

To configure PayPal and know how to use its gateways, please visit the PayPal Gateway Package page.

Exceptions

If checkout or placeOrder had errores, you can call and see the exception related:

Critical exceptions are stored in laravel's log.

Shopping Cart

Carts are created per user in the database, this means that a user can have his cart saved when logged out and when he switches to a different device.

Let's start by calling or creating the current user's cart:

Note: Laravel Shop doen not support guest at the moment.

Get the cart of another user:

Adding Items

Lest add one item of our test and existing model MyCustomProduct:

By default the add method will set a quantity of 1.

Instead lets add 3 MyCustomProduct;

Only one item will be created per sku in the cart. If an item of the same sku is added, just on item will remain but its quantity will increase:

We can reset the quantity of an item to a given value:

Adding Unexistent Model Items

You can add unexistent items by inserting them as arrays, each array must contain sku and price keys:

Removing Items

Lest remove our test and existing model MyCustomProduct from cart:

The example below will remove the item completly, but it is possible to only remove a certain quantity from the cart:

Arrays can be used to remove unexistent model items:

To empty cart:

These methods can be chained:

Cart Methods

Placing Order

You can place an order directly from the cart without calling the Shop class, although this will only create the order record in the database and no payments will be processed. Same ad when using Shop, the cart will be empty after the order is placed.

Status can be forced in creation as well:

Displaying

Hew is an example of how to display the cart in a blade template:

Items count in cart:

Items in cart:

Cart amount calculations:

Item

Models or arrays inserted in a cart or order are converted into SHOP ITEMS, model Item is used instead within the shop.

Model objects can be retrieved from a SHOP ITEM:

$item->object is MyCustomProduct model already loaded, we can access its properties and methods directly, like:

The following shop methods apply to model Item or exiting models that uses ShopItemTrait:

Order

Find a specific order number:

Find orders form user:

Placing Transactions

You can place a transaction directly from the order without calling the Shop class, although this will only create the transaction record in the database and no payments will be processed.

Order Methods

Order Status Codes

Status codes out of the box:

You can use your own custom status codes. Simply add them manually to the order_status database table or create a custom seeder like this:

Then use it like:

Events

Laravel Shop follows Laravel 5 guidelines to fire events, create your handlers and listeners like you would normally do to use them.

Event Description Data passed
Cart checkout Event fired after a shop has checkout a cart. id - Cart Id success - Checkout result (boolean)
Order placed Event fired when an order has been placed. id - Order Id
Order completed Event fired when an order has been completed. id - Order Id
Order status changed Event fired when an order's status has been changed. id - Order Id statusCode - New status previousStatusCode - Prev status

Here are the events references:

Event Reference
Cart checkout BaklySystems\LaravelShop\Events\CartCheckout
Order placed BaklySystems\LaravelShop\Events\OrderPlaced
Order completed BaklySystems\LaravelShop\Events\OrderCompleted
Order status changed BaklySystems\LaravelShop\Events\OrderStatusChanged

Event Handler Example

An example of how to use an event in a handler:

Remember to register your handles and listeners at the Event Provider:

Payment Gateway Development

Laravel Shop has been developed for customization in mind. Allowing the community to expand its capabilities.

Missing payment gateways can be easily developed as external packages and then be configured in the config file.

Make this proyect a required dependency of your package or laravel's setup and simply extend from Laravel Shop core class, here a PayPal example:

The gateway will require onCharge method as minimun. You can add more depending your needs.

Once created, you can add it to the shop.php config file, like:

And use it like:

Transaction

To properly generate the transaction there are 3 properties you must consider on setting during onCharge:

Callbacks

Laravel Shop supports gateways that require callbacks. For this, you will need to add 2 additional functions to your gateway:

In the example above, onCharge instead of creating a completed transaction, it is creating a pending transaction and indicating the provider to which urls to call back with the payment results.

The methods onCallbackSuccess and onCallbackFail are called by Shop when the provider calls back with its reponse, the proper function will be called depending on the callback url used by the provider.

The method onCallbackSuccess will create a new transaction for the order it ends.

Exceptions

Laravel Shop provides several exceptions you can use to report errors.

For onCheckout:

For onChange, onCallbackSuccess and onCallbackFail:

NOTE: Laravel Shop will not catch any other exception. If a normal Exception or any other exceptions is thrown, it will break the method as it normally would, this will affect your checkout flow like in example when you want to get the order from placeOrder().

Examples

You can see the PayPal gateways we made as examples.

License

Laravel Shop is free software distributed under the terms of the MIT license.

Additional Information

This package's architecture and design was inpired by the Zizaco/entrust package, we'll like to thank their contributors for their awesome woek.

Change Log


All versions of laravel-shop-extended with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.9
illuminate/console Version ~5.0
illuminate/support Version ~5.0
amsgames/laravel-shop-gateway-paypal Version 1.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 baklysystems/laravel-shop-extended contains the following files

Loading the files please wait ....