In the wpsc-single_product.php file I replaced line #151
To this:
get_var('
SELECT
sum(`pm`.`meta_value`)
FROM
`' . $wpdb->postmeta . '` `pm`
JOIN
`' . $wpdb->posts . '` `p`
ON
`pm`.`post_id` = `p`.`id`
WHERE
`p`.`post_type`= "wpsc-product"
AND
`p`.`post_parent` = ' . $product_id . '
AND
`pm`.`meta_key` = "_wpsc_stock"
');
}
?>
ID, '_wpsc_stock', true );
$remaining_quantity = wpsc_variations_stock_remaining( $post->ID );
_e('Only ', 'wpsc'); echo $stock;echo $remaining_quantity; _e(' left in stock. Order today!', 'wpsc'); ?>
this covers both stock for items without variations and items with variations (combining the number for all variation stock). However it does show 0 if you have variations without any stock set.
Please let me know if anyone who would know a better way or cleaner code to accomplish this. And possibly any alternative if statements to not show this for items without variation stock set.
Aside from this you can easily change the wording of the message, if you don't want to display the actual inventory number.
Change:
to: