Can_Find_Cheapest_Product

Trait for finding the cheapest nth product.

Tags
author

Barn2 Plugins support@barn2.com

license

GPL-3.0

copyright

Barn2 Media Ltd

Table of Contents

find_cheapest_nth_product()  : WC_Product|WC_Order_Item_Product
This function will find the cheapest nth product based on numeric value of the $n_product parameter.

Methods

find_cheapest_nth_product()

This function will find the cheapest nth product based on numeric value of the $n_product parameter.

public find_cheapest_nth_product(array<string|int, mixed> $relevant_products, int $nth) : WC_Product|WC_Order_Item_Product

$n_product = 1 will return the cheapest product. $n_product = 2 will return the second cheapest product. $n_product = 3 will return the third cheapest product. etc...

Parameters
$relevant_products : array<string|int, mixed>

The relevant products.

$nth : int

The nth cheapest product to find.

Return values
WC_Product|WC_Order_Item_Product

The nth cheapest product.

Search results