Hooks & filters (developer reference)

Filters

nyp_get_option

  • Filters any option value retrieved by the nyp_get_option() helper.
  • Parameters: $value (mixed), $key (string), $default (mixed)
  • Example:
add_filter( 'nyp_get_option', function( $value, $key, $default ) {
    if ( $key === 'price_field_label' ) {
        return 'Pay What You Want';
    }
    return $value;
}, 10, 3 );

nyp_add_to_cart_text

  • Filters the add to cart button text for NYP products.
  • Parameters: $text (string)

nyp_shop_button_text

  • Filters the shop page button text for NYP products.
  • Parameters: $text (string)

woocommerce_get_sections_nyp_settings

  • Filters the settings sections array for the Custom Pricing settings tab.
  • Parameters: $sections (array)

woocommerce_get_settings_nyp_settings

  • Filters the settings fields array for each section.
  • Parameters: $settings (array), $current_section (string)

Actions

nyp_product_options

  • Fires inside the Name Your Price product data panel, after the built-in fields. Use this to add custom fields.
  • Parameters: $post_id (int)
  • Example:
add_action( 'nyp_product_options', function( $product_id ) {
    woocommerce_wp_text_input( [
        'id'    => '_my_custom_nyp_field',
        'label' => 'Custom NYP Field',
    ] );
} );