Redeem or exclude for products that are on sale

To allow or prevent a gift card balance from paying for specific products, use the pwgc_eligible_cart_amount hook.

Note: If you are more comfortable adding the code to your functions.php you can do that instead of using Code Snippets.

1. Download the free Code Snippets plugin:
2. Create a new Snippet with the following code:

function on_sale_pwgc_eligible_cart_amount( $eligible_amount, $cart ) {

    foreach( WC()->cart->get_cart() as $cart_item ) {
        $valid_product = true;

        $product = $cart_item['data'];

        if ( is_a( $product, 'WC_Product' ) && $product->is_on_sale() ) {
            $valid_product = false;

        if ( !$valid_product )  {
            $eligible_amount -= $cart_item['line_total'];
            $eligible_amount -= $cart_item['line_tax'];

    return max( 0, $eligible_amount );
add_filter( 'pwgc_eligible_cart_amount', 'on_sale_pwgc_eligible_cart_amount', 10, 2 );

Depending on your needs you can set the Eligible Product IDs to pick a few products that can be purchased, or set the Ineligible Product IDs to block out a few products that are not allowed to be purchased with a gift card.

The code will still allow the product(s) to be purchased, it just prevents the amounts from being paid by the gift card balance.

Skip to content