Download the PHP package dlds/yii2-ecom without Composer

On this page you can find all versions of the php package dlds/yii2-ecom. 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 yii2-ecom

E-commerce extension for Yii2

Provides support for basic e-commerce operations as a wrapper for dlds/yii2-payment. For usage examples see dlds/yii2-app-ecom - a sample application using this extension. This guide assumes that you are familiar with implementations of Estonian bank payments (see pangalink.net)

Main features:

Installation

You can install this package using composer. In your composer.json add the following required package:

Technical overview

The package lives under \dlds\ecom namespace and consists of 3 sub-components (these can be overridden in configuration and are directly accessible as properties of the main component).

  1. basket - provides shopping basket functionality
  2. payment - provides functionality for receiving payments
  3. formatter - helper class used in grid views

Most classes and subclasses can be overridden in the configuration.

Configuration

After the installation you will probably want to:

  1. Override and extend the main class to provide some custom functionality
  2. Register this class as application component
  3. Configure the bank payment parameters and the return URL

You can use something similar in the application configuration to achieve this:

And define the class MyEcomComponent like this:

You can use banks-default.php to store general bank configuration (e.g. which banks are used) and define the more specific access parameters in banks-local.php, which is environment-specific and is not held in CVS. You can download the example files from here.

Usage

The following examples assume that you have registered dlds\ecom\Component (or its child class) as an application component under Yii::$app->ecom.

Using ActiveRecord integration

ActiveRecord integration makes it very easy to add items to shopping basket and to use the basket to create orders and payment forms. Currently there are three kinds of AR integration available.

  1. Implement dlds\ecom\models\BasketProductInterface in your AR model class to add support for products and services
  2. Implement dlds\ecom\models\BasketDiscountInterface to add support for discounts
  3. Implement dlds\ecom\models\OrderInterface to add support for orders

Using the shopping basket

Operations with the shopping basket are very straightforward when using a models that implement one of the two basket interfaces. The basket object can be accessed under \Yii::$app->ecom->basket and can be overridden in configuration if you need to customize it.

Items in the basket

Products/items that are added to the basket are serialized/unserialized when saving and loading data from basket storage. If you are using Active Record models as products/discounts, make sure that you are omitting any unnecessary references from the serialized data to keep it compact.

Creating orders

The basket object can easily be converted into orders (AR objects that implement the OrderInterface).

This calls the saveFromBasket method from your Order class, which could look something like this.

Using payments

Generating payment forms

If you have saved your Order objects, you can use the included widget dlds\ecom\widgets\PaymentButtons to render all the bank forms included in your configuration. You can provide your own widget class in the configuration if you need customization (override widgetClass under payment sub-component). There is a shorthand method for generating the widget with correct parameters:

Receiving requests from banks

After payment the user is directed back to the application to a URL specified in your configuration by bankReturnRoute under payment sub-component. In your controller action you can pass the request to the component like this:

The above code loads the right Order from the database and calls the bankReturn method from your Order class. You are responsible for saving the order and logging necessary data.

Advanced examples

Storing basket data in database

There are two built-in adapters for storing basket data: session storage (default) and database storage. You can also write your own storage classes and define them in configuration under basket component:

In addition to table name, you can override both field names (one for user identifier and another for session data). If Database::$userComponent is set (for example to user), then the adapter will try to ask the user identifier via \Yii::$app->user->getId() method. If this fails or the component name is not specified, session ID will be used to identify the user. The session table should have at least two fields and look similar to this:

Using discounts

To add discounts to the basket/order, simply add an object implementing BasketDiscountInterface to the basket and specify the discount logic in applyToBasket method.


All versions of yii2-ecom with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
yiisoft/yii2 Version *
dlds/yii2-payment Version *
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 dlds/yii2-ecom contains the following files

Loading the files please wait ....