Title: echo product weight with PHP
Last modified: August 21, 2016

---

# echo product weight with PHP

 *  Resolved [bobspalding](https://wordpress.org/support/users/bobspalding/)
 * (@bobspalding)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/echo-product-weight-with-php/)
 * Hi, I was wondering if it would be possible to echo the product weight with a
   PHP code on the single products page a little bit like <?php echo ‘weight’ ?>(
   Note- Code not real… yet) All help appreciated.
 * [http://wordpress.org/extend/plugins/wp-e-commerce/](http://wordpress.org/extend/plugins/wp-e-commerce/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Justin Sainton](https://wordpress.org/support/users/justinsainton/)
 * (@justinsainton)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/echo-product-weight-with-php/#post-3904915)
 * 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](https://wordpress.org/support/users/bobspalding/)
 * (@bobspalding)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/echo-product-weight-with-php/#post-3904917)
 * 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](https://wordpress.org/support/users/splashingpixelscom/)
 * (@splashingpixelscom)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/echo-product-weight-with-php/#post-3904918)
 * 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.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-e-commerce_ebebeb.svg)
 * [WP eCommerce](https://wordpress.org/plugins/wp-e-commerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-e-commerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-e-commerce/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-e-commerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-e-commerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-e-commerce/reviews/)

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)
 * [weight](https://wordpress.org/support/topic-tag/weight/)

 * 3 replies
 * 3 participants
 * Last reply from: [Roy Ho](https://wordpress.org/support/users/splashingpixelscom/)
 * Last activity: [12 years, 10 months ago](https://wordpress.org/support/topic/echo-product-weight-with-php/#post-3904918)
 * Status: resolved