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
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
- Fetch project
git clone git@github.com:HazemNoor/ecommerce-rule-engine.git
cd ecommerce-rule-engine
- Make sure to have
docker-compose
installed on your machine, then execute this command to build docker images
make build
- Run this command to execute
composer install
make install
- 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
- Unit tests for all cases
- Rules should be maintainable/configurable through a structured JSON/Yaml/Excel file
- Rules based on quantity of articles & value of the cart - with conditions
>
,==
,<
- Simple Frontend form for users to input their products & test the rules
- Consumable Symfony/Laravel package
Optional
- 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 € |
- Database integration