Created
February 26, 2020 19:47
-
-
Save Spreeuw/e3b5d78fbea0c225b64b6d6f3fcea879 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('woocommerce_order_item_add_action_buttons','wpo_bulk_edit_line_item_prices',10,1); | |
function wpo_bulk_edit_line_item_prices($order) { | |
?> | |
<input type="text" class="bulk-multiply-items-multiplier" size="5" style="float:left;"><button type="button" class="button bulk-multiply-items">multiply prices</button> | |
<script> | |
jQuery(function($) { | |
$('.button.bulk-multiply-items').click(function(event){ | |
event.preventDefault(); | |
var multiplier = parseFloat( $('.bulk-multiply-items-multiplier').val() ); | |
$('.edit-order-item').each(function(){ | |
var type = $(this).closest('tbody').attr('id'); | |
if (type == 'order_line_items' || type == 'order_shipping_line_items') { | |
$(this).trigger('click'); // enable edit mode | |
if (type == 'order_line_items') { | |
$line_subtotal = $(this).closest('tr').find('td.line_cost input.line_subtotal'); | |
$line_subtotal.val(parseFloat($line_subtotal.val())*multiplier); | |
} | |
$line_total = $(this).closest('tr').find('td.line_cost input.line_total'); | |
$line_total.val(parseFloat($line_total.val())*multiplier); | |
} | |
}); | |
}); | |
}); | |
</script> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment