Lightweight package providing a pre-configured, yet filterable WP_Query extension for top selling products.
Switch branches/tags
Nothing to show
Clone or download
Latest commit b8fac1f Jul 18, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Initial commit. Jul 18, 2016
src Initial commit. Jul 18, 2016
tests/php Initial commit. Jul 18, 2016
.editorconfig Initial commit. Jul 18, 2016
.gitattributes Initial commit. Jul 18, 2016
.gitignore Initial commit. Jul 18, 2016
.travis.yml Initial commit. Jul 18, 2016
CHANGELOG.md Initial commit. Jul 18, 2016
LICENSE Initial commit. Jul 18, 2016
README.md Initial commit. Jul 18, 2016
composer.json Initial commit. Jul 18, 2016
phpunit.xml.dist Initial commit. Jul 18, 2016

README.md

Top Selling Products

Latest Stable Version Project Status Build Status Total Downloads License

Lightweight package providing a pre-configured, yet filterable WP_Query extension for top selling products.

Introduction

This package comes with a WP_Query extension that allows for querying top selling products. By default, there is no definition as to when a product is a top seller, though. This can either be done by passing according query arguments, or filtering the given or default ones.

Installation

$ composer require inpsyde/top-selling-products:~1.0

Run the tests:

$ vendor/bin/phpunit

Requirements

This package requires PHP 5.4 or higher.

Usage

Filters

inpsyde_top_selling_products.query_args

This hook allows to filter the query arguments.

Arguments:

  • array $args: Query arguments.
<?php

add_filter( 'inpsyde_top_selling_products.query_args' , function( array $args ) {

	// Randomize the results, but exclude posts with specific IDs. 
	return array_merge( $args, [
		'post__not_in' => [ 4, 8, 15, 16, 23, 42 ],
		'orderby'      => 'rand',
	] );
} );

License

Copyright (c) 2016 Inpsyde GmbH, Thorsten Frommen

This code is licensed under the MIT License.