Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

ikicni

// Add Shortcode
function price_currency( $atts ) {

	// Attributes
	$atts = shortcode_atts(
		array(
			'kur' => 'dolar',
		),
		$atts,
		'currency'
	);

	// tour price
				function get_price( $settings = array() ){
					
		
	
					$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>
			</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;
		 			str_replace(".",",",$dolar);
		 			str_replace(".",",",$euro);
		 			str_replace(".",",",$sterlin);
	
					
					
						
						$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']) ){
							
							if($_POST){
								if($_POST["currency"] == "try"){
									$try = $post_meta['tour-price-discount-text'] * $dolar;
			 						$post_meta['tour-price-discount-text'] = $post_meta['tour-price-discount-text'] * $dolar;
									$_SESSION["currency"] = $_POST["currency"];
									$_SESSION["tour-price-discount-text"] = $post_meta['tour-price-discount-text'];
									echo "ananza: !!!!!!!".$try;
					}
						if($_POST["currency"] == "euro"){
								$try =$post_meta['tour-price-discount-text'] * $euro;
								$_SESSION["currency"] = $_POST["currency"];
								$_SESSION["tour-price-discount-text"] = $post_meta['tour-price-discount-text'];
								echo $try;
				}
			}
							$_SESSION["currency"] = $_POST["currency"];
							$_SESSION["tour-price-discount-text"] = $post_meta['tour-price-discount-text'];
							$ret .= '<span class="tourmaster-tour-discount-price">';
							if($_POST){
								if($_POST["currency"] == "try"){
									$post_meta['tour-price-discount-text'] = $post_meta['tour-price-discount-text'] * $dolar;
									$ret .='₺'.($post_meta['tour-price-discount-text']);
								}
								else if($_POST["currency"] == "euro"){
									$post_meta['tour-price-discount-text'] = $post_meta['tour-price-discount-text'] * $dolar/$euro;
								}
							}
							$ret .='$'.($post_meta['tour-price-discount-text']);
							$ret .= '</span>';
							//$ret .= tourmaster_money_format($post_meta['tour-price-discount-text']*2, $decimal_digit);
		
						}
	
						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' );