Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Justin Sainton

    (@justinsainton)

    The weight is stored in a product meta field. You’d want something like the following.

    $meta   = get_post_meta( $product_id, '_wpsc_product_metadata', true );
    $weight = ! empty( $meta['weight'] ) ? $meta['weight'] : 0;

    Hope that helps!

    Thread Starter bobspalding

    (@bobspalding)

    Hi Justin,
    How would I use this code as a PHP line? Just to explain what I mean, would this go something like:
    <?php echo
    $meta = get_post_meta( $product_id, ‘_wpsc_product_metadata’, true );
    $weight = ! empty( $meta[‘weight’] ) ? $meta[‘weight’] : 0;
    ?>
    I just want it to appear on the single_product_page.php you see…

    Thanks for the reply btw;

    Roy Ho

    (@splashingpixelscom)

    This is what you want.

    $meta   = get_post_meta( $product_id, '_wpsc_product_metadata', true );
    $weight = ! empty( $meta['weight'] ) ? $meta['weight'] : 0;
    
    echo $weight;
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘echo product weight with PHP’ is closed to new replies.