• Resolved Bakhshi

    (@bakhshi)


    Hello Sir/ Madam

    I have some products on my shop, which were made by woocommerce.
    Now I would like to display only the price of one of them in my form field.

    how can I display a woocommerce product price by id number in one field any form?

    Thanks in advance.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @bakhshi

    My apologies for the delay in responding to your question. If you want to access the products’ prices by their IDs you would need the “WooCommerce Products And Variations Prices for Calculated Fields Form” complementary plugin (https://cff-bundles.dwbooster.com/product/woocommerce-price).

    Best regards.

    Thread Starter Bakhshi

    (@bakhshi)

    Wow! …. great! …. congratulation!
    Honestly, I have been thinking for 2 years, why you have always made an effort to have great support for your clilent, thesedays I can see the result of your viewpoint!

    In addition to customer orientation and the prosperity of your business, you could come up with new plugins based on client’s problems, and make a great progress in your job!

    This was like a kind of lesson to me. congratulat to you!

    Plugin Author codepeople

    (@codepeople)

    Hello @bakhshi

    Thank you very much.

    Best regards.

    Thread Starter Bakhshi

    (@bakhshi)

    Hello dear Codepeople

    Honestly, I live in Iran, and we are under sanction, so depositing international payments are impossible for me due to sanction.

    I put the following code into functions.php file:

    //Get Woocommerce Price By ID MihanWP
    function mihanwp_get_price( $atts ) {
        $atts = shortcode_atts( array(
            'id' => null,
        ), $atts, 'bartag' );
    
        $html = '';
    
        if( intval( $atts['id'] ) > 0 && function_exists( 'wc_get_product' ) ){
             $_product = wc_get_product( $atts['id'] );
             $html = "" . $_product->get_price();
        }
        return $html;
    }
    add_shortcode( 'woocommerce_price', 'mihanwp_get_price' );

    and I made this shortcode [woocommerce_price id="4431"] for displaying my price and put it in a page and it worked, but I could not display it by the form!

    is it possible put a shortcode into any field of Calculated Fields Form?

    Plugin Author codepeople

    (@codepeople)

    Hello @bakhshi

    I’m sorry, our plugin renders the form on the client-side with JavaScript. We cannot guarantee the HTML structures generated by third-party shortcodes don’t break the form code. For this reason, our plugin does not support third-party shortcodes in the form fields.

    Best regards.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘how to display a woocommerce product price by id number in one field?’ is closed to new replies.