PHPackages                             openbuildings/promotions - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. openbuildings/promotions

ActiveKohana-module[Utility &amp; Helpers](/categories/utility)

openbuildings/promotions
========================

Promotions for Purchases

0.10.0(5y ago)2166.1k1[2 PRs](https://github.com/OpenBuildings/promotions/pulls)BSD-3-ClausePHPPHP ^7.3

Since Sep 23Pushed 3y ago6 watchersCompare

[ Source](https://github.com/OpenBuildings/promotions)[ Packagist](https://packagist.org/packages/openbuildings/promotions)[ Docs](https://github.com/OpenBuildings/promotions)[ RSS](/packages/openbuildings-promotions/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (10)Dependencies (9)Versions (40)Used By (0)

Promotions Module
=================

[](#promotions-module)

[![Build Status](https://camo.githubusercontent.com/84d9e9ed37623ece148a1fcf9182bb45584b3a8dba97e323cde73bfd0ed69d54/68747470733a2f2f7472617669732d63692e6f72672f4f70656e4275696c64696e67732f70726f6d6f74696f6e732e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/OpenBuildings/promotions)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/b0f16dbac205ccef17ad3c037a3ce74b55487d33f0cb8380869b0c58c086bd46/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4f70656e4275696c64696e67732f70726f6d6f74696f6e732f6261646765732f7175616c6974792d73636f72652e706e673f733d32306261666633343430313634393162616535333130636335393662333864643666613262613964)](https://scrutinizer-ci.com/g/OpenBuildings/promotions/)[![Code Coverage](https://camo.githubusercontent.com/aa81fe362c151e5f8078c6373ce45984b78198bd883d4d9a7be0de632436ef89/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4f70656e4275696c64696e67732f70726f6d6f74696f6e732f6261646765732f636f7665726167652e706e673f733d62663136626634623231306164366165633338656635333630333962613761373264346331383731)](https://scrutinizer-ci.com/g/OpenBuildings/promotions/)[![Latest Stable Version](https://camo.githubusercontent.com/be06b42db5331fa128fad1813db675a5db6d468fd6e2b8c68c1bc595b470f219/68747470733a2f2f706f7365722e707567782e6f72672f6f70656e6275696c64696e67732f70726f6d6f74696f6e732f762f737461626c652e706e67)](https://packagist.org/packages/openbuildings/promotions)

This module gives the ability to define promotions with a set of requirements that add themselves to purchases, based on these rules. Each promotion can have a static or dynamic/configurable amount.

Promotions can also have ontime or multiple time uses for promo\_codes

Usage
-----

[](#usage)

Add a behavior to the purchase and brand\_purchase models:

```
class Model_Brand_Purchase extends Kohana_Model_Brand_Purchase {

	public static function initialize(Jam_Meta $meta)
	{
		parent::initialize($meta);

		$meta
			->behaviors(array(
				'promotable_brand_purchase' => Jam::behavior('promotable_brand_purchase'),
			));
	}
}
// ...
class Model_Purchase extends Kohana_Model_Purchase {

	public static function initialize(Jam_Meta $meta)
	{
		parent::initialize($meta);

		$meta
			->behaviors(array(
				'promotable_purchase' => Jam::behavior('promotable_purchase'),
			));
	}
}
```

And you'll need to add actual promotions to the database. The promtion modle uses single table inheritence to have a different class for each promotion. Each of these has to define "applies\_to" and "price\_for\_purchase\_item" which your promotions will have to implement. There is also the `Model_Promotion_Promocode` class which gives the promotion the ability to use promo codes which exhaust themselves when are used.

There are 2 availbale predefined promotions:

- Model\_Promotion\_Promocode\_Giftcard - to use it you'll need to enter requirement - the minimum price where the promotion applies, and amount - the amount (Jam\_Price) to be reducted from the purchase
- Model\_Promotion\_Promocode\_Percent - get a static reduction of some percent (amount). Amount is a value from 0 to 1.

promo\_code\_text
-----------------

[](#promo_code_text)

The `promotable_purchase` behavior adds a promo\_code\_text field to the purchase (its not in the database). When you set a promocode to this field it would try to find it, and then run "validate\_purchase" of the appropriate promotion, if found. If everything checks out, the promotion associated with this promocode will be added to the purchase.

License
-------

[](#license)

Copyright (c) 2012-2013, OpenBuildings Ltd. Developed by Yasen Yanev as part of [clippings.com](http://clippings.com)

Under BSD-3-Clause license, read LICENSE file.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~77 days

Recently: every ~285 days

Total

35

Last Release

2029d ago

PHP version history (4 changes)0.1.0PHP &gt;=5.3.0

0.7.4PHP ^7

0.8.0PHP ^7.1

0.10.0PHP ^7.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/506129?v=4)[Harry Dobrev](/maintainers/hkdobrev)[@hkdobrev](https://github.com/hkdobrev)

![](https://avatars.githubusercontent.com/u/4113307?v=4)[Danail Kyosev](/maintainers/dkyosev)[@dkyosev](https://github.com/dkyosev)

![](https://avatars.githubusercontent.com/u/7592650?v=4)[Evstati Zarkov](/maintainers/EZarkov)[@EZarkov](https://github.com/EZarkov)

![](https://avatars.githubusercontent.com/u/745771?v=4)[Filip Georgiev](/maintainers/phgeorgiev)[@phgeorgiev](https://github.com/phgeorgiev)

![](https://avatars.githubusercontent.com/u/490439?v=4)[Zdravko Evstatiev](/maintainers/zedevs)[@zedevs](https://github.com/zedevs)

---

Top Contributors

[![hkdobrev](https://avatars.githubusercontent.com/u/506129?v=4)](https://github.com/hkdobrev "hkdobrev (35 commits)")[![ivank](https://avatars.githubusercontent.com/u/4976?v=4)](https://github.com/ivank "ivank (14 commits)")[![george-clippings](https://avatars.githubusercontent.com/u/67631863?v=4)](https://github.com/george-clippings "george-clippings (7 commits)")[![stanstst](https://avatars.githubusercontent.com/u/9391542?v=4)](https://github.com/stanstst "stanstst (5 commits)")[![EZarkov](https://avatars.githubusercontent.com/u/7592650?v=4)](https://github.com/EZarkov "EZarkov (5 commits)")[![yanev](https://avatars.githubusercontent.com/u/1153044?v=4)](https://github.com/yanev "yanev (4 commits)")[![dkyosev](https://avatars.githubusercontent.com/u/4113307?v=4)](https://github.com/dkyosev "dkyosev (4 commits)")[![tumbalev](https://avatars.githubusercontent.com/u/28398671?v=4)](https://github.com/tumbalev "tumbalev (1 commits)")

---

Tags

kohanastorepurchasecartbasketpromotionsjam

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/openbuildings-promotions/health.svg)

```
[![Health](https://phpackages.com/badges/openbuildings-promotions/health.svg)](https://phpackages.com/packages/openbuildings-promotions)
```

###  Alternatives

[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.3k10](/packages/helsingborg-stad-municipio)[mautic/core

Mautic Open Source Distribution

9.8k2.6k9](/packages/mautic-core)[mediawiki/maps

Adds various mapping features to MediaWiki

78149.7k3](/packages/mediawiki-maps)[civicrm/civicrm-drupal-8

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

19246.3k2](/packages/civicrm-civicrm-drupal-8)[altis/core

Core module for Altis

19222.5k2](/packages/altis-core)[humanmade/popup

An popup and tooltip dialog block utility, multiple trigger options, and supports anchor placements

146.6k](/packages/humanmade-popup)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
