HazemNoor / ecommerce-rule-engine

PHP eCommerce Rule engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PHP eCommerce Rule engine

This is an eCommerce Rule engine, It will check the Cart against set of business rules and apply the first matching one.

Usage

Checkout examples or tests

Installation

This package is still under development, but can be used in any framework using composer

  • Add GitHub repository source
    "repositories": [
        {
            "type": "vcs",
            "url": "git@github.com:HazemNoor/ecommerce-rule-engine.git",
            "no-api": true
        }
    ]
  • Add using composer require
composer require hazemnoor/ecommerce-rule-engine dev-main

Development

  1. Fetch project
git clone git@github.com:HazemNoor/ecommerce-rule-engine.git
cd ecommerce-rule-engine
  1. Make sure to have docker-compose installed on your machine, then execute this command to build docker images
make build
  1. Run this command to execute composer install
make install
  1. You can start the server and goto http://rule.localhost to test the package
make start

Testing

You can run tests using this command

make test

Other commands

  • Checkout list of commands by typing
make

Coding Style

The coding style used is PSR-12 and is included with the testing command make test using PHP_CodeSniffer

Code coverage

Run code coverage, an HTML report will be generated in .code-coverage directory

make coverage

Task Details, click to expand

As we value loyal customers in our imaginary MoonShiner Hoodies Merchandise Shop with some additional gadgets.

We want to offer them special deals, when

Case Condition Discount
Case A A repeating Customer & ordering more than 4 pieces of different hoodies 5 € Off the total
Case B Ordered 2 pieces of the same product (more than one piece of a product) Get the first one free
Case C Never ordered before Get the special “OneHoodie” for free
Case D Entering the PromoCode - Welcome1337 Free Purchase
Case E When there’s ProductA & ProductB in the cart Get first one free

MVP Requirements

  1. Unit tests for all cases
  2. Rules should be maintainable/configurable through a structured JSON/Yaml/Excel file
  3. Rules based on quantity of articles & value of the cart - with conditions >, ==, <
  4. Simple Frontend form for users to input their products & test the rules
  5. Consumable Symfony/Laravel package

Optional

  1. Connect to a Google spreadsheet - as your primary data source.
Hoodie Price
MoonShiner Howling Wolf 55.00 €
MoonShiner The Answer 42.00 €
MoonShiner Pro 133.70 €
MoonShiner Special 35.00 €
MoonShiner WeAreMoonShiner 65.00 €
  1. Database integration

About

PHP eCommerce Rule engine


Languages

Language:PHP 94.6%Language:Makefile 3.3%Language:Dockerfile 1.3%Language:Shell 0.8%