• Resolved kellydj01

    (@kellydj01)


    Hi,

    First of all thanks for this plugin which works like a charm.

    I need help with some display functionnality for which I need to code but I don’t know how. What I want is to have a table on my product page displaying all 6 prices of my variable product. Basically I need to know how to get these dynamic prices via a php code I guess, so I don’t have to change it manually everytime the exchange rate changes.

    Thanks a lot for your help.
    Kelly

Viewing 1 replies (of 1 total)
  • Thread Starter kellydj01

    (@kellydj01)

    Ok, I managed to do it with a custom php code :

    
    function price_shortcode_callback( $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 = number_format($_product->get_price(), 0) . " €";
    }
    return $html;
    }
    add_shortcode( 'woocommerce_price', 'price_shortcode_callback' );
    

    And adding this on my product page :

    
    [woocommerce_price id="1080"]
    

    If this can help someone…

    • This reply was modified 6 years, 6 months ago by kellydj01.
Viewing 1 replies (of 1 total)

The topic ‘Dynamic price display’ is closed to new replies.