# Downloads Tab With Manuals and Data Sheets

> Adds a "Documents" field to products for links to manuals, data sheets or certificates, listed in a Downloads tab on the product page.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, product-tabs, documents, downloads
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-product-documents-tab/

## Code

```php
add_action( 'woocommerce_product_options_general_product_data', function () {
    global $product_object;

    woocommerce_wp_textarea_input( array(
        'id'          => '_wpide_documents',
        'label'       => 'Documents',
        'placeholder' => "User manual | https://example.com/manual.pdf\nData sheet | https://example.com/sheet.pdf",
        'description' => 'One per line: Label | URL',
        'desc_tip'    => true,
        'value'       => $product_object instanceof WC_Product ? $product_object->get_meta( '_wpide_documents' ) : '',
    ) );
} );

add_action( 'woocommerce_admin_process_product_object', function ( $product ) {
    // phpcs:ignore WordPress.Security.NonceVerification -- WooCommerce verifies the product save nonce.
    if ( isset( $_POST['_wpide_documents'] ) ) {
        $product->update_meta_data( '_wpide_documents', sanitize_textarea_field( wp_unslash( $_POST['_wpide_documents'] ) ) );
    }
} );

add_filter( 'woocommerce_product_tabs', function ( $tabs ) {
    global $product;

    $raw  = $product instanceof WC_Product ? (string) $product->get_meta( '_wpide_documents' ) : '';
    $docs = array();

    foreach ( preg_split( '/\r\n|\n/', $raw ) as $line ) {
        $parts = array_map( 'trim', explode( '|', $line, 2 ) );

        if ( 2 === count( $parts ) && wp_http_validate_url( $parts[1] ) ) {
            $docs[] = $parts;
        }
    }

    if ( $docs ) {
        $tabs['wpide_documents'] = array(
            'title'    => 'Downloads',
            'priority' => 35,
            'callback' => function () use ( $docs ) {
                echo '<ul class="wpide-documents">';

                foreach ( $docs as $doc ) {
                    printf( '<li><a href="%s" target="_blank" rel="noopener">%s</a></li>', esc_url( $doc[1] ), esc_html( $doc[0] ) );
                }

                echo '</ul>';
            },
        );
    }

    return $tabs;
} );
```

## Notes

Enter one document per line as "Label | URL", using URLs of PDFs uploaded to the media library.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Downloads Tab With Manuals and Data Sheets" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
