Support » Plugins » WooCommerce Quantity Available

  • I am somewhat familiar with how java functions work, but have never tried using a WP function myself.

    Looking to access WooCommerce quantity available data for use on a page, to display on the frontend.

    I found the function, but am unsure on how to use it? Help is super appreciated:

    128 /**
    129 * Returns number of items available for sale.
    130 *
    131 * @access public
    132 * @return int
    133 */
    134 function get_stock_quantity() {
    135 return $this->managing_stock() ? apply_filters( ‘woocommerce_stock_amount’, $this->stock ) : ”;
    136 }

    I searched for a shortcode, but found none

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hey there —

    “WP functions” are actually written in PHP (just for clarity on terminology).

    I am not familiar with WooCommerce and the function you’ve got, however it probably needs to go into your theme’s functions.php file or a custom plugin file that you’ve deployed on your site. Be very (very!) careful when editing functions.php though – a tiny mistake can bring your whole site down and you won’t be able to get into the admin screens. Always take a backup of the file before editing, and have your FTP access info on hand so you can restore the backup on the server if something goes wrong.

    The code you have includes line numbers which will create all sorts of problems. You must have copied it from a site like GitHub. When copying code from the Web, always look for the “raw” link – you need just the text. Those extra numbers will mess you up. You should go back to wherever you found this and copy just the actual function.

    Regardless, all of that is just sort of background info. To get you help on whatever you’re trying to implement, you should go to the WooCommerce plugin support page here on or use the plugin developer’s support.

    Thanks essaysnark.

    Yes, I should have removed the line numbers 🙂 I am not ready yet to purchase plugin support, but will soon…until then help would be great

    So, I place the function in functions.php, then what do I do?

    I am not seeing tutorials on how to use functions from a plugin, just custom functions…

    I saw elsewhere that there is a WC object, which I guess I would use to call the function, but as stated above have only worked in java with functions…

    Help is much appreciated

    Any seen a tutorial on using plugin functions?

    Not sure how to do this…

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WooCommerce Quantity Available’ is closed to new replies.