get_currency
This commit is contained in:
parent
3f93886cb9
commit
9181c107a8
|
@ -228,7 +228,7 @@ class WC_Admin_Assets {
|
|||
|
||||
if ( $post_id && in_array( get_post_type( $post_id ), wc_get_order_types( 'order-meta-boxes' ) ) ) {
|
||||
$order = wc_get_order( $post_id );
|
||||
$currency = $order->get_order_currency();
|
||||
$currency = $order->get_currency();
|
||||
}
|
||||
|
||||
$params = array(
|
||||
|
|
|
@ -53,10 +53,10 @@ $item_subtotal = ( isset( $item['line_subtotal'] ) ) ? esc_attr( wc_format_local
|
|||
<div class="view">
|
||||
<?php
|
||||
if ( isset( $item['line_total'] ) ) {
|
||||
echo wc_price( $order->get_item_total( $item, false, true ), array( 'currency' => $order->get_order_currency() ) );
|
||||
echo wc_price( $order->get_item_total( $item, false, true ), array( 'currency' => $order->get_currency() ) );
|
||||
|
||||
if ( isset( $item['line_subtotal'] ) && $item['line_subtotal'] != $item['line_total'] ) {
|
||||
echo '<span class="wc-order-item-discount">-' . wc_price( wc_format_decimal( $order->get_item_subtotal( $item, false, false ) - $order->get_item_total( $item, false, false ), '' ), array( 'currency' => $order->get_order_currency() ) ) . '</span>';
|
||||
echo '<span class="wc-order-item-discount">-' . wc_price( wc_format_decimal( $order->get_item_subtotal( $item, false, false ) - $order->get_item_total( $item, false, false ), '' ), array( 'currency' => $order->get_currency() ) ) . '</span>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -84,15 +84,15 @@ $item_subtotal = ( isset( $item['line_subtotal'] ) ) ? esc_attr( wc_format_local
|
|||
<div class="view">
|
||||
<?php
|
||||
if ( isset( $item['line_total'] ) ) {
|
||||
echo wc_price( $item['line_total'], array( 'currency' => $order->get_order_currency() ) );
|
||||
echo wc_price( $item['line_total'], array( 'currency' => $order->get_currency() ) );
|
||||
}
|
||||
|
||||
if ( isset( $item['line_subtotal'] ) && $item['line_subtotal'] !== $item['line_total'] ) {
|
||||
echo '<span class="wc-order-item-discount">-' . wc_price( wc_format_decimal( $item['line_subtotal'] - $item['line_total'], '' ), array( 'currency' => $order->get_order_currency() ) ) . '</span>';
|
||||
echo '<span class="wc-order-item-discount">-' . wc_price( wc_format_decimal( $item['line_subtotal'] - $item['line_total'], '' ), array( 'currency' => $order->get_currency() ) ) . '</span>';
|
||||
}
|
||||
|
||||
if ( $refunded = $order->get_total_refunded_for_item( $item_id ) ) {
|
||||
echo '<small class="refunded">' . wc_price( $refunded, array( 'currency' => $order->get_order_currency() ) ) . '</small>';
|
||||
echo '<small class="refunded">' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
@ -124,17 +124,17 @@ $item_subtotal = ( isset( $item['line_subtotal'] ) ) ? esc_attr( wc_format_local
|
|||
<div class="view">
|
||||
<?php
|
||||
if ( '' != $tax_item_total ) {
|
||||
echo wc_price( wc_round_tax_total( $tax_item_total ), array( 'currency' => $order->get_order_currency() ) );
|
||||
echo wc_price( wc_round_tax_total( $tax_item_total ), array( 'currency' => $order->get_currency() ) );
|
||||
} else {
|
||||
echo '–';
|
||||
}
|
||||
|
||||
if ( isset( $item['line_subtotal'] ) && $item['line_subtotal'] !== $item['line_total'] ) {
|
||||
echo '<span class="wc-order-item-discount">-' . wc_price( wc_round_tax_total( $tax_item_subtotal - $tax_item_total ), array( 'currency' => $order->get_order_currency() ) ) . '</span>';
|
||||
echo '<span class="wc-order-item-discount">-' . wc_price( wc_round_tax_total( $tax_item_subtotal - $tax_item_total ), array( 'currency' => $order->get_currency() ) ) . '</span>';
|
||||
}
|
||||
|
||||
if ( $refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id ) ) {
|
||||
echo '<small class="refunded">' . wc_price( $refunded, array( 'currency' => $order->get_order_currency() ) ) . '</small>';
|
||||
echo '<small class="refunded">' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
|
|
@ -135,7 +135,7 @@ if ( wc_tax_enabled() ) {
|
|||
|
||||
$link = $post_id ? add_query_arg( array( 'post' => $post_id, 'action' => 'edit' ), admin_url( 'post.php' ) ) : add_query_arg( array( 's' => $item['name'], 'post_status' => 'all', 'post_type' => 'shop_coupon' ), admin_url( 'edit.php' ) );
|
||||
|
||||
echo '<li class="code"><a href="' . esc_url( $link ) . '" class="tips" data-tip="' . esc_attr( wc_price( $item['discount_amount'], array( 'currency' => $order->get_order_currency() ) ) ) . '"><span>' . esc_html( $item['name'] ). '</span></a></li>';
|
||||
echo '<li class="code"><a href="' . esc_url( $link ) . '" class="tips" data-tip="' . esc_attr( wc_price( $item['discount_amount'], array( 'currency' => $order->get_currency() ) ) ) . '"><span>' . esc_html( $item['name'] ). '</span></a></li>';
|
||||
}
|
||||
?></ul>
|
||||
</div>
|
||||
|
@ -147,7 +147,7 @@ if ( wc_tax_enabled() ) {
|
|||
<td class="label"><?php echo wc_help_tip( __( 'This is the total discount. Discounts are defined per line item.', 'woocommerce' ) ); ?> <?php _e( 'Discount', 'woocommerce' ); ?>:</td>
|
||||
<td width="1%"></td>
|
||||
<td class="total">
|
||||
<?php echo wc_price( $order->get_total_discount(), array( 'currency' => $order->get_order_currency() ) ); ?>
|
||||
<?php echo wc_price( $order->get_total_discount(), array( 'currency' => $order->get_currency() ) ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
@ -158,9 +158,9 @@ if ( wc_tax_enabled() ) {
|
|||
<td width="1%"></td>
|
||||
<td class="total"><?php
|
||||
if ( ( $refunded = $order->get_total_shipping_refunded() ) > 0 ) {
|
||||
echo '<del>' . strip_tags( wc_price( $order->get_total_shipping(), array( 'currency' => $order->get_order_currency() ) ) ) . '</del> <ins>' . wc_price( $order->get_total_shipping() - $refunded, array( 'currency' => $order->get_order_currency() ) ) . '</ins>';
|
||||
echo '<del>' . strip_tags( wc_price( $order->get_total_shipping(), array( 'currency' => $order->get_currency() ) ) ) . '</del> <ins>' . wc_price( $order->get_total_shipping() - $refunded, array( 'currency' => $order->get_currency() ) ) . '</ins>';
|
||||
} else {
|
||||
echo wc_price( $order->get_total_shipping(), array( 'currency' => $order->get_order_currency() ) );
|
||||
echo wc_price( $order->get_total_shipping(), array( 'currency' => $order->get_currency() ) );
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
|
@ -174,7 +174,7 @@ if ( wc_tax_enabled() ) {
|
|||
<td width="1%"></td>
|
||||
<td class="total"><?php
|
||||
if ( ( $refunded = $order->get_total_tax_refunded_by_rate_id( $tax->rate_id ) ) > 0 ) {
|
||||
echo '<del>' . strip_tags( $tax->formatted_amount ) . '</del> <ins>' . wc_price( WC_Tax::round( $tax->amount, wc_get_price_decimals() ) - WC_Tax::round( $refunded, wc_get_price_decimals() ), array( 'currency' => $order->get_order_currency() ) ) . '</ins>';
|
||||
echo '<del>' . strip_tags( $tax->formatted_amount ) . '</del> <ins>' . wc_price( WC_Tax::round( $tax->amount, wc_get_price_decimals() ) - WC_Tax::round( $refunded, wc_get_price_decimals() ), array( 'currency' => $order->get_currency() ) ) . '</ins>';
|
||||
} else {
|
||||
echo $tax->formatted_amount;
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ if ( wc_tax_enabled() ) {
|
|||
<tr>
|
||||
<td class="label refunded-total"><?php _e( 'Refunded', 'woocommerce' ); ?>:</td>
|
||||
<td width="1%"></td>
|
||||
<td class="total refunded-total">-<?php echo wc_price( $order->get_total_refunded(), array( 'currency' => $order->get_order_currency() ) ); ?></td>
|
||||
<td class="total refunded-total">-<?php echo wc_price( $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); ?></td>
|
||||
</tr>
|
||||
|
||||
<?php do_action( 'woocommerce_admin_order_totals_after_refunded', $order->id ); ?>
|
||||
|
@ -259,11 +259,11 @@ if ( wc_tax_enabled() ) {
|
|||
</tr>
|
||||
<tr>
|
||||
<td class="label"><?php _e( 'Amount already refunded', 'woocommerce' ); ?>:</td>
|
||||
<td class="total">-<?php echo wc_price( $order->get_total_refunded(), array( 'currency' => $order->get_order_currency() ) ); ?></td>
|
||||
<td class="total">-<?php echo wc_price( $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label"><?php _e( 'Total available to refund', 'woocommerce' ); ?>:</td>
|
||||
<td class="total"><?php echo wc_price( $order->get_total() - $order->get_total_refunded(), array( 'currency' => $order->get_order_currency() ) ); ?></td>
|
||||
<td class="total"><?php echo wc_price( $order->get_total() - $order->get_total_refunded(), array( 'currency' => $order->get_currency() ) ); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label"><label for="refund_amount"><?php _e( 'Refund amount', 'woocommerce' ); ?>:</label></td>
|
||||
|
@ -283,7 +283,7 @@ if ( wc_tax_enabled() ) {
|
|||
<div class="clear"></div>
|
||||
<div class="refund-actions">
|
||||
<?php
|
||||
$refund_amount = '<span class="wc-order-refund-amount">' . wc_price( 0, array( 'currency' => $order->get_order_currency() ) ) . '</span>';
|
||||
$refund_amount = '<span class="wc-order-refund-amount">' . wc_price( 0, array( 'currency' => $order->get_currency() ) ) . '</span>';
|
||||
$gateway_supports_refunds = false !== $payment_gateway && $payment_gateway->supports( 'refunds' );
|
||||
$gateway_name = false !== $payment_gateway ? ( ! empty( $payment_gateway->method_title ) ? $payment_gateway->method_title : $payment_gateway->get_title() ) : __( 'Payment Gateway', 'woocommerce' );
|
||||
?>
|
||||
|
|
|
@ -60,10 +60,10 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
<td class="line_cost" width="1%">
|
||||
<div class="view">
|
||||
<?php
|
||||
echo ( isset( $item['cost'] ) ) ? wc_price( wc_round_tax_total( $item['cost'] ), array( 'currency' => $order->get_order_currency() ) ) : '';
|
||||
echo ( isset( $item['cost'] ) ) ? wc_price( wc_round_tax_total( $item['cost'] ), array( 'currency' => $order->get_currency() ) ) : '';
|
||||
|
||||
if ( $refunded = $order->get_total_refunded_for_item( $item_id, 'shipping' ) ) {
|
||||
echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_order_currency() ) ) . '</small>';
|
||||
echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
@ -87,10 +87,10 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
<td class="line_tax" width="1%">
|
||||
<div class="view">
|
||||
<?php
|
||||
echo ( '' != $tax_item_total ) ? wc_price( wc_round_tax_total( $tax_item_total ), array( 'currency' => $order->get_order_currency() ) ) : '–';
|
||||
echo ( '' != $tax_item_total ) ? wc_price( wc_round_tax_total( $tax_item_total ), array( 'currency' => $order->get_currency() ) ) : '–';
|
||||
|
||||
if ( $refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id, 'shipping' ) ) {
|
||||
echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_order_currency() ) ) . '</small>';
|
||||
echo '<small class="refunded">-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</small>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
|
|
@ -130,7 +130,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
|
|||
'status' => $order->get_status(),
|
||||
'order_key' => $order->order_key,
|
||||
'number' => $order->get_order_number(),
|
||||
'currency' => $order->get_order_currency(),
|
||||
'currency' => $order->get_currency(),
|
||||
'version' => $order->order_version,
|
||||
'prices_include_tax' => $order->prices_include_tax,
|
||||
'date_created' => wc_rest_prepare_date_response( $post->post_date_gmt ),
|
||||
|
|
|
@ -160,7 +160,7 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
'updated_at' => $this->server->format_datetime( $order_post->post_modified_gmt ),
|
||||
'completed_at' => $this->server->format_datetime( $order->completed_date, true ),
|
||||
'status' => $order->get_status(),
|
||||
'currency' => $order->get_order_currency(),
|
||||
'currency' => $order->get_currency(),
|
||||
'total' => wc_format_decimal( $order->get_total(), $dp ),
|
||||
'subtotal' => wc_format_decimal( $order->get_subtotal(), $dp ),
|
||||
'total_line_items_quantity' => $order->get_item_count(),
|
||||
|
|
|
@ -166,7 +166,7 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
'updated_at' => $this->server->format_datetime( $order_post->post_modified_gmt ),
|
||||
'completed_at' => $this->server->format_datetime( $order->completed_date, true ),
|
||||
'status' => $order->get_status(),
|
||||
'currency' => $order->get_order_currency(),
|
||||
'currency' => $order->get_currency(),
|
||||
'total' => wc_format_decimal( $order->get_total(), $dp ),
|
||||
'subtotal' => wc_format_decimal( $order->get_subtotal(), $dp ),
|
||||
'total_line_items_quantity' => $order->get_item_count(),
|
||||
|
|
|
@ -318,7 +318,7 @@ class WC_Emails {
|
|||
'@type' => 'Offer',
|
||||
'itemOffered' => $item_offered,
|
||||
'price' => $order->get_line_subtotal( $item ),
|
||||
'priceCurrency' => $order->get_order_currency(),
|
||||
'priceCurrency' => $order->get_currency(),
|
||||
'eligibleQuantity' => (object) array(
|
||||
'@type' => 'QuantitativeValue',
|
||||
'value' => apply_filters( 'woocommerce_email_order_item_quantity', $item['qty'], $item )
|
||||
|
@ -337,7 +337,7 @@ class WC_Emails {
|
|||
'name' => get_bloginfo( 'name' ),
|
||||
),
|
||||
'orderNumber' => strval( $order->get_order_number() ),
|
||||
'priceCurrency' => $order->get_order_currency(),
|
||||
'priceCurrency' => $order->get_currency(),
|
||||
'price' => $order->get_total(),
|
||||
'acceptedOffer' => $accepted_offers,
|
||||
'url' => $order->get_view_order_url(),
|
||||
|
|
|
@ -635,7 +635,7 @@ class WC_CLI_Order extends WC_CLI_Command {
|
|||
'updated_at' => $this->format_datetime( $order_post->post_modified_gmt ),
|
||||
'completed_at' => $this->format_datetime( $order->completed_date, true ),
|
||||
'status' => $order->get_status(),
|
||||
'currency' => $order->get_order_currency(),
|
||||
'currency' => $order->get_currency(),
|
||||
'total' => wc_format_decimal( $order->get_total(), $dp ),
|
||||
'subtotal' => wc_format_decimal( $order->get_subtotal(), $dp ),
|
||||
'total_line_items_quantity' => $order->get_item_count(),
|
||||
|
|
|
@ -38,7 +38,7 @@ class WC_Gateway_Paypal_API_Handler {
|
|||
'METHOD' => 'DoCapture',
|
||||
'AUTHORIZATIONID' => $order->get_transaction_id(),
|
||||
'AMT' => number_format( is_null( $amount ) ? $order->get_total() : $amount, 2, '.', '' ),
|
||||
'CURRENCYCODE' => $order->get_order_currency(),
|
||||
'CURRENCYCODE' => $order->get_currency(),
|
||||
'COMPLETETYPE' => 'Complete',
|
||||
);
|
||||
return apply_filters( 'woocommerce_paypal_capture_request', $request, $order, $amount );
|
||||
|
@ -64,7 +64,7 @@ class WC_Gateway_Paypal_API_Handler {
|
|||
);
|
||||
if ( ! is_null( $amount ) ) {
|
||||
$request['AMT'] = number_format( $amount, 2, '.', '' );
|
||||
$request['CURRENCYCODE'] = $order->get_order_currency();
|
||||
$request['CURRENCYCODE'] = $order->get_currency();
|
||||
$request['REFUNDTYPE'] = 'Partial';
|
||||
}
|
||||
return apply_filters( 'woocommerce_paypal_refund_request', $request, $order, $amount, $reason );
|
||||
|
|
|
@ -126,8 +126,8 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
|
|||
* @param string $currency
|
||||
*/
|
||||
protected function validate_currency( $order, $currency ) {
|
||||
if ( $order->get_order_currency() != $currency ) {
|
||||
WC_Gateway_Paypal::log( 'Payment error: Currencies do not match (sent "' . $order->get_order_currency() . '" | returned "' . $currency . '")' );
|
||||
if ( $order->get_currency() != $currency ) {
|
||||
WC_Gateway_Paypal::log( 'Payment error: Currencies do not match (sent "' . $order->get_currency() . '" | returned "' . $currency . '")' );
|
||||
|
||||
// Put this order on-hold for manual checking.
|
||||
$order->update_status( 'on-hold', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'woocommerce' ), $currency ) );
|
||||
|
|
|
@ -356,7 +356,7 @@ class WC_Gateway_Paypal_Request {
|
|||
protected function round( $price, $order ) {
|
||||
$precision = 2;
|
||||
|
||||
if ( ! $this->currency_has_decimals( $order->get_order_currency() ) ) {
|
||||
if ( ! $this->currency_has_decimals( $order->get_currency() ) ) {
|
||||
$precision = 0;
|
||||
}
|
||||
|
||||
|
@ -372,7 +372,7 @@ class WC_Gateway_Paypal_Request {
|
|||
protected function number_format( $price, $order ) {
|
||||
$decimals = 2;
|
||||
|
||||
if ( ! $this->currency_has_decimals( $order->get_order_currency() ) ) {
|
||||
if ( ! $this->currency_has_decimals( $order->get_currency() ) ) {
|
||||
$decimals = 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue