inpsyde/top-selling-products

This package is abandoned and no longer maintained. No replacement package was suggested.

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

1.0.1 2021-02-10 07:51 UTC

This package is auto-updated.

Last update: 2021-02-11 10:30:45 UTC


README

Latest Stable Version Project Status Build Status Total Downloads

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

UNMAINTAINED

NOTE: This repository is no longer maintained.

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 this License.