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.