Prevent a running balance (force gift card to always use entire balance)
Note: This customization requires the PW Gift Cards Pro version.
Follow these steps to make the gift card always use 100% of the remaining balance when redeemed, regardless of the order amount.
1. Download the free Code Snippets plugin: https://wordpress.org/plugins/code-snippets/
2. Create a Snippet with the following code:
function custom_pwgc_debit_amount( $debit_amount, $gift_card, $order_item_id, $line, $order ) { return ( $gift_card->get_balance() * -1 ); } add_filter( 'pwgc_debit_amount', 'custom_pwgc_debit_amount', 10, 5 ); function custom_pwgc_remaining_balance( $balance, $gift_card ) { return 0; } add_filter( 'pwgc_remaining_balance_cart', 'custom_pwgc_remaining_balance', 10, 2 ); add_filter( 'pwgc_remaining_balance_checkout', 'custom_pwgc_remaining_balance', 10, 2 );
Note: If you are more comfortable with editing your functions.php you can do that instead of Code Snippets.