Last active
November 8, 2024 19:07
-
-
Save zackeryfretty/bcce9c3d5ceaaedccd81fdb8abfb8b12 to your computer and use it in GitHub Desktop.
When looping through the items in an order pass the $item to this function to get the quantity returned from the line item.
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
function zf_get_line_item_returned_quantity( $item, $order ) { | |
$returned_quantity = 0; | |
foreach ($order->get_refunds() as $refund) { | |
foreach ($refund->get_items() as $refund_item) { | |
if ($refund_item->get_product_id() == $item->get_product_id()) { | |
$returned_quantity += $refund_item->get_quantity(); | |
} | |
} | |
} | |
return $returned_quantity; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment