Skip to content

Commit df09565

Browse files
committed
Finish 1.1.4
1 parent 1540299 commit df09565

4 files changed

Lines changed: 44 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 1.1.4 - 2019-12-17
2+
### Added
3+
- Add ability to pre-filter purchase patterns (via [@jmauzyk](https://github.com/jmauzyk))
4+
5+
### Fixed
6+
- Fix query issues (via [@jmauzyk](https://github.com/jmauzyk))
7+
18
## 1.1.3 - 2019-12-04
29
### Fixed
310
- Fix widget error when showing disabled products (Fixes #2)

README.md

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
11
![Purchase Patterns](resources/banner.png)
22

33
# Purchase Patterns
4-
Easily keep track of and show products customers bought together. Plus, sorting by individual and order sales.
4+
Easily keep track of and show products customers bought together. Plus, sorting
5+
by individual and order sales.
56

67
## Requirements
78

8-
This plugin requires Craft CMS 3.0.0 or later, and Craft Commerce 2.0.0-beta.2 or later.
9+
This plugin requires Craft CMS 3.0.0 or later, and Craft Commerce 2.0.0-beta.2
10+
or later.
911

1012
## Installation
1113

1214
Purchasable via the Plugin Store.
1315

1416
## Usage
1517

16-
Use the `craft.purchasePatterns.related` function in your templates to get related products that customers also bought.
18+
Use the `craft.purchasePatterns.related` function in your templates to get
19+
related products that customers also bought.
1720

1821
```php
19-
ProductQueryExtended related ( Product|Order $target [, int $limit = 8 [, ProductQuery $paddingQuery = null ] ] )
22+
ProductQueryExtended related ( Product|Order $target [, int $limit = 8 [, ProductQuery $paddingQuery = null [, array $filter = [] ] ] ] )
2023
```
2124

22-
The function returns a `ProductQueryExtended`, so you can include additional query parameters as needed. The `id` parameter is already set and shouldn't be overridden.
25+
The function returns a `ProductQueryExtended`, so you can include additional
26+
query parameters as needed. The `id` parameter is already set and shouldn't be
27+
overridden.
2328

2429
```twig
2530
{% set customersAlsoBought = craft.purchasePatterns.related(
@@ -30,7 +35,10 @@ The function returns a `ProductQueryExtended`, so you can include additional que
3035

3136
Setting `fixedOrder` to true will sort the products by times purchased together.
3237

33-
The `paddingQuery` allows you to specify a `ProductQuery` that will be used to pad out the related results if they fall below the given `limit`. This query should NOT include things like `order`, `limit`, or execution commands like `all`.
38+
The `paddingQuery` allows you to specify a `ProductQuery` that will be used to
39+
pad out the related results if they fall below the given `limit`. This query
40+
should NOT include things like `order`, `limit`, or execution commands like
41+
`all`.
3442

3543
```twig
3644
{% set customersAlsoBought = craft.purchasePatterns.related(
@@ -42,11 +50,29 @@ The `paddingQuery` allows you to specify a `ProductQuery` that will be used to p
4250

4351
**Editor's Note:** `random()` is Postgres specific. Use `RAND()` for MySQL.
4452

53+
`filter` expects an array of properties that will be used to filter the final
54+
result. You can use this to ensure your query always returns the expected number
55+
of results. You can pass any properties that you would otherwise include in the
56+
outer query:
57+
58+
```twig
59+
{% set customersAlsoBought = craft.purchasePatterns.related(
60+
order,
61+
20,
62+
craft.products.relatedTo(product.myCategory),
63+
{ availableForPurchase: 1 }
64+
).all() %}
65+
```
66+
67+
For more info on the filter feature (added by [jmauzyk](https://github.com/jmauzyk))
68+
see [#3](https://github.com/ethercreative/purchase-patterns/pull/3).
69+
4570
### Extended Product Query
4671

47-
The extended product query allows you to sort the products by `qtyCount` and `orderCount`.
48-
It extends the base product query, to you can use it the same way as you would `craft.products`.
49-
The `related` query above returns an extended query, as does:
72+
The extended product query allows you to sort the products by `qtyCount` and
73+
`orderCount`. It extends the base product query, to you can use it the same way
74+
as you would `craft.products`. The `related` query above returns an extended
75+
query, as does:
5076

5177
```twig
5278
{% set products = craft.purchasePatterns.extended().orderBy('orderCount DESC').all() %}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ether/purchase-patterns",
33
"description": "Easily keep track of and show products customers bought together. Plus, sorting by individual and order sales.",
4-
"version": "1.1.3",
4+
"version": "1.1.4",
55
"type": "craft-plugin",
66
"license": "proprietary",
77
"minimum-stability": "dev",

src/Variable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function related (
4545
$target,
4646
$limit = 8,
4747
ProductQuery $paddingQuery = null,
48-
array $filters = []
48+
array $filters = []
4949
) {
5050
$service = PurchasePatterns::getInstance()->getService();
5151

0 commit comments

Comments
 (0)