• Resolved volbraakzakje

    (@volbraakzakje)


    ?Hi,

    Im trying to create a table with my woocommerce products. The table is just plain html <table>.

    Inside that table I’d like to add shortcodes. I think I need multiple shortcodes for this to work. Most optimally a different one for each.
    These shortcodes should be displayed:
    1. RRP Excl VAT,
    2. Sale Price Excl VAT
    3. Sale Price Incl VAT

    I’ve got this shortcode for nr 3: Sale Price Including VAT:
    [product_price id=XX]

    function wc_price_by_id_shortcode( $atts ) {
        $atts = shortcode_atts( array( 'id' => null, ), $atts, 'bartag' );
    
        if( intval( $atts['id'] ) > 0 && function_exists( 'wc_get_product' ) ){ 
            $_product = wc_get_product( $atts['id'] ); 
            $price = wc_price( $_product->get_price() );
          } 
    
      return $html;
    } 
    add_shortcode( 'product_price', 'wc_price_by_id_shortcode' );
    $html .= "<span class="price_by_id_shortcode">". $price . "</span>";

    Is this correct? And I’m not sure how I can get the RRP Excl TAX and Sales Price Excl TAX.

    Many thanks!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Get Product RRP, Saleprice with shortcode in plain text?’ is closed to new replies.