Change QR Code URL

Note: this feature requires PW Gift Cards Pro v1.448 or later.

By default, the QR Code uses the same URL as the “Redeem” button in the email. When it is scanned, it will take the user to your store with the gift card number applied to the cart just like clicking the Redeem button in the email.

To change the URL just for the QR code, follow these steps:

1. Install the free Code Snippets plugin: https://wordpress.org/plugins/code-snippets/
2. Create a new Snippet with the following code. Note: if you prefer, add the code to your functions.php rather than using Code Snippets.

add_filter( 'pwgc_qr_code_url', 'custom_pwgc_qr_code_url', 10, 3 );
function custom_pwgc_qr_code_url( $url, $gift_card_number, $design_id ) {
    // Change $url to something before returning it.
    return $url;
}
Example 1: Scanning QR Code will open the Check Balance page.
add_filter( 'pwgc_qr_code_url', 'custom_pwgc_qr_code_url', 10, 3 );
function custom_pwgc_qr_code_url( $url, $gift_card_number, $design_id ) {
    // Scanning QR Code will open the Check Balance page with the gift card number.
    $url = get_permalink( pwgc_get_balance_page() );
    $url = add_query_arg( 'card_number', $gift_card_number, $url );

    return $url;
}
Example 2: Scanning QR Code will open the gift card in the WP Admin Check Balance area.
add_filter( 'pwgc_qr_code_url', 'custom_pwgc_qr_code_url', 10, 3 );
function custom_pwgc_qr_code_url( $url, $gift_card_number, $design_id ) {
    // Scanning QR Code will open the gift card in the WP Admin Check Balance area.
    $url = pwgc_admin_url( 'balances', array( 'card_number' => $gift_card_number ) );

    return $url;
}
Example 3: Scanning QR Code will route to a specific website:
add_filter( 'pwgc_qr_code_url', 'custom_pwgc_qr_code_url', 10, 3 );
function custom_pwgc_qr_code_url( $url, $gift_card_number, $design_id ) {
    // Scanning QR Code will route to a specific website:
    $url = add_query_arg( 'gift_card_number', $gift_card_number, 'https://www.example.com/page.html' );

    return $url;
}
Skip to content