Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // WooCommerce - show price in two currencies
- // not great because you'll need to manually update the factor regularly
- add_filter( 'woocommerce_get_price_html', 'euros_custom_price', 100, 2 );
- function euros_custom_price( $price, $product ) {
- $factor = 0.008352; // Euro conversion factor
- if ( $product->is_type('simple') ) {
- $my_price = $product->get_price();
- $euros = $my_price * $factor;
- $euros = number_format($euros, 2);
- $price = 'XPF ' . $price . ' (EUROS ' . $euros . ')';
- }
- if ( $product->is_type('variable') ) {
- $min_price = $product->get_variation_price('min');
- $min_euros = $min_price * $factor;
- $min_euros = number_format($min_euros, 2);
- $max_price = $product->get_variation_price('max');
- $max_euros = $max_price * $factor;
- $max_euros = number_format($max_euros, 2);
- $price = 'XPF '.$min_price.' to '.$max_price.' (EUROS '.$min_euros.' to '.$max_euros.')';
- }
- return $price;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement