Last active
August 8, 2022 07:53
-
-
Save romanpamula/1cdafc392881b6fbf7e65a0638719318 to your computer and use it in GitHub Desktop.
Adds product's stock quantity on admin order detail page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Adds product's stock quantity on admin order detail page in WooCommerce | |
* | |
* Snippet updated on 18/9/2021 for compatibility with PHP 8 | |
* | |
* @since 3.0.0 | |
* @see https://pamula.sk/woocommerce-ako-zobrazit-pocet-produktov-na-sklade-v-detaile-objednavky/ | |
* | |
* Please REMOVE the opening <?php tag before placing into functions.php | |
* Prosim ODSTRANTE otvaraciu <?php znacku pred umiestnenim do functions.php | |
*/ | |
add_action('woocommerce_admin_order_item_headers', 'add_stock_status_header_on_order_item_view'); | |
function add_stock_status_header_on_order_item_view() | |
{ ?> | |
<th class="quantity sortable" data-sort="string-ins"><?php | |
_e('Stock Qty', 'woocommerce'); ?></th><?php | |
} | |
add_action('woocommerce_admin_order_item_values', 'add_stock_status_value_on_order_item_view'); | |
function add_stock_status_value_on_order_item_view($_product) | |
{ ?> | |
<td class="quantity" width="1%"> | |
<div class="view"><?php | |
if (is_callable(array($_product, 'get_manage_stock')) && | |
method_exists($_product, 'get_manage_stock')) { | |
echo $_product->get_stock_quantity(); | |
} ?> | |
</div> | |
</td><?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi
How do I make this stock quantity appear at the end of the list and not at the beginning?
thank you in advance