Closed remcotolsma closed 1 year ago
We already have some code in place for this: https://github.com/pronamic/wp-pronamic-pay-woocommerce/blob/21974a29deef5a8ac633ba199458afaf162fb82e/src/Extension.php#L760-L831
To make this work properly, we keep track of how much refund we have processed in the WooCommerce order in meta: _pronamic_amount_refunded.
_pronamic_amount_refunded
For the difference between this amount and the refunded we create a WooCommerce refund via wc_create_refund.
wc_create_refund
We should extend this with line_items: https://github.com/woocommerce/woocommerce/blob/52bc1879bb3b05413d3e37bdbd3b42b5a04d73db/plugins/woocommerce/includes/wc-order-functions.php#L515-L677
line_items
Also we don't have to keep track of the refunded amount, WooCommerce has a function for this: https://github.com/woocommerce/woocommerce/blob/52bc1879bb3b05413d3e37bdbd3b42b5a04d73db/plugins/woocommerce/includes/class-wc-order.php#L2012-L2031
We already have some code in place for this: https://github.com/pronamic/wp-pronamic-pay-woocommerce/blob/21974a29deef5a8ac633ba199458afaf162fb82e/src/Extension.php#L760-L831
To make this work properly, we keep track of how much refund we have processed in the WooCommerce order in meta:
_pronamic_amount_refunded
.For the difference between this amount and the refunded we create a WooCommerce refund via
wc_create_refund
.We should extend this with
line_items
: https://github.com/woocommerce/woocommerce/blob/52bc1879bb3b05413d3e37bdbd3b42b5a04d73db/plugins/woocommerce/includes/wc-order-functions.php#L515-L677Also we don't have to keep track of the refunded amount, WooCommerce has a function for this: https://github.com/woocommerce/woocommerce/blob/52bc1879bb3b05413d3e37bdbd3b42b5a04d73db/plugins/woocommerce/includes/class-wc-order.php#L2012-L2031