Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions paymentiq-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ public function init_hooks() {
if($this->captureOnStatusComplete === 'yes') {
add_action( 'woocommerce_order_status_completed', array( $this, 'paymentiq_checkout_order_status_completed' ) );
}

add_filter( 'woocommerce_admin_order_should_render_refunds', array( $this, 'paymentiq_should_render_refund' ) );

}

/* Hook when a woo order is cancelled - if the order has a piqTxId - do a void (cancel in PIQ) */
Expand All @@ -247,6 +250,15 @@ public function init_hooks() {
add_action( 'piq_co_handle_transaction_status_update', array( $this, 'handle_transaction_status_update' ) );
}

function paymentiq_should_render_refund () {
global $post;
$order_id = $post->ID;
$order = wc_get_order( $order_id );
$order_completed = in_array( $order->get_status(), array( 'completed' ), true );
$render_refunds = (0 < $order->get_total() - $order->get_total_refunded() || 0 < absint( $order->get_item_count() - $order->get_item_count_refunded())) && $order_completed;
return $render_refunds;
}

/*
When developing locally, disable trying to send emails
*/
Expand Down