PHPackages                             fostercommerce/commerce-best-sellers - 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. fostercommerce/commerce-best-sellers

ActiveCraft-plugin[Utility &amp; Helpers](/categories/utility)

fostercommerce/commerce-best-sellers
====================================

1.3.0(1mo ago)0388↓88.2%proprietaryPHPPHP &gt;=8.2CI failing

Since Mar 29Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/FosterCommerce/commerce-best-sellers)[ Packagist](https://packagist.org/packages/fostercommerce/commerce-best-sellers)[ RSS](/packages/fostercommerce-commerce-best-sellers/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (22)Versions (23)Used By (0)

[![Screenshot](resources/images/header.png)](resources/images/header.png)

Best Sellers for Craft Commerce
===============================

[](#best-sellers-for-craft-commerce)

Sales analytics and reporting built for Craft Commerce. Track revenue, orders, products, customers, discounts, and carts, all from your control panel.

Best Sellers gives you a clear picture of what's selling, who's buying, and how your store is performing over any date range.

Requirements
------------

[](#requirements)

Best Sellers requires Craft CMS 5.0.0, Craft Commerce 5.0.0 and PHP 8.2.

Setup
-----

[](#setup)

### Installation

[](#installation)

To install the plugin, search for “Best Sellers” in the Craft Plugin Store follow these instructions.

Or install via your terminal.

1. Open your terminal and go to your Craft project:

    ```
     cd /path/to/project

    ```
2. Then tell Composer to require the plugin, and Craft to install it:

    ```
     composer require fostercommerce/commerce-best-sellers && php craft install/plugin bestsellers

    ```

### Prep data

[](#prep-data)

After installing, backfill your existing order data into Best Sellers database tables. These will create queue jobs. Run `best-sellers/backfill` first.

```
./craft best-sellers/backfill
./craft best-sellers/backfill/daily-stats
```

This processes your completed orders and builds the aggregated stats. New orders are tracked automatically going forward.

You can also run the backfill from the control panel under **Utilities &gt; Best Sellers**.

Features
--------

[](#features)

### Dashboard

[](#dashboard)

The dashboard provides a full overview of store performance for any date range, organized into focused sections with narrative summaries that explain what the numbers mean.

**Overview**

- Revenue, Orders, AOV, and Repeat Rate KPI cards
- Revenue/Orders/AOV toggle chart with previous period comparison
- Narrative summary comparing against previous period, same period last year, and trailing 12-month average

**Discounts &amp; Order Composition**

- Total Discounts, Items Sold, and Avg Items/Order KPI cards
- Discounted vs. Full-Price Orders breakdown (order count, revenue, AOV)
- Most Used Discounts ranked table with order counts linking to filtered orders
- Items Per Order histogram with clickable bars linking to filtered orders
- Shipping Methods ranked table with order counts linking to filtered orders

**Customers &amp; Retention**

- Customers, New Customers, and Avg Customer LTV KPI cards
- Top Customers by Revenue ranked table
- Credentialed vs Guest comparison (customer count, LTV, avg orders, total revenue)
- New vs Returning Customers trend chart

**Product Performance**

- Unique Products Sold and Product Revenue KPI cards
- Best Sellers top 10 ranked table with links to product edit pages

**Carts**

- Cart abandonment rate, abandoned value, and age breakdown (4-24h, 1-7d, 7+d)
- Highest-Value Abandoned Carts table with customer email, value, age, and cart restore links
- Anonymous cart toggle for filtering

**Global Controls**

- Date range picker with presets (Today, This Week, This Month, This Year, Past 7/30/90 Days, Past Year, All Time, custom)
- Order Status filter that persists across all report pages via session
- Past date ranges exclude today (complete days only)
- Partial period comparisons are prorated for fair comparison

### Orders

[](#orders)

Browse and search every completed order with filtering.

- Filters: Order Status, Payment Status, Shipping Method, Discount (discounted/full-price and specific discounts by ID), Items Per Order bucket
- Sortable columns: order number, date, status, item subtotal, tax, discount, shipping, total paid, items sold, payment status
- Page totals for all currency columns
- Dashboard widgets link to pre-filtered views
- CSV export with all applied filters

### Products

[](#products)

See which products or variants are generating the most revenue, with breakdowns by product type.

- Toggle between viewing products or variants
- Filter by product type
- Search by title, SKU, or product type
- Drill down to every order containing a specific product
- Sortable by units sold, order count, item sales (net of line-level discounts), or average price
- CSV export with all applied filters

### Customers

[](#customers)

Understand who your customers are, how much they spend, and how often they come back.

- Filter by customer type (credentialed or guest)
- Search by email
- Sortable by email, status, order count, total spent, AOV, or last purchase date
- Links to customer profiles in the control panel
- CSV export with all applied filters

### Operations

[](#operations)

Operational overview to help you understand store configuration, email notifications, and coupon usage across all time.

- Commerce Settings quick links (General Settings, Store Settings)
- Order Status Emails table showing which emails fire on each status transition, with enabled/disabled indicators and recipient types
- All Configured Emails table with name, subject, recipient, template path, and enabled status
- Coupon Usage (All Time) ranked table with usage counts and total discount per code

### Cart Restore

[](#cart-restore)

Built-in cart restoration for abandoned cart recovery.

- Shareable restore URL
- Restores the cart to the visitor's session and redirects to Commerce's `loadCartRedirectUrl`
- Credentialed customer carts require the account owner to be logged in
- Logged-in users cannot claim another user's cart
- Logged-out users can restore inactive/guest carts
- Styled login-required page when authentication is needed
- Cart purge expiry info shown in the dashboard based on Commerce's `purgeInactiveCartsDuration`

Templating
----------

[](#templating)

Best Sellers provides Twig variables for displaying sales data on your front end.

### Units Sold &amp; Item Sales

[](#units-sold--item-sales)

```
{# Units sold for a variant #}
{{ craft.bestsellers.variantTotalSales(variant.id) }}
{{ craft.bestsellers.variantTotalSales(variant.id, '30 days ago') }}
{{ craft.bestsellers.variantTotalSales(variant.id, '2024-01-01', '2024-12-31') }}

{# Item sales (net of line-level discounts) for a variant. #}
{# Matches the CP Products report. #}
{{ craft.bestsellers.variantTotalItemSalesNet(variant.id)|commerceCurrency }}

{# Units sold for a product (all variants combined) #}
{{ craft.bestsellers.productTotalSales(product.id) }}

{# Item sales (net) for a product #}
{{ craft.bestsellers.productTotalItemSalesNet(product.id)|commerceCurrency }}
```

`*TotalRevenue()` methods are still available (gross, SUM of `lineItemTotal` only) but are deprecated since 1.6.0. See [docs/usage.md](docs/usage.md) for the full difference.

### Previous Purchases

[](#previous-purchases)

```
{# Check if the current user previously purchased a specific product #}
{% set previousOrder = craft.bestsellers.previousPurchaseByUser(variant.id, currentUser) %}
{% if previousOrder %}
    You purchased this on {{ previousOrder.dateOrdered|date('M j, Y') }}
    Order #{{ previousOrder.reference }}
{% endif %}

{# Get all variants previously purchased by a user #}
{% set purchasedVariants = craft.bestsellers.previouslyPurchasedProducts(currentUser) %}
{% if purchasedVariants %}
    Your Previously Purchased Products
    {% for variant in purchasedVariants.all() %}
        {{ variant.title }}
    {% endfor %}
{% endif %}
```

### Best Sellers Queries

[](#best-sellers-queries)

Best Sellers extends Craft's element queries so you can fetch products or variants sorted by sales:

```
{# Top 10 best-selling products in the last 30 days #}
{% set bestSellers = craft.commerce.products
    .bestSellers('30 days ago')
    .limit(10)
    .all() %}
```

```
use craft\commerce\elements\Product;

$bestSellers = Product::find()
    ->bestSellers('2024-01-01', '2024-12-31')
    ->limit(10)
    ->all();

foreach ($bestSellers as $product) {
    echo $product->title . ': ' . $product->totalQtySold;
}
```

For additional examples, see the [Developer Documentation](docs/usage.md).

Console Commands
----------------

[](#console-commands)

CommandDescription`./craft best-sellers/backfill`Queue existing completed orders for processing (batches of 25)`./craft best-sellers/backfill --start-date=2025-01-01 --end-date=2025-12-31`Backfill orders within a specific date range`./craft best-sellers/backfill/daily-stats`Rebuild the daily stats table from order data`./craft best-sellers/backfill/daily-stats --date=2026-03-15`Rebuild daily stats for a single date`./craft best-sellers/backfill/refresh-orders`Clear variant sales and reprocess all orders`./craft best-sellers/backfill/refresh-daily-stats`Clear daily stats and rebuild from order data`./craft best-sellers/backfill/clear-orders`Clear the variant sales table`./craft best-sellers/backfill/clear-daily-stats`Clear the daily stats table`./craft best-sellers/backfill/clear-logs`Clear all backfill log entriesBoth commands are also available from the **Utilities &gt; Best Sellers** page in the control panel.

Roadmap
-------

[](#roadmap)

- Goal settings (revenue/order targets with progress tracking)
- Inventory reports (stock levels, low stock alerts, sell-through rates)
- Saved reports (save filter configurations for quick access)
- Extensible reports (API for plugins/modules to add custom report sections, KPI cards, and widgets)
- Subscription analytics (recurring revenue, churn, MRR for Commerce subscriptions)
- Third-party purchasable support (Digital Products, Donations, and other plugin purchasable types)

Credits
-------

[](#credits)

Brought to you by [Foster Commerce](https://fostercommerce.com)

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance92

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community10

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 ~46 days

Recently: every ~14 days

Total

10

Last Release

45d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9ac5b96165dd51aed8f0b9ea079d5d5beeb430a915cd07d645db0a228b0ac3aa?d=identicon)[fostercommerce](/maintainers/fostercommerce)

---

Top Contributors

[![sjcallender](https://avatars.githubusercontent.com/u/984311?v=4)](https://github.com/sjcallender "sjcallender (32 commits)")[![peteeveleigh](https://avatars.githubusercontent.com/u/827065?v=4)](https://github.com/peteeveleigh "peteeveleigh (29 commits)")[![johnnynotsolucky](https://avatars.githubusercontent.com/u/4161106?v=4)](https://github.com/johnnynotsolucky "johnnynotsolucky (4 commits)")

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/fostercommerce-commerce-best-sellers/health.svg)

```
[![Health](https://phpackages.com/badges/fostercommerce-commerce-best-sellers/health.svg)](https://phpackages.com/packages/fostercommerce-commerce-best-sellers)
```

###  Alternatives

[verbb/formie

The most user-friendly forms plugin for Craft.

102393.6k70](/packages/verbb-formie)[verbb/events

A full-featured plugin for event management and ticketing.

2311.9k](/packages/verbb-events)[spicyweb/craft-neo

A Matrix-like field type with block hierarchy

393813.5k10](/packages/spicyweb-craft-neo)[craftcms/commerce

Craft Commerce

240425.9k185](/packages/craftcms-commerce)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

54681.3k19](/packages/solspace-craft-freeform)[verbb/vizy

A flexible visual editor field for Craft.

4250.4k](/packages/verbb-vizy)

PHPackages © 2026

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