WordPress at a glance
function is not described

WC_Abstract_Legacy_Product::get_total_stock() public WC 1.0

Deprecated from version 3.0.0. It is no longer supported and can be removed in future releases. It is recommended to replace this function with the same one.

Get total stock - This is the stock of parent and children combined.

{} It's a method of the class: WC_Abstract_Legacy_Product{}

No Hooks.

Return

Int.

Usage

$WC_Abstract_Legacy_Product = new WC_Abstract_Legacy_Product();
$WC_Abstract_Legacy_Product->get_total_stock();

Changelog

Deprecated 3.0.0

Code of WC_Abstract_Legacy_Product::get_total_stock() WC 5.0.0

<?php
public function get_total_stock() {
	wc_deprecated_function( 'WC_Product::get_total_stock', '3.0', 'get_stock_quantity on each child. Beware of performance issues in doing so.' );
	if ( sizeof( $this->get_children() ) > 0 ) {
		$total_stock = max( 0, $this->get_stock_quantity() );

		foreach ( $this->get_children() as $child_id ) {
			if ( 'yes' === get_post_meta( $child_id, '_manage_stock', true ) ) {
				$stock = get_post_meta( $child_id, '_stock', true );
				$total_stock += max( 0, wc_stock_amount( $stock ) );
			}
		}
	} else {
		$total_stock = $this->get_stock_quantity();
	}
	return wc_stock_amount( $total_stock );
}