Skip to content

Instantly share code, notes, and snippets.

@helgatheviking
Last active April 5, 2021 17:28
Show Gist options
  • Save helgatheviking/e1326e2047ed621158f86c1d4747e9bc to your computer and use it in GitHub Desktop.
Save helgatheviking/e1326e2047ed621158f86c1d4747e9bc to your computer and use it in GitHub Desktop.
Add placeholder text to Name Your Price inputs
/**
* Modify NYP price input's placeholder.
*
* @param array $attributes The array of attributes for the NYP div
* @param obj $product WC_Product The product object
* @param string $suffix - needed for grouped, composites, bundles, etc.
* @return string
* @return string - The modified input html.
*/
function kia_custom_nyp_placeholder( $attributes, $product, $suffix ) {
$attributes['placeholder'] = __( 'Enter price here', 'your-text-domain' );
return $attributes;
}
add_filter( 'wc_nyp_price_input_attributes', 'kia_custom_nyp_placeholder', 10, 3 );
@captainhook
Copy link

This doesn't seem to work any more.

@helgatheviking
Copy link
Author

@captainhook As of NYP 3, it's preferred to use the wc_nyp_price_input_attributes filter. See the updated gist. If you still have issues, please open a support ticket at https://woocommerce.com/my-account/create-a-ticket/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment