Refunds and fees
-
Hi! I have been looking into adding specific fees when processing a refund, for example, a cancellation fee to be added manual and which should be deducted from the amount to be refunded. These fees could be then shown in the email the customer gets so it is all well specified.
I have not found hooks or “easy” methods to create such functionality. It would be great to get some advice or guidance on how to achieve that, and it would even be greater if such hooks could be in place in later versions.
In a nutshell, I am trying the following:
- add_action( ‘admin_enqueue_scripts’, ‘enqueue_custom_refund_script’ );
The function enqueue_custom_refund_script checks whether I am in the admin, Edit Order. If that is the case, then I enqueue a js: wp_enqueue_script( ‘custom-refund-fields’, get_template_directory_uri() . ‘/js/custom-refund-fields.js’, array( ‘jquery’ ), ‘1.0’, true ); - custom-refund-fields.js
Shows the fields I want to add when the button “refund” is clicked - Additional functionality is added to perform the calculations etc.
The main problem I have is actually with 1.
I am using $screen = get_current_screen(); to find out if this is a “shop_order” as post_type. So I wonder if the following: if ( $screen && ‘shop_order’ === $screen->post_type ) { … }, is sufficient to decide enqueuing the js. I find it a bit unorthodox to use this method, but it may be ok?As said, some guidance would be nice.
- add_action( ‘admin_enqueue_scripts’, ‘enqueue_custom_refund_script’ );
- You must be logged in to reply to this topic.