Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Ultimate › How could make "Regular Price" field became "Required" at variable product?
Tagged: variable product Regular Price
- This topic has 4 replies, 2 voices, and was last updated 5 years, 7 months ago by MOHO.
Viewing 4 reply threads
- AuthorPosts
- August 4, 2018 at 8:33 pm #27637
- August 5, 2018 at 5:20 pm #27714WCFM ForumKeymaster
Hi,
I have give you a code yesterday for variations, please replace that with this code –
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( $wp->query_vars['wcfm-products-manage'] ) && !empty( $wp->query_vars['wcfm-products-manage'] ) ) { $product_id = absint( $wp->query_vars['wcfm-products-manage'] ); } if( $product_id ) { if( get_post_status( $product_id ) == 'publish' ) { if( !current_user_can( 'administrator' ) ) { if( isset( $variation_fileds['regular_price'] ) ) { $variation_fileds['regular_price']['attributes'] = array( 'readonly' => true ); } if( isset( $variation_fileds['sale_price'] ) ) { $variation_fileds['sale_price']['attributes'] = array( 'readonly' => true ); } } } } 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 );
I have added few more lines in that block, you may only add that part as well –
if( isset( $variation_fileds['regular_price'] ) ) { $variation_fileds['regular_price']['custom_attributes'] = array( 'required' => 1 ); }
Thank You
- August 6, 2018 at 2:27 am #27722MOHOParticipant
Thanks it work now!
and if i hope the vendor user could edit the price of live product.
What code should i remove?
- August 6, 2018 at 10:16 am #27755WCFM ForumKeymaster
Hi,
For simple product I have give you a separate code, just disable that.
For variation, disable this part –
if( $product_id ) { if( get_post_status( $product_id ) == 'publish' ) { if( !current_user_can( 'administrator' ) ) { if( isset( $variation_fileds['regular_price'] ) ) { $variation_fileds['regular_price']['attributes'] = array( 'readonly' => true ); } if( isset( $variation_fileds['sale_price'] ) ) { $variation_fileds['sale_price']['attributes'] = array( 'readonly' => true ); } } } }
Thank You
- August 6, 2018 at 10:42 pm #27802MOHOParticipant
thanks a lot!
- AuthorPosts
Viewing 4 reply threads
- The topic ‘How could make "Regular Price" field became "Required" at variable product?’ is closed to new replies.