Hide the “From” and “Message” fields

To remove the “From” and “Message” fields, follow these steps:

1. Download the free Code Snippets plugin: https://wordpress.org/plugins/code-snippets/
2. Create a Snippet with the following code (or add to your functions.php if you prefer):

add_action('wp_head', 'pwgc_head_remove_from');
function pwgc_head_remove_from() {
    ?>
    <style>
        #pwgc-form-message {
            display: none;
        }

        #pwgc-form-from {
            display: none;
        }
    </style>
    <?php
}

add_action( 'wp_footer', 'pwgc_footer_remove_from' );
function pwgc_footer_remove_from() {
    ?>
    <script>
        jQuery('#pwgc-from').attr('required', false);
    </script>
    <?php
}

If you have PW Gift Cards Pro and want to hide the “From” and “Message” fields on the Physical gift card product only, use this code instead:

add_action('wp_head', 'pwgc_head_remove_from');
function pwgc_head_remove_from() {
    global $post;

    // Remove the From and Message fields for physical gift cards.
    $product = property_exists( $post, 'ID' ) ? wc_get_product( $post->ID ) : false;
    if ( is_a( $product, 'WC_Product_PW_Gift_Card' ) && $product->get_pwgc_is_physical_card() ) {
        ?>
        <style>
            #pwgc-form-message {
                display: none;
            }

            #pwgc-form-from {
                display: none;
            }
        </style>
        <?php
    }
}

add_action( 'wp_footer', 'pwgc_footer_remove_from' );
function pwgc_footer_remove_from() {
    ?>
    <script>
        jQuery('#pwgc-from').attr('required', false);
    </script>
    <?php
}
Skip to content