Advertisement
palsushobhan

wcfm-price-under-inventory-tab

Nov 14th, 2022
950
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.96 KB | None | 0 0
  1.  
  2. add_filter('wcfm_product_manage_fields_pricing', function($fields) {
  3.     if(isset($fields['regular_price'])) {
  4.         unset($fields['regular_price']);
  5.     }
  6.     if(isset($fields['sale_price'])) {
  7.         unset($fields['sale_price']);
  8.     }
  9.     return $fields;
  10. });
  11.  
  12. add_filter('wcfm_product_fields_stock', function($fields, $product_id) {
  13.     $wcfm_wpml_edit_disable_element = '';
  14.     if ( $product_id && defined( 'ICL_SITEPRESS_VERSION' ) && ! ICL_PLUGIN_INACTIVE && class_exists( 'SitePress' ) ) {
  15.         global $sitepress, $wpml_post_translations;
  16.         $current_language = $sitepress->get_current_language();
  17.         $source_language  = $wpml_post_translations->get_source_lang_code( $product_id );
  18.         if( $source_language && ( $source_language != $current_language ) ) {
  19.             $wcfm_is_translated_product = true;
  20.             $wcfm_wpml_edit_disable_element = 'wcfm_wpml_hide';
  21.         }
  22.     }
  23.     $regular_price = '';
  24.     $sale_price = '';
  25.     if(!empty($product_id)) {
  26.         $product = wc_get_product($product_id );
  27.         if ( is_a( $product, 'WC_Product' ) ) {
  28.             $regular_price = $product->get_regular_price( 'edit' );
  29.             $sale_price = $product->get_sale_price( 'edit' );
  30.         }
  31.     }
  32.     if(!isset($fields['regular_price'])) {
  33.         $fields['regular_price'] = array('label' => __('Price', 'wc-frontend-manager') . ' (' . get_woocommerce_currency_symbol() . ')', 'type' => 'number', 'class' => 'wcfm-text wcfm_ele wcfm_non_negative_input simple external non-subscription non-variable-subscription non-auction non-redq_rental non-accommodation-booking non-lottery non-pw-gift-card' . ' ' . $wcfm_wpml_edit_disable_element, 'label_class' => 'wcfm_ele wcfm_title simple external non-subscription non-variable-subscription non-auction non-redq_rental non-accommodation-booking non-lottery non-pw-gift-card' . ' ' . $wcfm_wpml_edit_disable_element, 'value' => $regular_price, 'attributes' => array( 'min' => '0.1', 'step'=> '0.1' ) );
  34.     }
  35.     if(!isset($fields['sale_price'])) {
  36.         $fields['sale_price'] = array('label' => __('Sale Price', 'wc-frontend-manager') . ' (' . get_woocommerce_currency_symbol() . ')', 'type' => 'number', 'class' => 'wcfm-text wcfm_ele wcfm_non_negative_input simple external non-variable-subscription non-auction non-redq_rental non-accommodation-booking non-lottery non-pw-gift-card' . ' ' . $wcfm_wpml_edit_disable_element, 'label_class' => 'wcfm_ele wcfm_title simple external non-variable-subscription non-auction non-redq_rental non-accommodation-booking non-lottery non-pw-gift-card' . ' ' . $wcfm_wpml_edit_disable_element, 'value' => $sale_price, 'desc_class' => 'wcfm_ele simple external non-variable-subscription non-auction non-redq_rental non-accommodation-booking non-lottery non-pw-gift-card sales_schedule' . ' ' . $wcfm_wpml_edit_disable_element, 'desc' => __( 'schedule', 'wc-frontend-manager' ), 'attributes' => array( 'min' => '0.1', 'step'=> '0.1' ) );
  37.     }
  38.     return $fields;
  39. }, 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement