View Categories

Product Notes Developer Reference: Shortcode, Functions and Hooks

This developer reference covers the shortcode, PHP functions, filters, actions and data keys in Product Notes Tab & Private Admin Notes for WooCommerce. Use them to display notes in custom templates or change who can see them. Plugin settings are at WPFactory > Product Notes (also reachable at WooCommerce > Settings > Product Notes).

Shortcode: [alg_wc_product_notes] #

Outputs the notes of a product. Available in the free and Pro versions.

[alg_wc_product_notes]
[alg_wc_product_notes private_or_public="public" product_id="123" glue=" | "]
Attribute Default Description
private_or_public public public or private
product_id 0 Product or variation ID. 0 uses the current product
glue <br> Text placed between multiple notes
content %product_notes% Wrapper; %product_notes% is replaced with the notes
do_shortcode false Run shortcodes inside notes
do_esc_html true Escape HTML in notes
do_wpautop true Convert line breaks to paragraphs
make_clickable true Turn plain URLs into links

Note: the shortcode does not check the viewer’s role. With private_or_public="private" it shows private notes to anyone who can see the page. The output is passed through wp_kses_post().

PHP functions #

Function Returns
alg_wc_pn_get_product_notes( $private_or_public, $product_id = 0, $args = array() ) Formatted notes as an HTML string. $args accepts the same keys as the shortcode attributes except private_or_public and product_id. No visibility check
alg_wc_pn_has_product_notes( $private_or_public, $product_id = 0 ) true if the product has at least one non-empty note of that type
alg_wc_pn_get_enabled_sections() Array of enabled note types, for example array( 'private', 'public' )
alg_wc_pn_is_any_section_enabled() true if at least one section is enabled

Example: print public notes in a custom single product template.

if ( function_exists( 'alg_wc_pn_has_product_notes' ) && alg_wc_pn_has_product_notes( 'public', get_the_ID() ) ) {
    echo wp_kses_post( alg_wc_pn_get_product_notes( 'public', get_the_ID() ) );
}

Filters #

Filter Arguments Use
alg_wc_pn_do_display $display, $private_or_public Whether notes are shown on the storefront (product tab, product meta, single and shop positions, variation description, cart, checkout). Default: private notes for manage_woocommerce users only; public notes for everyone, or logged-in users when Logged users only is on
alg_wc_pn_get_product_notes $notes (array), $private_or_public, $product_id Raw stored notes for a product before values are extracted
alg_wc_pn_get_product_note_values $values (array of strings), $private_or_public, $product_id Non-empty note texts used for all output
alg_wc_pn_product_tab $notes (HTML), $private_or_public, $product_id Final HTML of the product tab content
alg_wc_pn_display_in_wpo_wcpdf (Pro) $display, $private_or_public, $template_type, $item, $order Return false to skip notes for a PDF document or item

Example: also show private notes on the storefront to users who can edit products.

add_filter( 'alg_wc_pn_do_display', function ( $display, $private_or_public ) {
    if ( 'private' === $private_or_public && current_user_can( 'edit_products' ) ) {
        return true;
    }
    return $display;
}, 10, 2 );

Actions #

Action Arguments Fires
alg_wc_pn_core_loaded $core After the core class has loaded its components
alg_wc_product_note_settings_after_save None After the plugin settings are saved (tools run on this hook)

Data keys #

Key Stored on Format
_alg_wc_internal_product_note Product and variation post meta Array of notes; each note is an array with time (timestamp), author (user ID) and value (text)
_alg_wc_public_product_note Product and variation post meta Same format as above
alg_wc_internal_product_note_tab_title, alg_wc_public_product_note_tab_title Product post meta Per-product tab title (when Tab title per product is on)
_alg_wc_internal_product_note, _alg_wc_public_product_note (Pro) Order item meta String; notes joined with ; (when Save in order items meta is on)

Private notes use the internal ID alg_wc_internal_product_note and public notes alg_wc_public_product_note. The same IDs name the product list columns, export columns and import mapping options in Pro.

Need a hand? Our team answers every ticket on the Product Notes support forum.