Created
April 1, 2022 10:18
-
-
Save amirhp-com/37f64ae0aff71d9337900f1ec2f57d30 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
add_filter( "puiw_printinvoice_create_html_item_row_metas", "my_custom_lineitems_macros", 10, 5); | |
/* add the macro: {{{remaining-qty}}} */ | |
function my_custom_lineitems_macros ($macros, $item_id, $item, $product_id, $order){ | |
$product = $item->get_product(); | |
$current_qty = $product->get_stock_quantity(); | |
$bought_qty = $item->get_quantity(); | |
$remaining_qty = (int) $current_qty - (int) $bought_qty; | |
$macros["remaining-qty"] = $remaining_qty; | |
return $macros; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment