Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zackeryfretty/bcce9c3d5ceaaedccd81fdb8abfb8b12 to your computer and use it in GitHub Desktop.
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.
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