Set hard cap for donation goal

[ad_1]

Plugin Author
flinnn

(@flinnn)

Hi alibr0wn,

thanks for reaching out.
This feature is not available because it is not trivial to implement properly. For example, it would have to be ensured that someone is not allowed to give more in a single donation than is still in the budget; the product would have to be set back to available if someone cancels their donation; and in fact the donation amount is not always calculated directly but cached to save server resources during heavy load.
If you are happy with a rudimentary implementation you can use the following code snippet below.

Best regards
Jonas

function set_out_of_stock_if_limit_reached( $revenue, $product_id ) {
if ($product_id === 123 && $revenue > 1000) update_post_meta( $product_id, '_stock_status', 'outofstock' );
return $revenue;
}
add_action( 'wcdp_update_product_revenue', 'set_out_of_stock_if_limit_reached', 10, 2 );

  • This reply was modified 22 minutes ago by flinnn.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer