Skip to content
Docs
Get RestroPress

Filter

rpress_insert_discount

Updated
On this page

Filters the discount meta before a new discount is inserted.

Runs in RPRESS_Discount::add() when a new discount is created, after the meta array is built from the arguments. Keys include code, name, status, uses, max_uses, amount, start, expiration, type, min_price, product_reqs, product_condition, excluded_products, category_reqs, excluded_category, is_not_global and is_single_use.

Available since RestroPress 1.0.6.

Parameters#

ParameterTypeDescription
$metaarrayDiscount meta to be stored.

Return value#

array. The discount meta to store.

Example#

function my_insert_discount( $meta ) {
	$meta['code'] = strtoupper( $meta['code'] );
	return $meta;
}
add_filter( 'rpress_insert_discount', 'my_insert_discount' );

Notes#

The source docblock lists a discount ID parameter, but only the meta array is passed.

Source#

Applied in:

  • includes/class-rpress-discount.php (line 1178), in RPRESS_Discount::add()

See also#

Was this page helpful?