Get price from table via. product id (1 post)

  1. nikwitting
    Posted 2 years ago #

    I am making af woocommerce site where each product contains a tablepress table, which i can get a certain cell value with af shortcode.
    Every product will have its own table, with the table id equal to the product sku.

    In functions.php i have made a filter so the price shown across the site will be equal to the cell value in the table.

    add_filter('woocommerce_empty_price_html', 'custom_call_for_price');
    function custom_call_for_price() {
    global $product, $woocommerce;
    $product_id = $_product->parent->sku;
        echo do_shortcode("[table-cell id=$product_id row=2 column=2 /]");

    The code works if i write
    $product_id=1; instead of $product_id = $_product->parent->sku; even though the sku is set as 1

    NB. i am new to php and woocommerce

Topic Closed

This topic has been closed to new replies.

About this Topic