You shouldn’t edit core files. No snippets exist for this so if you need extra customisation in the backend you’ll need a developer.
jobs.wordpress.net
I mentioned in the other threads, we’re looking at this for future updates.
Hi Mike
did not get you exactly
No snippets exist for this so if you need extra customisation in the backend you’ll need a developer.
Do you mean I need a developer who will override for me woocommerce files?
Yes, ideally via custom javascript files which won’t be removed on update.
Mike
Is it possible override woocomerce’s admin js files in theme?
Or it should be like new plugin?
Can you say which files can be affected ?
It can be added to a new plugin, and can either be JS based, or your plugin could maybe add a new button via PHP too.
Can you say which files can be affected ?
Not modifying files so it doesn’t matter.
Hi Mike
Can you please with other issue?
On my site I would like automatically calculate shippping tax depends on shipping sum.
So I created js file and fire them with all admin scripts:
functions.php
add_action('admin_enqueue_scripts', 'admin_hooks');
function admin_hooks( $hook ) {
wp_enqueue_script( 'admin-hooks', get_template_directory_uri(). '/js/admin.hook.js' );
}
admin.hook.js
jQuery( "input.line_total" ).on('focus', function() {
console.log('ad');
});
But when I click save this code doesn’t work until I refresh page.
Hi Mike
Can you please with other issue?
On my site I would like automatically calculate shippping tax depends on shipping sum.
So I created js file and fire them with all admin scripts:
functions.php
add_action('admin_enqueue_scripts', 'admin_hooks');
function admin_hooks( $hook ) {
wp_enqueue_script( 'admin-hooks', get_template_directory_uri(). '/js/admin.hook.js' );
}
admin.hook.js
jQuery( "input.line_total" ).on('focus', function() {
console.log('ad');
});
But when I click save this code doesn’t work until I refresh page.
I suggest you look at the docs for jquery .on() – move the scope higher, since those elements will be removed/recreated.
jQuery( document ).on( 'focus', "input.line_total", function() { .....
Thank you Mike
That works.
Hi Mike
As I said I have to do some calculation on order page in wp-admin.
What the correcct way to get currency for current order?
I found some way when I getting currency code and set as JS variable
Then I can worj with this variable.
add_action( 'woocommerce_before_order_itemmeta', 'before_order_itemmeta', 10, 3 );
function before_order_itemmeta( $item_id, $item, $_product ){
global $woocommerce;
$curr = get_woocommerce_currency();
echo "<script type='text/javascript'>
currency_abbreviation = '".$curr."';
console.log(currency_abbreviation);
</script>";
}
But it works not good, did not found why yet.
Is it correct way?
You can get the current order currency using it:
$order = wc_get_order( $post_id );
$order->get_order_currency();