Remove 'order' discounts from classes

This commit is contained in:
Mike Jolley 2014-11-25 11:05:14 +00:00
parent 549d7ab2c0
commit 4a8c541fbf
8 changed files with 21 additions and 39 deletions

View File

@ -573,9 +573,6 @@ jQuery( function ( $ ) {
var line_totals = 0;
var tax = 0;
var shipping = 0;
var order_discount = $( '#_order_discount' ).val() || '0';
order_discount = accounting.unformat( order_discount.replace( ',', '.' ) );
$( '.woocommerce_order_items tr.shipping input.line_total' ).each(function() {
var cost = $( this ).val() || '0';
@ -601,7 +598,7 @@ jQuery( function ( $ ) {
// Set Total
$( '#_order_total' )
.val( accounting.formatNumber( line_totals + tax + shipping - order_discount, woocommerce_admin_meta_boxes.currency_format_num_decimals, '', woocommerce_admin.mon_decimal_point ) )
.val( accounting.formatNumber( line_totals + tax + shipping, woocommerce_admin_meta_boxes.currency_format_num_decimals, '', woocommerce_admin.mon_decimal_point ) )
.change();
$( 'button.save-action' ).click();

File diff suppressed because one or more lines are too long

View File

@ -482,7 +482,7 @@ abstract class WC_Abstract_Order {
*/
public function set_total( $amount, $total_type = 'total' ) {
if ( ! in_array( $total_type, array( 'shipping', 'order_discount', 'tax', 'shipping_tax', 'total', 'cart_discount' ) ) ) {
if ( ! in_array( $total_type, array( 'shipping', 'tax', 'shipping_tax', 'total', 'cart_discount' ) ) ) {
return false;
}
@ -491,7 +491,6 @@ abstract class WC_Abstract_Order {
$key = '_order_total';
$amount = wc_format_decimal( $amount, get_option( 'woocommerce_price_num_decimals' ) );
break;
case 'order_discount' :
case 'cart_discount' :
$key = '_' . $total_type;
$amount = wc_format_decimal( $amount );
@ -722,7 +721,7 @@ abstract class WC_Abstract_Order {
$this->set_total( $cart_subtotal - $cart_total, 'cart_discount' );
$grand_total = round( $cart_total + $fee_total + $this->get_total_shipping() - $this->get_order_discount() + $this->get_cart_tax() + $this->get_shipping_tax(), absint( get_option( 'woocommerce_price_num_decimals' ) ) );
$grand_total = round( $cart_total + $fee_total + $this->get_total_shipping() + $this->get_cart_tax() + $this->get_shipping_tax(), absint( get_option( 'woocommerce_price_num_decimals' ) ) );
$this->set_total( $grand_total, 'total' );
@ -1239,9 +1238,11 @@ abstract class WC_Abstract_Order {
/**
* Gets the total (order) discount amount - these are applied after tax.
*
* @deprecated order (after tax) discounts removed in 2.3.0
* @return float
*/
public function get_order_discount() {
_deprecated_function( 'get_order_discount', '2.3' );
return apply_filters( 'woocommerce_order_amount_order_discount', (double) $this->order_discount, $this );
}
@ -1251,7 +1252,7 @@ abstract class WC_Abstract_Order {
* @return float
*/
public function get_total_discount() {
return apply_filters( 'woocommerce_order_amount_total_discount', $this->get_cart_discount() + $this->get_order_discount(), $this );
return apply_filters( 'woocommerce_order_amount_total_discount', $this->get_cart_discount(), $this );
}
/**
@ -1649,9 +1650,11 @@ abstract class WC_Abstract_Order {
/**
* Get cart discount (formatted).
*
* @deprecated order (after tax) discounts removed in 2.3.0
* @return string
*/
public function get_order_discount_to_display() {
_deprecated_function( 'get_order_discount_to_display', '2.3' );
return apply_filters( 'woocommerce_order_discount_to_display', wc_price( $this->get_order_discount(), array( 'currency' => $this->get_order_currency() ) ), $this );
}
@ -1756,13 +1759,6 @@ abstract class WC_Abstract_Order {
}
}
if ( $this->get_order_discount() > 0 ) {
$total_rows['order_discount'] = array(
'label' => __( 'Order Discount:', 'woocommerce' ),
'value' => '-' . $this->get_order_discount_to_display()
);
}
if ( $this->get_total() > 0 ) {
$total_rows['payment_method'] = array(
'label' => __( 'Payment Method:', 'woocommerce' ),

View File

@ -136,6 +136,16 @@ if ( wc_tax_enabled() ) {
}
?>
<table class="wc-order-totals">
<tr>
<td class="label"><?php _e( 'Discount', 'woocommerce' ); ?> <span class="tips" data-tip="<?php _e( 'This is the total discount. Discounts are defined per line item.', 'woocommerce' ); ?>">[?]</span>:</td>
<td class="total">
<?php echo wc_price( $order->get_total_discount(), array( 'currency' => $order->get_order_currency() ) ); ?>
</td>
<td width="1%"></td>
</tr>
<?php do_action( 'woocommerce_admin_order_totals_after_discount', $order->id ); ?>
<tr>
<td class="label"><?php _e( 'Shipping', 'woocommerce' ); ?> <span class="tips" data-tip="<?php _e( 'This is the shipping and handling total costs for the order.', 'woocommerce' ); ?>">[?]</span>:</td>
<td class="total"><?php echo wc_price( $order->get_total_shipping(), array( 'currency' => $order->get_order_currency() ) ); ?></td>
@ -156,20 +166,6 @@ if ( wc_tax_enabled() ) {
<?php do_action( 'woocommerce_admin_order_totals_after_tax', $order->id ); ?>
<tr>
<td class="label"><?php _e( 'Order Discount', 'woocommerce' ); ?> <span class="tips" data-tip="<?php _e( 'This is the total discount applied after tax.', 'woocommerce' ); ?>">[?]</span>:</td>
<td class="total">
<div class="view"><?php echo wc_price( $order->get_total_discount(), array( 'currency' => $order->get_order_currency() ) ); ?></div>
<div class="edit" style="display: none;">
<input type="text" class="wc_input_price" id="_order_discount" name="_order_discount" placeholder="<?php echo wc_format_localized_price( 0 ); ?>" value="<?php echo ( isset( $data['_order_discount'][0] ) ) ? esc_attr( wc_format_localized_price( $data['_order_discount'][0] ) ) : ''; ?>" />
<div class="clear"></div>
</div>
</td>
<td><?php if ( $order->is_editable() ) : ?><div class="wc-order-edit-line-item-actions"><a class="edit-order-item" href="#"></a></div><?php endif; ?></td>
</tr>
<?php do_action( 'woocommerce_admin_order_totals_after_discount', $order->id ); ?>
<tr>
<td class="label"><?php _e( 'Order Total', 'woocommerce' ); ?>:</td>
<td class="total">

View File

@ -325,7 +325,6 @@ function wc_save_order_items( $order_id, $items ) {
update_post_meta( $order_id, '_cart_discount', $subtotal - $total );
// Update totals
update_post_meta( $order_id, '_order_discount', wc_format_decimal( $items['_order_discount'] ) );
update_post_meta( $order_id, '_order_total', wc_format_decimal( $items['_order_total'] ) );
// Update tax

View File

@ -158,7 +158,6 @@ class WC_API_Orders extends WC_API_Resource {
'shipping_tax' => wc_format_decimal( $order->get_shipping_tax(), 2 ),
'total_discount' => wc_format_decimal( $order->get_total_discount(), 2 ),
'cart_discount' => wc_format_decimal( $order->get_cart_discount(), 2 ),
'order_discount' => wc_format_decimal( $order->get_order_discount(), 2 ),
'shipping_methods' => $order->get_shipping_method(),
'payment_details' => array(
'method_id' => $order->payment_method,

View File

@ -289,7 +289,6 @@ class WC_Checkout {
$order->set_address( $shipping_address, 'shipping' );
$order->set_payment_method( $this->payment_method );
$order->set_total( WC()->cart->shipping_total, 'shipping' );
$order->set_total( WC()->cart->get_order_discount_total(), 'order_discount' );
$order->set_total( WC()->cart->get_cart_discount_total(), 'cart_discount' );
$order->set_total( WC()->cart->tax_total, 'tax' );
$order->set_total( WC()->cart->shipping_tax_total, 'shipping_tax' );

View File

@ -157,7 +157,7 @@ class WC_Gateway_Paypal_Request {
/**
* Try passing a line item per product if supported
*/
if ( ( ! wc_tax_enabled() || ! wc_prices_include_tax() ) && ! $order->get_order_discount() && $this->prepare_line_items( $order ) ) {
if ( ( ! wc_tax_enabled() || ! wc_prices_include_tax() ) && $this->prepare_line_items( $order ) ) {
$line_item_args = $this->get_line_items();
$line_item_args['tax_cart'] = $order->get_total_tax();
@ -175,14 +175,10 @@ class WC_Gateway_Paypal_Request {
$this->delete_line_items();
$this->add_line_item( $this->get_order_item_names( $order ), 1, number_format( $order->get_total() - round( $order->get_total_shipping() + $order->get_shipping_tax(), 2 ) + $order->get_order_discount(), 2, '.', '' ), $order->get_order_number() );
$this->add_line_item( $this->get_order_item_names( $order ), 1, number_format( $order->get_total() - round( $order->get_total_shipping() + $order->get_shipping_tax(), 2 ), 2, '.', '' ), $order->get_order_number() );
$this->add_line_item( sprintf( __( 'Shipping via %s', 'woocommerce' ), ucwords( $order->get_shipping_method() ) ), 1, number_format( $order->get_total_shipping() + $order->get_shipping_tax(), 2, '.', '' ) );
$line_item_args = $this->get_line_items();
if ( $order->get_order_discount() ) {
$line_item_args['discount_amount_cart'] = $order->get_order_discount();
}
}
return $line_item_args;