• Hello i have contact the support on your site 3 days ago and i don’t recieved any reply for this issue:

    Well i need to add new field for product price called (max price)
    I have trying with following snippet and it works fine but only works on woocommerce:`

    Here the code:

    // Add a custom field for price range to product in backend add_action( ‘woocommerce_product_options_pricing’, ‘add_field_product_options_pricing’ ); function add_field_product_options_pricing() { global $post;

    echo ‘<div class=”options_group show_if_simple”>’;

    woocommerce_wp_text_input( array( ‘id’ => ‘_max_price_for_range’, ‘label’ => __(‘Max price for range’, ‘woocommerce’).’ (‘.get_woocommerce_currency_symbol().’)’, ‘placeholder’ => __(‘Set the max price for range’, ‘woocommerce’), ‘description’ => __(‘Set the max price for range, to activate it…’, ‘woocommerce’), ‘desc_tip’ => ‘true’, ));

    echo ‘</div>’; }

    // Save product custom field to database when submitted in Backend add_action( ‘woocommerce_process_product_meta’, ‘save_product_options_custom_fields’, 30, 1 ); function save_product_options_custom_fields( $post_id ){ // Saving custom field value if( isset( $_POST[‘_max_price_for_range’] ) ){ update_post_meta( $post_id, ‘_max_price_for_range’, sanitize_text_field( $_POST[‘_max_price_for_range’] ) ); } }

    // Frontend: display a price range when the max price is set for the product add_filter( ‘woocommerce_get_price_html’, ‘custom_range_price_format’, 10, 2 ); function custom_range_price_format( $price, $product ) {

    // Only for simple product type if( $product->is_type(‘simple’) ){ // Get the max price for range $max_price = get_post_meta( $product->get_id(), ‘_max_price_for_range’, true );

    if( empty($max_price) ) return $price; // exit

    $active_price = wc_get_price_to_display( $product, array( ‘price’ => $product->get_price() ) );

    $price = sprintf( ‘%s – %s’, wc_price($active_price), wc_price($max_price) ); } return $price; }

    After testing this code it display correctly in the backend & frontend
    I need to set this code for wcfm, Please try it to understand what i need!

    Please Check others solution here:

    stackoverflow.com/questions/47759205/display-the-min-and-max-prices-in-woocommerce-product-category-archives

    stackoverflow.com/search?q=min+max+price+woocommerce

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘custom field for price range’ is closed to new replies.