Tips and Tricks HQ Support

Support site for Tips and Tricks HQ premium products

  • Home
  • Contact Us
  • Documentation
  • Forum Home
    • Forum
    • Forum Search
    • Forum Login
    • Forum Registration

Is there a function call to show the total # of items left for sale?

by

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 14 years, 7 months ago by billboardfamily.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • September 21, 2010 at 1:21 am #1885
    billboardfamily
    Member

    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?

    http://www.billboardfamily.com

    September 21, 2010 at 2:58 am #24602
    amin007
    Participant

    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-460

    September 21, 2010 at 3:06 am #24603
    billboardfamily
    Member

    I did not see it there. I need a php call, not a short code, btw

    September 21, 2010 at 3:19 am #24604
    amin007
    Participant

    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
    billboardfamily
    Member

    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
    amin007
    Participant

    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
    billboardfamily
    Member

    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
    amin007
    Participant

    You can add the following code in the “wp_eStore1.php” file and then call the function:

    function eStore_get_remaining_copies_of_all_products()
    {
    global $wpdb;
    $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;
    if ($wp_eStore_db)
    {
    foreach ($wp_eStore_db as $wp_eStore_db)
    {
    $total_available_copies += $wp_eStore_db->available_copies;
    }
    }
    return $total_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
    billboardfamily
    Member

    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
    amin007
    Participant

    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
    billboardfamily
    Member

    That has done it….that you so much!!!!!!

  • Author
    Posts
Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.
Log In

Forum Related

  • Forum Home
  • Forum Search
  • Forum Registration
  • Forum Login

Support Related Forms

  • Contact Us
  • Customer Support
  • Request a Plugin Update
  • Request Fresh Download Links

Useful Links

  • Plugin Upgrade Instructions
  • WP eStore Documentation
  • WP eMember Documentation
  • WP Affiliate Platform Documentation
  • Tips and Tricks HQ Home Page
  • Our Projects

Quick Setup Video Tutorials

  • WP eStore Video Tutorial
  • WP eMember Video Tutorial
  • WP Affiliate Platform Video Tutorial
  • Lightbox Ultimate Video Tutorial

Our Other Plugins

  • WP Express Checkout
  • Stripe Payments Plugin
  • Simple Shopping Cart Plugin
  • Simple Download Monitor

Copyright © 2025 | Tips and Tricks HQ