Custom WordPress and WooCommerce Development

WooCommerce Name Your Price – What’s New in 3.0

Because I personally have clearly not aged a bit since 2012, it’s hard to believe my Name Your Price plug in is eight years old. But here we both are…older and, I hope, at least a little wiser. 

Thousands of licenses are sold each year for Name Your Price, and users have come up with some pretty clever ways to put it to work for them, including bill pay, tipping, and more. At first, I imagined Name Your Price would be a cool way to sell products – and it is! But over eight years, my customers have shown me how they use Name Your Price for donations, to democratize pricing for certain products, as a strategic sales and marketing tool and many other use cases that never even crossed my mind!

You have all taught me a lot! And I’m always trying to make Name Your Price better for the people who use it. And while I had made small updates to version 2.0 over the years, I started to work on what would really be the first substantial changes since 2014.  SINCE 2014! And it took…forever. 

Its Been A Long Time Mueller Report GIF - Find & Share on GIPHY
Scene from The Titanic, and older Rose reflects that is has been 84 years…

No one was really screaming out for big changes… I mean if it ain’t broke right?… but there was a usability issue that came up often enough that I knew needed tackling. To users, the changes we’ve made here won’t be jarring. Heck, some users may not notice the changes at all, but I hope you do and I hope you like them.

We’ve streamlined the user experience, improved function for hidden minimum prices, provided accessibility for users of screen readers, and the same reliable compatibility with a broad range of product types and plugins.

If you want to geek out with me a little, here’s a deeper dive into the details of Name Your Price’s long-awaited version 3.0.

Changelog, TLDR

WooCommerce Name Your Price version 3.0 features a total rewrite of the front-end validation scripts. As the biggest rewrite to date, this release:

  • Polishes the customer’s user experience (UX) 
  • Resolves a specific usability issue for hidden minimum prices or blank input fields
  • Maintains, improves, and expands compatibility with the many plugins which integrate with Name Your Price
    • Improves behavior where there can be more than one Name-Your-Price input on a page (such as with grouped products, product bundles, etc.)
    • Introduces compatibility with WooCommerce.com’s PayPal Gateway’s smart buttons
  • Adds improved accessibility for users of screen readers.

Resolving the Issue with Hidden Minimums/Blank Inputs

In previous versions of Name Your Price, some customers encountered difficulty on sites with hidden minimum prices or blank price-input fields. The add to cart button would be disabled and could not be clicked on if no value or an inadequate value (below the seller’s minimum) were entered into the price field. Further, even after the customer entered a valid price, the button would remain disabled until the customer clicked somewhere in empty space. 

In isolation, this issue would be easy enough to resolve, but a solution that preserved compatibility with the many plugins which integrate with Name Your Price made this more complex.

The script rewrite in version 3.0 fully resolves this issue and maintains and improves Name Your Price’s seamless integration with existing compatible plugins.

Subtle Enhancements to Price Inputs

Recording of a text input. A user enters 9, which is below the minimum price and an error appears. A user then enters 29 and the price disappears and the add to cart button comes back to full opacity.
An empty price input and relocated error message improve UX.

You might notice that the price input is now empty by default in Name Your Price v3.0. This makes it easier for users who are navigating the site with keyboards. The minimum price is styled just a little bit differently, and the error notice is now immediately below the input. We think these subtle changes improve performance, but, as always, Name Your Price is fully extensible, and the layout can be customized to your wishes.

Suggested and Minimum-Price Placeholders

In previous versions of Name Your Price, you could set the strings for “Suggested price” and “Minimum price” in the settings, and the price would be added automatically. This could be difficult for users who did not actually want to display the price there. Version 3.0 now uses a %PRICE% placeholder, and this is where the suggested or minimum price will be inserted.

In version 3.0, this tiny update to the database will insert this placeholder automatically, and monolingual sites shouldn’t even notice the change. However, if you have a multi-lingual site, you will need to update your translations to use this new placeholder.

A screenshot of the Name Your Price settings. The suggested price text and minimum price text values now include a placeholder, %PRICE%,
The %PRICE% placeholder is automatically added to your settings.

Developer Notes

Removed woocommerce_get_price_input filter

In order to ensure that all displayed HTML was properly escaped, we have removed this filter and moved the price input’s HTML back into the price-input.php filter. This is a potentially breaking change if you were targeting this filter for customization, but because it was a security risk, we decided it was better to remove it.

In its stead, we’ve also introduced a new filter called wc_nyp_price_input_attributes where you can filter most of the attributes for the input in a more secure way.

As an example, here’s how you would use the new filter to modify the input’s inputmode:

/**
 * Modify NYP price input.
 * 
 * @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_attributes( $attributes, $product, $suffix ) {
	
	$new_attributes = array( 
		'inputmode' => 'decimal',
	);
	
	$attributes['custom_attributes'] = array_merge( $attributes['custom_attributes'], $new_attributes );
	
	return $attributes;
}
add_filter( 'wc_nyp_price_input_attributes', 'kia_custom_nyp_attributes' );
Code language: PHP (php)

Unified Prefixes for Actions and Filters

Version 3.0 renames all actions and filters to begin with the wc_nyp_ prefix_. Over time, previous versions’ actions and filters had picked up different naming conventions, but version 3.0 brings them all into a unified system. Any snippets targeting the old actions and filters you were using will still work, but you should try to update them at your earliest convenience.

Need Support?

If you have purchased it… first thank you! If there’s anything we can help you with, please submit a support ticket and we’ll be in touch with you as soon as possible.


Comments

4 responses to “WooCommerce Name Your Price – What’s New in 3.0”

  1. I have purchased it and I can’t find where to open a support ticket.
    I can not get this extension to work with Events Tickets Plus. Can you help me?

    1. You can submit a ticket via your WooCommerce.com account at https://woocommerce.com/my-account/create-a-ticket/

      However, you should know that currently Events Tickets Plus is not fully compatible with NYP. Compatibility with 3rd party plugins is not covered under the WooCommerce Support Policy.

      There’s been enough interest in the past, that I’ve written partial support via https://github.com/kathyisawesome/wc-nyp-event-tickets but that plugin is very much “as is” and is not officially supported by me. Events Tickets made some updates and so the bridge plugin needs updating but I cannot prioritize unless it becomes a commissioned project.

      1. Hey thanks a lot for all the work you;ve done on the bridge plugin. I installed it and I was able to get it up on an event page. It auto-replaced the price area but didn’t actually add the price I entered in the cart, it just went with the $0 price that the ticket is set to when it was added to the cart. Any ideas on how to register that payment? I’d be happy to chip in on some custom work if you’re interested.

  2. Hi Kathy! We love the “Name Your Price” Plug-in, it is really fantastic for our organization. I do have a question for you, though regarding our accounting needs. So, in our store we have set the minimum prices for products, but any amount in excess of that would be considered a tax-deductible donation, so we track that for our customers…manually, which has become entirely untenable. The transactions are uploaded to Quickbooks, at which point our bookkeeper has manually made note of the donation amount by customer. We are desperately in need of a solution to this, and I am not sure how various plug-ins interface with one another.
    Suggestions?