Fixing currency position in reports

This commit is contained in:
Nicola Mustone 2014-09-19 09:23:58 +02:00
parent f3aaf04ff6
commit 8a7ed9a053
5 changed files with 26 additions and 6 deletions

View File

@ -505,6 +505,26 @@ class WC_Admin_Report {
}
}
/**
* Return currency tooltip JS based on WooCommerce currency position settings.
*
* @return string
*/
public function get_currency_tooltip() {
switch( get_option( 'woocommerce_currency_pos' ) ) {
case 'left':
$currency_tooltip = 'prepend_tooltip: "' . get_woocommerce_currency_symbol() . '"'; break;
case 'left_space':
$currency_tooltip = 'prepend_tooltip: "' . get_woocommerce_currency_symbol() . ' "'; break;
case 'right':
$currency_tooltip = 'append_tooltip: "' . get_woocommerce_currency_symbol() . '"'; break;
case 'right_space':
$currency_tooltip = 'append_tooltip: " ' . get_woocommerce_currency_symbol() . '"'; break;
}
return $currency_tooltip;
}
/**
* Get the main chart
*

View File

@ -434,7 +434,7 @@ class WC_Report_Coupon_Usage extends WC_Admin_Report {
points: { show: true, radius: 5, lineWidth: 3, fillColor: '#fff', fill: true },
lines: { show: true, lineWidth: 4, fill: false },
shadowSize: 0,
prepend_tooltip: "<?php echo get_woocommerce_currency_symbol(); ?>"
<?php echo $this->get_currency_tooltip(); ?>
}
];

View File

@ -330,7 +330,7 @@ class WC_Report_Sales_By_Category extends WC_Admin_Report {
data: jQuery.parseJSON( "' . json_encode( $series ) . '" ),
color: "' . $color . '",
bars: { fillColor: "' . $color . '", fill: true, show: true, lineWidth: 1, align: "center", barWidth: ' . $width * 0.75 . ', stack: false },
prepend_tooltip: "' . get_woocommerce_currency_symbol() . '",
' . $this->get_currency_tooltip() . '",
enable_tooltip: true,
prepend_label: true
},';

View File

@ -352,7 +352,7 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
points: { show: true, radius: 5, lineWidth: 3, fillColor: '#fff', fill: true },
lines: { show: true, lineWidth: 4, fill: false },
shadowSize: 0,
prepend_tooltip: "<?php echo get_woocommerce_currency_symbol(); ?>"
<?php echo $this->get_currency_tooltip(); ?>
},
{
label: "<?php echo esc_js( __( 'Shipping amount', 'woocommerce' ) ) ?>",
@ -362,7 +362,7 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
points: { show: true, radius: 5, lineWidth: 3, fillColor: '#fff', fill: true },
lines: { show: true, lineWidth: 4, fill: false },
shadowSize: 0,
prepend_tooltip: "<?php echo get_woocommerce_currency_symbol(); ?>"
<?php echo $this->get_currency_tooltip(); ?>
},
{
label: "<?php echo esc_js( __( 'Sales amount', 'woocommerce' ) ) ?>",
@ -372,7 +372,7 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
points: { show: true, radius: 5, lineWidth: 3, fillColor: '#fff', fill: true },
lines: { show: true, lineWidth: 4, fill: false },
shadowSize: 0,
prepend_tooltip: "<?php echo get_woocommerce_currency_symbol(); ?>"
<?php echo $this->get_currency_tooltip(); ?>
}
];

View File

@ -458,7 +458,7 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
points: { show: true, radius: 5, lineWidth: 3, fillColor: '#fff', fill: true },
lines: { show: true, lineWidth: 4, fill: false },
shadowSize: 0,
prepend_tooltip: "<?php echo get_woocommerce_currency_symbol(); ?>"
<?php echo $this->get_currency_tooltip(); ?>
}
];