TL;DR
By default, suggested donation amounts are sorted in ascending order. However, you can change this for specific products (or for all products) using the wcdp_sort_order
filter. Keep in mind that this filter only takes effect when a product is updated, so make sure to edit and save each product where you want to apply the change.
How It Works
Donation Platform for WooCommerce sorts suggested donation amounts in ascending order by default. If you prefer to display them in descending order, you can use the wcdp_sort_order
filter.
Apply to a Specific Product
To display suggested donation amounts from highest to lowest for a specific product, add the following code (see also how you can add custom code snippets to your page):
add_filter('wcdp_sort_order', function ($order, $post_id) {
// Replace 123 with the actual product ID where you want descending order
return ($post_id === 123) ? 'DESC' : $order;
}, 10, 2);
Apply to All Products
To apply descending order to all products, use this simplified version:
add_filter('wcdp_sort_order', fn() => 'DESC');
Notes:
- The default sorting order is
'ASC'
(lowest to highest). - You can modify the order for specific products by checking
$post_id
. - If you ignore
$post_id
, the change will apply to all products. - This filter only applies when a product is updated, so you must edit and save the product for the change to take effect.