Make price mandatory for variations

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!

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WC Marketplace Make price mandatory for variations

Viewing 1 reply thread
  • Author
    Posts
    • #123131
      L Stewart
      Participant

      Hi,

      I would like to make price mndatory for variations. I found this code you have shared. But is this correct?

      function wcfm_restrict_publish_product_variation_pricing( $variation_fileds, $variations, $variation_shipping_option_array, $variation_tax_classes_options, $products_array ) {
      	global $wp;
      	$product_id = 0;
      
      	if( isset( $variation_fileds['regular_price'] ) ) {
      		$variation_fileds['regular_price']['custom_attributes'] = array( 'required' => 1 );
      	}
      	return $variation_fileds;
      }
      
      add_filter( 'wcfm_product_manage_fields_variations', 'wcfm_restrict_publish_product_variation_pricing', 50, 5 );

      In particular I don’t know what this section is for:
      add_filter( 'wcfm_product_manage_fields_variations', 'wcfm_restrict_publish_product_variation_pricing', 50, 5 );

    • #123191
      Sushobhan
      Keymaster

      Hi,
      This is how a filter is called. You can read more about this here- https://developer.wordpress.org/reference/functions/add_filter/
      Argument 1: wcfm_product_manage_fields_variations is the filter name
      Argument 2: ‘wcfm_restrict_publish_product_variation_pricing’ is the callback function
      Argument 3 (Optional): Is the priority of this callback function. Low value of priority ensures early execution. Default value- 10
      Argument 4 (Optional): Number of arguments getting passed to the callback function
      Hope this helps!
      Thank You!

Viewing 1 reply thread
  • You must be logged in to reply to this topic.