How could i limit price and custom field read only at live product

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 WCFM – Ultimate How could i limit price and custom field read only at live product

Viewing 2 reply threads
  • Author
    Posts
    • #27529
      MOHO
      Participant

      When vendor submit product as “live, then limit vendor can’t edit price.

      1. Variable product
      every price and sale price of all variable options

      2. Toolset custom field

      You have give me simple product code, these price and custom field also need, thanks.

      By Moho

      Attachments:
      You must be logged in to view attached files.
    • #27576
      WCFM Forum
      Keymaster

      Hi,

      Here is your code for disabling Variation prices –

      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 );
      				}
      			}
      		}
      	}
      	return $variation_fileds;
      }
      add_filter( 'wcfm_product_manage_fields_variations', 'wcfm_restrict_publish_product_variation_pricing', 50, 5 );

      I am checking how this can be done for Toolset fields!

      Thank You

    • #27803
      MOHO
      Participant

      thanks it work. please close it.

Viewing 2 reply threads
  • The topic ‘How could i limit price and custom field read only at live product’ is closed to new replies.