Vendor maximum 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 WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Tagged: , , ,

Viewing 3 reply threads
  • Author
    Posts
    • #86883
      M Max
      Participant

      I want the vendor could only sell products for a maximum price € 30.
      How can I fix this pricing?

    • #87105
      WCFM Forum
      Keymaster

      OK, what type of products you are allowing to create by vendors?

    • #88106
      M Max
      Participant

      Single & Variable products.

    • #88470
      WCFM Forum
      Keymaster

      HI,

      Please use this code to your site –

      add_filter( 'wcfm_form_custom_validation', function( $wcfm_products_manage_form_data, $form_manager ) {
        if( $form_manager == 'product_manage' ) {
        	if( $wcfm_products_manage_form_data['product_type'] == 'simple' ) {
      			$regular_price = isset( $wcfm_products_manage_form_data['regular_price'] ) ? wc_clean( $wcfm_products_manage_form_data['regular_price'] ) : '';
      			
      			if( $regular_price && ( $regular_price > 30 ) ) {
      				$custom_validation_results['has_error'] = true;
      				$custom_validation_results['message'] = 'Product maximum price should not be more than 30';
      				return $custom_validation_results;
      			}
      		} elseif( $wcfm_products_manage_form_data['product_type'] == 'variable' ) {
      			if(isset($wcfm_products_manage_form_data['variations']) && !empty($wcfm_products_manage_form_data['variations'])) {
      			  foreach($wcfm_products_manage_form_data['variations'] as $variations) {
      			  	$regular_price = isset( $variations['regular_price'] ) ? wc_clean( $variations['regular_price'] ) : '';
      					
      					if( $regular_price && ( $regular_price > 30 ) ) {
      						$custom_validation_results['has_error'] = true;
      						$custom_validation_results['message'] = 'Product maximum price should not be more than 30';
      						return $custom_validation_results;
      					}
      			  }
      			}
      		}
        }
        return $wcfm_products_manage_form_data;
      }, 50 , 2 );

      Add this code to your child theme’s functions.php
      In case you do not have child theme then add code using this plugin – https://wordpress.org/plugins/code-snippets/

      Thank You

Viewing 3 reply threads
  • The topic ‘Vendor maximum price’ is closed to new replies.