jQuery(document).ready(function ($) {
var woocommerce_nyp_params = {
"currency_format_num_decimals": "2",
"currency_format_decimal_sep": ",",
"currency_format_thousand_sep": ".",
"currency_symbol": "\u20ac",
"annual_price_factors": {
"day": "365",
"week": "52",
"month": "12",
"year": "1"
},
"add_to_cart_text": "Add to Cart",
"minimum_error": "Please enter at least %s",
};
/*
* woocommerce_nyp_update function
* wraps all important nyp callbacks for plugins that maybe don't have elements available on load
* ie: quickview, bundles, etc
*/
$.fn.woocommerce_nyp_update = function () {
/*
* Name Your Price Handler for individual items
*/
$(this).on('woocommerce-nyp-update', function () {
// some important objects
var $cart = $(this);
var $nyp = $cart.find('.nyp');
var $nyp_input = $cart.find('.nyp-input');
var $submit = $cart.find(':submit');
// the current price
var form_price = $nyp_input.val();
// if nothing is entered, accept the placeholder as the value
if ($.trim(form_price) == '') {
form_price = $nyp_input.val($nyp_input.data('placeholder'));
}
// add a div to hold the error message
var $error = $cart.find('.woocommerce-nyp-message');
if (!$error.length) $nyp.prepend('<div class="woocommerce-nyp-message woocommerce-error" style="display:none"></div>');
// the default error message
var error_message = woocommerce_nyp_params.minimum_error;
var error = false;
// convert price to default decimal setting for calculations
var form_price_num = woocommerce_nyp_unformat_price(form_price);
var min_price =...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.