Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WC Marketplace › Make price mandatory for variations
- This topic has 1 reply, 2 voices, and was last updated 4 years, 8 months ago by Sushobhan.
- AuthorPosts
- April 26, 2020 at 7:51 am #123131L StewartParticipant
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 );
- April 26, 2020 at 12:31 pm #123191SushobhanKeymaster
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!
- AuthorPosts
- You must be logged in to reply to this topic.