WordPress.org

Ready to get started?Download WordPress

Forums

WP eCommerce
[resolved] echo product weight with PHP (4 posts)

  1. bobspalding
    Member
    Posted 1 year ago #

    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/

  2. Justin Sainton
    Member
    Plugin Author

    Posted 1 year ago #

    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!

  3. bobspalding
    Member
    Posted 12 months ago #

    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;

  4. Roy Ho
    Member
    Posted 12 months ago #

    This is what you want.

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags