Skip to content

Instantly share code, notes, and snippets.

@igorbenic
Created January 26, 2017 12:31
Show Gist options
  • Save igorbenic/2b5e179592194d95afde316fce507597 to your computer and use it in GitHub Desktop.
Save igorbenic/2b5e179592194d95afde316fce507597 to your computer and use it in GitHub Desktop.
WooCommerce Stock Management with other Services | http://www.ibenic.com/woocommerce-stock-management-services
<?php
// woocommerce/includes/abstracts/abstract-wc-product.php
/**
* Returns number of items available for sale.
*
* @return int
*/
public function get_stock_quantity() {
return apply_filters( 'woocommerce_get_stock_quantity', $this->managing_stock() ? wc_stock_amount( $this->stock ) : null, $this );
}
<?php
add_filter( 'woocommerce_get_stock_quantity', 'woodev_stock_get_stock_quantity', 10, 2 );
<?php
add_action( 'woocommerce_product_options_stock_fields', 'woodev_stock_product_service_field' );
<?php
add_action( 'woocommerce_process_product_meta', 'woodev_stock_product_service_field_save' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment