Home / Admin / Add A Default Campaign Custom Amount
Duplicate Snippet

Embed Snippet on Your Site

Add A Default Campaign Custom Amount

Code Preview
php
<?php
add_filter( 'charitable_session_donation_amount', 'example_get_donation_amount_in_session', 999, 2 );
function example_get_donation_amount_in_session( $amount = false, $campaign = false ) {
	// If the donation amount is not set in the session, return the default amount.
	// WARNING: Setting a default amount here will override any default amounts that might be set in the Charitable settings.
	// ALSO NOTE: This will only work for donations made via the donation form. It will not work for donations made via the admin.
	// FINALLY: Setting a default amount for the user can be a bad idea, as it can lead to accidental donation amounts.
	if ( ! $amount ) {
		return 100;
	}
	// Otherwise, return the amount.
	return $amount;
}

Comments

Add a Comment