Hi @josssv
Your approach to adding a custom refund script is technically correct. However, it’s important to note that the method you use to check if you’re on the “Edit Order” page might not be the most reliable.
The admin_enqueue_scripts hook is not specific to the “Edit Order” page; it runs on every admin page. Therefore, using get_current_screen within this hook is not the best practice because it might not always return the expected results.
Though writing or providing custom code is not within the scope of our support policy, here is an example:
add_action( 'load-shop_order', 'enqueue_custom_refund_script' );function enqueue_custom_refund_script() {
wp_enqueue_script( 'custom-refund-fields', get_template_directory_uri() . '/js/custom-refund-fields.js', array( 'jquery' ), '1.0', true );
}
If you still have problems or need further assistance on custom coding, we recommend asking development questions on the #developers channel of the WooCommerce Community Slack. Many of our developers hang out there and will be able to offer insights into your question.
Regarding your request to add hooks in future versions, we appreciate your feedback. It would be great if you added your ideas as an enhancement request, which is where developers go to look for future plugin features and improvements.
I wish I could help more, but hopefully, this gets you going in the right direction to get the job done.
Hi @josssv
I’m glad we were able to help! I will mark this thread as resolved. Should you have further inquiries, kindly create a new topic here.
Meanwhile, if it isn’t too much to ask for – would you mind leaving us a review here?
It only takes a couple of minutes but helps us tremendously. It would mean so much to us and would go a really long way.
Thanks!
