Home / Admin / Min-Max Product Price (with decimal support)
Duplicate Snippet

Embed Snippet on Your Site

Min-Max Product Price (with decimal support)

Add minimum/maximum validation to your product's price - with decimal support

Code Preview
php
<?php
add_filter( 'wcv_product_price', 'price_min_max' );
function price_min_max( $args ) {
	$args['custom_attributes'] = array(
		'min'                        => 3.2,
		'max'                        => 200.21,
		'step'                       => 0.01,
		'data-parsley-type'          => 'number',
		'data-parsley-range-message' => __( 'Price must be between 3.2 and 200.01', 'wcvendors-pro' ),
		'pattern'                    => '[0-9]+([\.,][0-9]+)?',
		'type'                       => 'number',
	);
	return $args;
}

Comments

Add a Comment