Merge branch 'credit-notes' of https://github.com/woothemes/woocommerce into credit-notes
Conflicts: assets/js/admin/meta-boxes-order.min.js
This commit is contained in:
commit
249f18f70d
|
@ -629,7 +629,9 @@ jQuery( function ( $ ) {
|
|||
// Refund actions
|
||||
$( 'body' )
|
||||
.on( 'change', '.wc-order-refund-items #refund_amount', function () {
|
||||
$( 'button .wc-order-refund-amount .amount' ).text( accounting.formatMoney( $( this ).val(), {
|
||||
var total = accounting.unformat( $( this ).val(), woocommerce_admin.mon_decimal_point );
|
||||
|
||||
$( 'button .wc-order-refund-amount .amount' ).text( accounting.formatMoney( total, {
|
||||
symbol: woocommerce_admin_meta_boxes.currency_format_symbol,
|
||||
decimal: woocommerce_admin_meta_boxes.currency_format_decimal_sep,
|
||||
thousand: woocommerce_admin_meta_boxes.currency_format_thousand_sep,
|
||||
|
@ -819,27 +821,36 @@ jQuery( function ( $ ) {
|
|||
return;
|
||||
}
|
||||
|
||||
addOrderItemsLoading();
|
||||
var rate_id = $( '#add-order-tax' ).val();
|
||||
var rates = $( '.order-tax-id' ).map( function () {
|
||||
return $( this ).val();
|
||||
}).get().join( ', ' );
|
||||
|
||||
var data = {
|
||||
action: 'woocommerce_add_order_tax',
|
||||
rate_id: $( '#add-order-tax' ).val(),
|
||||
order_id: woocommerce_admin_meta_boxes.post_id,
|
||||
security: woocommerce_admin_meta_boxes.order_item_nonce
|
||||
};
|
||||
// Test if already exists
|
||||
if ( -1 === $.inArray( rate_id, rates ) ) {
|
||||
addOrderItemsLoading();
|
||||
|
||||
$.ajax({
|
||||
url: woocommerce_admin_meta_boxes.ajax_url,
|
||||
data: data,
|
||||
type: 'POST',
|
||||
success: function( response ) {
|
||||
$( '#woocommerce-order-items .inside' ).empty();
|
||||
$( '#woocommerce-order-items .inside' ).append( response );
|
||||
runTipTip();
|
||||
removeOrderItemsLoading();
|
||||
}
|
||||
});
|
||||
var data = {
|
||||
action: 'woocommerce_add_order_tax',
|
||||
rate_id: rate_id,
|
||||
order_id: woocommerce_admin_meta_boxes.post_id,
|
||||
security: woocommerce_admin_meta_boxes.order_item_nonce
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: woocommerce_admin_meta_boxes.ajax_url,
|
||||
data: data,
|
||||
type: 'POST',
|
||||
success: function( response ) {
|
||||
$( '#woocommerce-order-items .inside' ).empty();
|
||||
$( '#woocommerce-order-items .inside' ).append( response );
|
||||
runTipTip();
|
||||
removeOrderItemsLoading();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
window.alert( woocommerce_admin_meta_boxes.i18n_tax_rate_already_exists );
|
||||
}
|
||||
});
|
||||
|
||||
$('span.inline_total').closest('.totals_group').find('input').change();
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -213,6 +213,7 @@ class WC_Admin_Assets {
|
|||
'default_attribute_variation' => apply_filters( 'default_attribute_variation', false ),
|
||||
'i18n_download_permission_fail' => __( 'Could not grant access - the user may already have permission for this file or billing email is not set. Ensure the billing email is set, and the order has been saved.', 'woocommerce' ),
|
||||
'i18n_permission_revoke' => __( 'Are you sure you want to revoke access to this download?', 'woocommerce' ),
|
||||
'i18n_tax_rate_already_exists' => __( 'You cannot add the same tax rate twice!', 'woocommerce' ),
|
||||
);
|
||||
|
||||
wp_localize_script( 'wc-admin-meta-boxes', 'woocommerce_admin_meta_boxes', $params );
|
||||
|
|
|
@ -16,6 +16,9 @@ if ( 'yes' == get_option( 'woocommerce_calc_taxes' ) ) {
|
|||
}
|
||||
}
|
||||
|
||||
// Get the payment gateway
|
||||
$payment_gateway = wc_get_payment_gateway_by_order( $order );
|
||||
|
||||
?>
|
||||
<div class="woocommerce_order_items_wrapper wc-order-items-editable">
|
||||
<table cellpadding="0" cellspacing="0" class="woocommerce_order_items">
|
||||
|
@ -41,7 +44,7 @@ if ( 'yes' == get_option( 'woocommerce_calc_taxes' ) ) {
|
|||
echo esc_attr( $tax_item['name'] . ' (' . $tax_class_name . ')' );
|
||||
?>">
|
||||
<?php echo esc_attr( $column_label ); ?>
|
||||
<input type="hidden" name="order_taxes[<?php echo $tax_id; ?>]" value="<?php echo esc_attr( $tax_item['rate_id'] ); ?>">
|
||||
<input type="hidden" class="order-tax-id" name="order_taxes[<?php echo $tax_id; ?>]" value="<?php echo esc_attr( $tax_item['rate_id'] ); ?>">
|
||||
<a class="delete-order-tax" href="#" data-rate_id="<?php echo $tax_id; ?>"></a>
|
||||
</th>
|
||||
<?php
|
||||
|
@ -60,7 +63,7 @@ if ( 'yes' == get_option( 'woocommerce_calc_taxes' ) ) {
|
|||
foreach ( $order_items as $item_id => $item ) {
|
||||
$_product = $order->get_product_from_item( $item );
|
||||
$item_meta = $order->get_item_meta( $item_id );
|
||||
|
||||
|
||||
include( 'html-order-item.php' );
|
||||
|
||||
do_action( 'woocommerce_order_item_' . $item['type'] . '_html', $item_id, $item );
|
||||
|
@ -201,7 +204,9 @@ if ( 'yes' == get_option( 'woocommerce_calc_taxes' ) ) {
|
|||
</table>
|
||||
<div class="clear"></div>
|
||||
<div class="refund-actions">
|
||||
<?php if ( false !== $payment_gateway && $payment_gateway->supports( 'refunds' ) ) : ?>
|
||||
<button type="button" class="button button-primary do-api-refund"><?php printf( _x( 'Refund %s via %s', 'Refund $amount', 'woocommerce' ), '<span class="wc-order-refund-amount">' . wc_price( 0 ) . '</span>', $order->payment_method_title ); ?></button>
|
||||
<?php endif; ?>
|
||||
<button type="button" class="button button-primary do-manual-refund"><?php _e( 'Refund manually', 'woocommerce' ); ?></button>
|
||||
<button type="button" class="button cancel-action"><?php _e( 'Cancel', 'woocommerce' ); ?></button>
|
||||
<div class="clear"></div>
|
||||
|
|
|
@ -585,3 +585,28 @@ function wc_get_tax_class_by_tax_id( $tax_id ) {
|
|||
|
||||
return wc_clean( $tax_class );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get payment gateway class by order data.
|
||||
*
|
||||
* @since 2.2
|
||||
* @param int|WC_Order $order
|
||||
* @return WC_Payment_Gateway|bool
|
||||
*/
|
||||
function wc_get_payment_gateway_by_order( $order ) {
|
||||
if ( WC()->payment_gateways() ) {
|
||||
$payment_gateways = WC()->payment_gateways->payment_gateways();
|
||||
} else {
|
||||
$payment_gateways = array();
|
||||
}
|
||||
|
||||
if ( is_object( $order ) ) {
|
||||
$payment_method = $order->payment_method;
|
||||
} else {
|
||||
$order_id = absint( $order );
|
||||
$order = new WC_Order( $order_id );
|
||||
$payment_method = $order->payment_method;
|
||||
}
|
||||
|
||||
return isset( $payment_gateways[ $order->payment_method ] ) ? $payment_gateways[ $order->payment_method ] : false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue