Price Currency
It changes currency in prices.
// Add Shortcode function price_currency( $atts ) { // Attributes $atts = shortcode_atts( array( 'kur' => 'dolar', ), $atts, 'currency' ); $ret = ''; $ret = ' <form method="POST"> <select name="currency"> <option value="dolar" name="dolar">$ USD</option> <option value="euro" name="euro">€ EUR</option> <option value="try" name ="try">₺ TRY</option> <option value="sterlin" name ="sterlin">£ GBP</option> </select> <input type = "submit" name ="buton" value = "getir"> </form>'; $post_meta = tourmaster_get_post_meta(get_the_ID(), 'tourmaster-tour-option'); $extra_class = empty($post_meta['tour-price-discount-text'])? '': 'tourmaster-discount'; $decimal_digit = tourmaster_get_option('general', 'header-price-decimal-digit', 0); if( !empty($post_meta['tour-price-text']) || !empty($post_meta['tour-price-discount-text']) ){ $kurlar = simplexml_load_file("https://tcmb.gov.tr/kurlar/today.xml"); $dolar =$kurlar -> Currency[0] -> BanknoteBuying; $euro = $kurlar -> Currency[3] -> BanknoteBuying; $sterlin = $kurlar -> Currency[4] -> BanknoteBuying; $ret .= '<div class="tourmaster-tour-price-wrap ' . esc_attr($extra_class) . '" >'; if( !empty($post_meta['tour-price-text']) ){ $ret .= '<span class="tourmaster-tour-price" >'; $ret .= '<span class="tourmaster-head">'; $ret .= empty($settings['price-prefix-text'])? esc_html__('From', 'tourmaster'): $settings['price-prefix-text']; $ret .= '</span>'; $ret .= '<span class="tourmaster-tail">' . tourmaster_money_format($post_meta['tour-price-text'], $decimal_digit) . '</span>'; $ret .= '</span>'; } if( !empty($post_meta['tour-price-discount-text']) ){ $ret .= '<span class="tourmaster-tour-discount-price">'; if($_POST){ if($_POST["currency"] == "dolar"){ $atts = "dolar"; $ret .='$'.(floor($post_meta['tour-price-discount-text'])); } else if($_POST["currency"] == "try"){ $atts = "try"; $post_meta['tour-price-discount-text'] = $post_meta['tour-price-discount-text'] * $dolar; $ret .='₺'.(floor($post_meta['tour-price-discount-text'])); } else if($_POST["currency"] == "euro"){ $atts = "euro"; $post_meta['tour-price-discount-text'] = $post_meta['tour-price-discount-text'] * $dolar/$euro; $ret .='€'.(floor($post_meta['tour-price-discount-text'])); } else if($_POST["currency"] == "sterlin"){ $atts = "sterlin"; $post_meta['tour-price-discount-text'] = $post_meta['tour-price-discount-text'] * $dolar/$sterlin; $ret .='£'.(floor($post_meta['tour-price-discount-text'])); } } else { $atts = "dolar"; $ret .='$'.($post_meta['tour-price-discount-text']); $ret .= '</span>'; } //$ret .='$'.($post_meta['tour-price-discount-text']); //$ret .= '</span>'; //$ret .= tourmast } if( !empty($settings['with-info']) ){ $ret .= '<span class="fa fa-info-circle tourmaster-tour-price-info" data-rel="tipsy" title="'; $ret .= esc_html__('The initial price based on 1 adult with the lowest price in low season', 'tourmaster'); $ret .= '" >'; $ret .= '</span>'; } $ret .= '</div>'; } return $ret; } } add_shortcode( 'currency', 'price_currency' );