Tips and Tricks HQ Support Portal › Forums › WP eStore Forum › WP eStore General Questions › Is there a function call to show the total # of items left for sale?
Tagged: total items left for sale
- This topic has 10 replies, 2 voices, and was last updated 12 years, 6 months ago by billboardfamily.
September 21, 2010 at 1:21 am #1885
On my site, there are spots where I want to show how many days are left for sale (we sell each day only one time). Basically I want to call a php function that shows the total # of items left for sale. How can I do this?September 21, 2010 at 2:58 am #24602
yes there is a shortcode and a PHP function that you can use to get the total #of items left for sale.
Please check the eStore shortcodes and PHP function references:
http://www.tipsandtricks-hq.com/ecommerce/wp-estore-shortcodes-and-functions-reference-460September 21, 2010 at 3:06 am #24603
I did not see it there. I need a php call, not a short code, btwSeptember 21, 2010 at 3:19 am #24604
The name of the document is “Shortcodes AND PHP function references” so if you read the PDF file you will see that there is a section for PHP functions.September 21, 2010 at 3:23 am #24605
I am sorry.
I read: http://www.tipsandtricks-hq.com/ecommerce/wp-content/uploads/wp-estore-shortcodes.pdf
And I see how to show all the items available for a specific ID … but not for the entire store.September 21, 2010 at 4:11 am #24606
I didn’t realize you wanted the items available for the entire site. There is no function for that but couldn’t you aggregate all the numbers in a loop?September 21, 2010 at 4:20 am #24607
That is pretty much beyond my skill level. If you know of the code to do it…please enlighten me. thanks!September 21, 2010 at 5:14 am #24608
You can add the following code in the “wp_eStore1.php” file and then call the function:
$products_table_name = WP_ESTORE_PRODUCTS_TABLE_NAME;
$wp_eStore_db = $wpdb->get_results("SELECT * FROM $products_table_name ORDER BY id DESC", OBJECT);
$total_available_copies = 0;
foreach ($wp_eStore_db as $wp_eStore_db)
$total_available_copies += $wp_eStore_db->available_copies;
I just coded this on the fly so no testing have been done on this but it should give you the idea.September 21, 2010 at 6:07 am #24609
Just added that to the end of the file (before the closing ?>, of course) and called it on this page: http://billboardfamily.com/contact-us/ (you can see the section in the sidebar area).
Unfortunately….nothing is returned there where I put the call.
Here is the call I used: <?php eStore_get_remaining_copies_of_all_products() ?>September 21, 2010 at 6:28 am #24610
You have to echo the output… so try the following in your template file:
<?php echo eStore_get_remaining_copies_of_all_products(); ?>September 21, 2010 at 6:41 am #24611
That has done it….that you so much!!!!!!
- You must be logged in to reply to this topic.