Limiting product price

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Viewing 3 reply threads
  • Author
    • #67631


      Is it possible to limit the price range of products that vendors can sell?
      Specifically, I’d like to disable offering “free” products unless the vendor is a premium subscriber.
      In capabilities I only see limit for number of products but not price.
      A custom code based solution would be perfect as well. For example, is there a hook where I can check the price setting before saving?


    • #67881
      WCFM Forum


      You may add such condition using this hook –

      do_action( 'after_wcfm_products_manage_meta_save', $new_product_id, $wcfm_products_manage_form_data );

      Thank You

    • #68564

      Thanks for the answer!
      Could you be a little bit more specific?
      I’d like to block saving the data if price is zero, and display an error notification on bottom of page, where ‘saved successfully’ normally appears.
      Sorry if it’s a lot to ask, but I would have to read the entire code-base to figure that out.
      Thanks a lot!

    • #69001
      WCFM Forum


      Please add this code to your child theme’s functions.php –

      add_filter( 'wcfm_form_custom_validation', function( $wcfm_products_manage_form_data, $form ) {
      	if( $form == 'product_manage' ) {
      		$product_price = isset( $wcfm_products_manage_form_data['regular_price'] ) ? wc_clean( $wcfm_products_manage_form_data['regular_price'] ) : 0;
      		$product_price = absint( $product_price );
      		if( !$product_price || ( $product_price < 0 ) ) {
      			$wcfm_products_manage_form_data['has_error'] = true;
      			$wcfm_products_manage_form_data['message'] = 'Please add some cost for the product.';
      	return $wcfm_products_manage_form_data;
      }, 50, 2);

      Thank You

Viewing 3 reply threads
  • You must be logged in to reply to this topic.