WCML_Bulk_Stock_Management

Compatibility class for plugin WooCommerce Bulk Stock Management http://www.woothemes.com/products/bulk-stock-management/.

Defined (1)

The class is defined in the following location(s).

/compatibility/class-wcml-bulk-stock-management.php  
  1. class WCML_Bulk_Stock_Management { 
  2. function __construct() { 
  3. if (is_admin() && isset($_GET['page']) && $_GET['page'] == 'woocommerce-bulk-stock-management') { 
  4. global $sitepress; 
  5. remove_action('admin_enqueue_scripts', array($sitepress, 'language_filter')); 
  6.  
  7. add_action( 'wc_bulk_stock_after_process_qty', array($this, 'wc_bulk_stock_after_process_qty_action'), 10, 1 ); 
  8.  
  9. function wc_bulk_stock_after_process_qty_action($id) { 
  10. global $sitepress; 
  11.  
  12. $new_quantity = get_post_meta($id, '_stock', true); 
  13.  
  14. if (is_numeric($new_quantity)) { 
  15.  
  16. $new_stock_status = ($new_quantity > 0) ? "instock" : "outofstock"; 
  17. wc_update_product_stock_status($id, $new_stock_status); 
  18.  
  19. $trid = $sitepress->get_element_trid( $id, 'post_product' ); 
  20. if (is_numeric($trid)) { 
  21. $translations = $sitepress->get_element_translations( $trid, 'post_product' ); 
  22.  
  23. if (is_array($translations)) { 
  24. foreach ($translations as $translation) { 
  25. if ( !isset($translation->element_id) || $translation->element_id == $id) { 
  26. continue; 
  27. update_post_meta($translation->element_id, '_stock', $new_quantity); 
  28. wc_update_product_stock_status($translation->element_id, $new_stock_status); 
  29.