Skip to content

Commit

Permalink
Merge pull request #2212 from the-events-calendar/fix/ET-1330-final
Browse files Browse the repository at this point in the history
Filter currencies on key screens
  • Loading branch information
bordoni authored Nov 17, 2021
2 parents 9d741bd + 1049082 commit a9ace17
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
3 changes: 3 additions & 0 deletions src/Tickets/Commerce/Ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ public function get_ticket( $ticket_id ) {
return null;
}

/** @todo TribeCommerceLegacy: Remove the usage of Currency from Tribe Commerce totally, leave that behind. */
add_filter( 'tribe_get_option_ticket-commerce-currency-code', [ tribe( Legacy_Compat::class ), 'maybe_load_currency_code_from_tribe_commerce' ] );

$event_id = get_post_meta( $ticket_id, static::$event_relation_meta_key, true );

$return = new \Tribe__Tickets__Ticket_Object();
Expand Down
3 changes: 3 additions & 0 deletions src/Tickets/Commerce/Utils/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ public static function to_string( $value, $decimal = '.', $thousand_sep = ',' )
* @return float
*/
public static function to_numeric( $value ) {

$value = preg_replace( '/&[^;]+;/', '', $value );

// Get all non-digits from the value
preg_match_all( '/[^\d]/', $value, $matches );

Expand Down
7 changes: 4 additions & 3 deletions src/views/v2/commerce/checkout/cart/footer/total.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
*
* @link https://evnt.is/1amp Help article for RSVP & Ticket template files.
*
* @since 5.1.9
* @since TBD enforcing proper currency formatting
* @since 5.1.9
*
* @version 5.1.9
* @version TBD
*
* @var \Tribe__Template $this [Global] Template object.
* @var Module $provider [Global] The tickets provider instance.
Expand All @@ -31,7 +32,7 @@
'<span class="tribe-tickets__commerce-checkout-cart-footer-total-label">',
'</span>',
'<span class="tribe-tickets__commerce-checkout-cart-footer-total-wrap">',
$total_value,
\TEC\Tickets\Commerce\Utils\Price::to_currency( $total_value ),
'</span>'
)
);
Expand Down
7 changes: 4 additions & 3 deletions src/views/v2/commerce/checkout/cart/item/sub-total.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
*
* @link https://evnt.is/1amp Help article for RSVP & Ticket template files.
*
* @since 5.1.9
* @since TBD enforcing proper currency formatting
* @since 5.1.9
*
* @version 5.1.9
* @version TBD
*
* @var \Tribe__Template $this [Global] Template object.
* @var Module $provider [Global] The tickets provider instance.
Expand All @@ -28,5 +29,5 @@

?>
<div class="tribe-tickets__commerce-checkout-cart-item-subtotal">
<?php echo esc_html( tribe_format_currency( $item['sub_total'] ) ); ?>
<?php echo wp_kses_post( \TEC\Tickets\Commerce\Utils\Price::to_currency( $item['sub_total'] ) ); ?>
</div>
7 changes: 4 additions & 3 deletions src/views/v2/commerce/order/details/total.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
*
* @link https://evnt.is/1amp Help article for RSVP & Ticket template files.
*
* @since 5.1.10
* @since TBD enforcing proper currency formatting
* @since 5.1.10
*
* @version 5.1.10
* @version TBD
*
* @var \Tribe__Template $this [Global] Template object.
* @var Module $provider [Global] The tickets provider instance.
Expand All @@ -31,6 +32,6 @@
<?php esc_html_e( 'Total:', 'event-tickets' ); ?>
</div>
<div class="tribe-tickets__commerce-order-details-col2">
<?php echo esc_html( $order->formatted_total ); ?>
<?php echo esc_html( \TEC\Tickets\Commerce\Utils\Price::to_currency( $order->formatted_total ) ); ?>
</div>
</div>

0 comments on commit a9ace17

Please sign in to comment.