Actions and Filters


Displaying Attachments on the Thank You Page

The WooCommerce Product Attachments plugin allows you to display order attachments using a shortcode on a custom Thank You page.

How to Use:

  • For Overwriting WooCommerce Thank You Page:
    • Open your theme’s woocommerce/checkout/thankyou.php  file.
    • Insert the following PHP code where you want the attachments to appear:
<?php echo do_shortcode('[wcpoa_order_attachments]'); ?>

Allow search attachment shortcode in other pages: 

The wcpoa_should_load_public_scripts  filter enables developers to load the WooCommerce Product Attachment plugin's frontend JavaScript on custom pages where the search attachment shortcode is used. This filter is essential for ensuring proper functionality of attachment search shortcodes outside the default WooCommerce pages.


<?php
/**
 * Allow search attachment shortcode functionality on custom pages
 */
function enable_search_attachment_shortcode_pages( $load_script ) {
    // Enable on pages with search attachment shortcodes
    if ( is_page( array( 'search-downloads', 'document-library', 'resources' ) ) ) {
        return true;
    }
    
    return $load_script;
}
add_filter( 'wcpoa_should_load_public_scripts', 'enable_search_attachment_shortcode_pages' );

This filter is essential for any implementation using search attachment shortcodes outside standard WooCommerce pages, ensuring full functionality and user experience.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.