Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Question / Issue

I have tried myself to include a filter that prevents / skips the output of products that have no value or a value lower than the value specified at the variable MinSavingPercent. Unfortunately, AT is too complex for me to get my head around. 😉

Answer / Solution

So that you can filter products by price discount in a list, you can use this filter. We filter for at least 40% off in this example.

Also, we only use this filter on the post with ID 6127. For all other contributions, this list is not filtered.

	
function atkp_modify_products_callback( $products ) {	
	
	if(get_the_ID() == 6127) {
		$products_filtered = array();
		
		foreach($products as $product) {
			if(floatval($product->percentagesaved) > 40) {
				$products_filtered[] = $product;
			}
		}
		
		return $products_filtered ;
	}	

	return $products ;
}
add_filter( 'atkp_modify_products', 'atkp_modify_products_callback', 10);

Just add this snippet to your functions.php or to a snippets plugin. But be sure to adjust the Post ID 6127.

Updated: 6. February 2023
Still not using affiliate-toolkit?
Setup takes less than 5 minutes and you can start to import first products!
Learn more about the packagesDownload FREE Version
Still need help?
Submit Your Question
Please give us the details, our support team will get back to you.
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram