diff --git a/public_html/wp-content/plugins/camptix/camptix.php b/public_html/wp-content/plugins/camptix/camptix.php
index 4182556df..6755e433d 100644
--- a/public_html/wp-content/plugins/camptix/camptix.php
+++ b/public_html/wp-content/plugins/camptix/camptix.php
@@ -64,6 +64,7 @@ function __construct() {
do_action( 'camptix_pre_init' );
require_once( plugin_dir_path( __FILE__ ) . 'inc/class-camptix-currencies.php' );
+ require_once( plugin_dir_path( __FILE__ ) . 'utility.php' );
require( dirname( __FILE__ ) . '/inc/class-camptix-addon.php' );
require( dirname( __FILE__ ) . '/inc/class-camptix-payment-method.php' );
@@ -610,7 +611,7 @@ function manage_columns_ticket_filter( $columns ) {
function manage_columns_ticket_action( $column, $post_id ) {
switch ( $column ) {
case 'tix_price':
- echo esc_html( $this->append_currency( get_post_meta( $post_id, 'tix_price', true ) ) );
+ echo esc_html( append_currency( get_post_meta( $post_id, 'tix_price', true ), $this->options ) );
break;
case 'tix_quantity':
echo intval( get_post_meta( $post_id, 'tix_quantity', true ) );
@@ -712,11 +713,11 @@ function manage_columns_attendee_action( $column, $post_id ) {
break;
case 'tix_order_total':
$order_total = (float) get_post_meta( $post_id, 'tix_order_total', true );
- echo esc_html( $this->append_currency( $order_total ) );
+ echo esc_html( append_currency( $order_total, $this->options ) );
break;
case 'tix_ticket_price':
$ticket_price = (float) get_post_meta( $post_id, 'tix_ticket_price', true );
- echo esc_html( $this->append_currency( $ticket_price ) );
+ echo esc_html( append_currency( $ticket_price, $this->options ) );
break;
}
}
@@ -758,7 +759,7 @@ function manage_columns_coupon_action( $column, $post_id ) {
$discount_price = (float) get_post_meta( $post_id, 'tix_discount_price', true );
$discount_percent = (int) get_post_meta( $post_id, 'tix_discount_percent', true );
if ( $discount_price > 0 ) {
- echo esc_html( $this->append_currency( $discount_price ) );
+ echo esc_html( append_currency( $discount_price, $this->options ) );
} elseif ( $discount_percent > 0 ) {
echo esc_html( $discount_percent . '%' );
}
@@ -1914,7 +1915,7 @@ function field_currency( $args ) {
$currency ) : ?>
@@ -1955,48 +1956,6 @@ function sort_currencies( $a, $b ) {
return $a['label'] > $b['label'] ? 1 : -1;
}
- /**
- * Give me a price and I'll format it according to the set currency for
- * display. Don't send my output anywhere but the screen, because I will
- * print and other things.
- */
- function append_currency( $amount, $nbsp = true, $currency_key = false ) {
- $amount = floatval( $amount );
-
- $currencies = CampTix_Currency::get_currency_list();
-
- if ( ! $currency_key ) {
- if ( isset( $this->options['currency'] ) ) {
- $currency_key = $this->options['currency'];
- } else {
- $currency_key = 'USD';
- }
- }
-
- $currency = $currencies[ $currency_key ];
-
- if ( ! isset( $currency['decimal_point'] ) ) {
- $currency['decimal_point'] = 2;
- }
-
- if ( isset( $currency['locale'] ) ) {
- $formatter = new NumberFormatter( $currency['locale'], NumberFormatter::CURRENCY );
- $formatted_amount = $formatter->format( $amount );
- } elseif ( isset( $currency['format'] ) && $currency['format'] ) {
- $formatted_amount = sprintf( $currency['format'], number_format( $amount, $currency['decimal_point'] ) );
- } else {
- $formatted_amount = $currency_key . ' ' . number_format( $amount, $currency['decimal_point'] );
- }
-
- $formatted_amount = apply_filters( 'tix_append_currency', $formatted_amount, $currency, $amount );
-
- if ( $nbsp ) {
- $formatted_amount = str_replace( ' ', ' ', $formatted_amount );
- }
-
- return $formatted_amount;
- }
-
/*
* Formats a string containing a first and/or last name, based on the specified name ordering scheme
* @param string $name_string A string containing placeholders for the given and surnames. e.g., "Hello %first% %last%"
@@ -2575,7 +2534,7 @@ function menu_tools_revenue() {
'
',
sprintf(
__( 'Woah! The revenue total does not match with the transactions total. The actual total is: %s. Something somewhere has gone wrong, please report this.', 'wordcamporg' ),
- esc_html( $this->append_currency( $results['actual_total'] ) )
+ esc_html( append_currency( $results['actual_total'], $this->options ) )
)
);
}
@@ -2697,18 +2656,18 @@ function generate_revenue_report_data() {
__( 'Ticket type', 'wordcamporg' ) => esc_html( $ticket->post_title ),
__( 'Sold', 'wordcamporg' ) => $ticket->tix_sold_count,
__( 'Remaining', 'wordcamporg' ) => $ticket->tix_remaining,
- __( 'Sub-Total', 'wordcamporg' ) => $this->append_currency( $ticket->tix_sold_count * $ticket->tix_price ),
- __( 'Discounted', 'wordcamporg' ) => $this->append_currency( $ticket->tix_discounted ),
- __( 'Revenue', 'wordcamporg' ) => $this->append_currency( $ticket->tix_sold_count * $ticket->tix_price - $ticket->tix_discounted ),
+ __( 'Sub-Total', 'wordcamporg' ) => append_currency( $ticket->tix_sold_count * $ticket->tix_price, $this->options ),
+ __( 'Discounted', 'wordcamporg' ) => append_currency( $ticket->tix_discounted, $this->options ),
+ __( 'Revenue', 'wordcamporg' ) => append_currency( $ticket->tix_sold_count * $ticket->tix_price - $ticket->tix_discounted, $this->options ),
);
}
$rows[] = array(
__( 'Ticket type', 'wordcamporg' ) => 'Total',
__( 'Sold', 'wordcamporg' ) => $totals->sold,
__( 'Remaining', 'wordcamporg' ) => $totals->remaining,
- __( 'Sub-Total', 'wordcamporg' ) => $this->append_currency( $totals->sub_total ),
- __( 'Discounted', 'wordcamporg' ) => $this->append_currency( $totals->discounted ),
- __( 'Revenue', 'wordcamporg' ) => $this->append_currency( $totals->revenue ),
+ __( 'Sub-Total', 'wordcamporg' ) => append_currency( $totals->sub_total, $this->options ),
+ __( 'Discounted', 'wordcamporg' ) => append_currency( $totals->discounted, $this->options ),
+ __( 'Revenue', 'wordcamporg' ) => append_currency( $totals->revenue, $this->options ),
);
// Update stats
@@ -4115,7 +4074,7 @@ function metabox_ticket_options() {
options['currency'] ); ?>
- append_currency( get_post_meta( get_the_ID(), 'tix_price', true ) ) ); ?>
+ options ) ); ?>
@@ -4619,7 +4578,7 @@ function metabox_coupon_options() {
- append_currency( $discount_price ) ); ?>
+ options ) ); ?>
%
@@ -4742,7 +4701,7 @@ function metabox_attendee_info() {
$rows[] = array( __( 'Coupon', 'wordcamporg' ), sprintf( '%s', get_edit_post_link( $coupon->ID ), $coupon->post_title ) );
}
- $rows[] = array( __( 'Order Total', 'wordcamporg' ), $this->append_currency( get_post_meta( $post->ID, 'tix_order_total', true ) ) );
+ $rows[] = array( __( 'Order Total', 'wordcamporg' ), append_currency( get_post_meta( $post->ID, 'tix_order_total', true ), $this->options ) );
// Reservation
if ( $this->options['reservations_enabled'] ) {
@@ -5281,7 +5240,7 @@ function template_redirect() {
if ( $this->coupon->tix_discount_price > 0 ) {
$ticket->tix_discounted_price = number_format( $ticket->tix_price - $this->coupon->tix_discount_price, 2, '.', '' );
- $ticket->tix_discounted_text = sprintf( __( 'Discounted %s', 'wordcamporg' ), $this->append_currency( $this->coupon->tix_discount_price ) );
+ $ticket->tix_discounted_text = sprintf( __( 'Discounted %s', 'wordcamporg' ), append_currency( $this->coupon->tix_discount_price, $this->options ) );
} elseif ( $this->coupon->tix_discount_percent > 0 ) {
$ticket->tix_discounted_price = number_format( $ticket->tix_price - ( $ticket->tix_price * $this->coupon->tix_discount_percent / 100 ), 2, '.', '' );
$ticket->tix_discounted_text = sprintf( __( 'Discounted %s%%', 'wordcamporg' ), $this->coupon->tix_discount_percent );
@@ -5646,7 +5605,7 @@ function form_start() {
0 ) : ?>
- append_currency( $price ) ); ?>
+ options ) ); ?>
@@ -5679,7 +5638,7 @@ function form_start() {
$discount_percent = (float) $this->coupon->tix_discount_percent;
$discount_text = '0%';
if ( $discount_price > 0 ) {
- $discount_text = $this->append_currency( $discount_price );
+ $discount_text = append_currency( $discount_price, $this->options );
} elseif ( $discount_percent > 0 ) {
$discount_text = $discount_percent . '%';
}
@@ -5850,13 +5809,13 @@ function form_attendee_info() {
|
0 ) : ?>
- append_currency( $price ) ); ?>
+ options ) ); ?>
|
|
- append_currency( $price * intval( $count ) ) ); ?> |
+ options ) ); ?> |
@@ -5868,7 +5827,7 @@ function form_attendee_info() {
$discount_text = '';
if ( $discount_price > 0 ) {
- $discount_text = $this->append_currency( $discount_price );
+ $discount_text = append_currency( $discount_price, $this->options );
} elseif ( $discount_percent > 0 ) {
$discount_text = $discount_percent . '%';
}
@@ -5889,7 +5848,7 @@ function form_attendee_info() {
- append_currency( $total ) ); ?>
+ options ) ); ?>
|
@@ -7835,13 +7794,13 @@ function email_tickets( $payment_token = false, $from_status = 'draft', $to_stat
$receipt_content = '';
foreach ( $order['items'] as $item ) {
$ticket = get_post( $item['id'] );
- $receipt_content .= sprintf( "* %s (%s) x%d = %s\n", $ticket->post_title, $this->append_currency( $item['price'], false ), $item['quantity'], $this->append_currency( $item['price'] * $item['quantity'], false ) );
+ $receipt_content .= sprintf( "* %s (%s) x%d = %s\n", $ticket->post_title, append_currency( $item['price'], $this->options, false ), $item['quantity'], append_currency( $item['price'] * $item['quantity'], $this->options, false ) );
}
if ( isset( $order['coupon'] ) && $order['coupon'] )
$receipt_content .= sprintf( '* ' . __( 'Coupon used: %s', 'wordcamporg' ) . "\n", $order['coupon'] );
- $receipt_content .= sprintf( "* " . __( 'Total: %s', 'wordcamporg' ), $this->append_currency( $order['total'], false ) );
+ $receipt_content .= sprintf( "* " . __( 'Total: %s', 'wordcamporg' ), append_currency( $order['total'], $this->options, false ) );
$signature = apply_filters( 'camptix_ticket_email_signature', __( 'Let us know if you have any questions!', 'wordcamporg' ) );
// Set the tmp receipt for shortcodes use.
diff --git a/public_html/wp-content/plugins/camptix/utility.php b/public_html/wp-content/plugins/camptix/utility.php
new file mode 100644
index 000000000..716caf75e
--- /dev/null
+++ b/public_html/wp-content/plugins/camptix/utility.php
@@ -0,0 +1,47 @@
+format( $amount );
+ } elseif ( isset( $currency['format'] ) && $currency['format'] ) {
+ $formatted_amount = sprintf( $currency['format'], number_format( $amount, $currency['decimal_point'] ) );
+ } else {
+ $formatted_amount = $currency_key . ' ' . number_format( $amount, $currency['decimal_point'] );
+ }
+
+ $formatted_amount = apply_filters( 'tix_append_currency', $formatted_amount, $currency, $amount );
+
+ if ( $nbsp ) {
+ $formatted_amount = str_replace( ' ', ' ', $formatted_amount );
+ }
+
+ return $formatted_amount;
+}