Home Support Themes TaskHive How can I change value step for prices?

How can I change value step for prices?

  • Author
    Posts
  • ben

    Hi, I have tried everything to change the value step when someone uploads a listing. Is it possible to change the value step for the price field from 0.01 to 1?

    ihor developer

    Please try using this code snippet:

    add_filter(
    	'hivepress/v1/models/listing/attributes',
    	function( $attributes ) {
    		if ( isset( $attributes['price'] ) ) {
    			$attributes['price']['edit_field']['decimals'] = 0;
    		}
     
    		return $attributes;
    	},
    	1000
    );
    ben

    Thank you for your support! It does not seem to work for me.

    ihor developer

    Please try this one instead:

    add_filter(
    	'hivepress/v1/forms/listing_update',
    	function( $form ) {
    		if ( isset( $form['fields']['price'] ) ) {
    			$form['fields']['price']['type']      = 'number';
    			$form['fields']['price']['min_value'] = 0;
    			$form['fields']['price']['decimals']  = 0;
    		}
    
    		return $form;
    	},
    	1000
    );
    ben

    Thank you it works this way! 🙌

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.