• Resolved alibr0wn

    (@alibr0wn)


    I’m trying to get it so that you cannot donate above the amount. Is there some kind of option here I can do this with?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jonas

    (@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 1 year, 11 months ago by Jonas.
    Thread Starter alibr0wn

    (@alibr0wn)

    Thank you for this response, Flinn. I’m going to try out the code you outlined with my dev and see where this takes me. I’m grateful for the time you took to respond and write that code for me.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Set hard cap for donation goal’ is closed to new replies.