HEX
Server: LiteSpeed
System: Linux mail.aatilis.ir 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User: www (1000)
PHP: 8.3.30
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/soqatland.com/wp-content/plugins/persian-woocommerce/include/class-currencies.php
<?php

defined( 'ABSPATH' ) || exit;

class Persian_Woocommerce_Currencies extends Persian_Woocommerce_Core {

	/** @var array */
	public $currencies;

	public static $currency = null;

	public function __construct() {
		$this->currencies = [
			'IRR'  => 'ریال',
			'IRHR' => 'هزار ریال',
			'IRT'  => 'تومان',
			'IRHT' => 'هزار تومان',
		];


		add_filter( 'woocommerce_currencies', [ $this, 'currencies' ] );
		add_filter( 'woocommerce_currency_symbol', [ $this, 'currency_symbol' ], 10, 2 );
		add_filter( 'woocommerce_structured_data_product_offer', [ $this, 'fix_prices_in_structured_data' ], 100 );

		add_filter( 'rank_math/snippet/rich_snippet_product_entity', [ $this, 'fix_prices_in_structured_data' ], 100 );
		add_filter( 'rank_math/opengraph/facebook/product_price_amount', [ $this, 'convert_to_IRR' ], 100 );
		add_filter( 'rank_math/opengraph/facebook/product_price_currency', [ $this, 'currency_IRR' ], 100 );

		add_filter( 'wpseo_schema_offer', [ $this, 'fix_prices_in_structured_data' ], 10, 3 );
	}

	public function currencies( array $currencies ): array {
		return $this->currencies + $currencies;
	}

	public function currency_symbol( $currency_symbol, $currency ) {
		return $this->currencies[ $currency ] ?? $currency_symbol;
	}

	public function fix_prices_in_structured_data( array $markup_offer ): array {

		foreach ( $markup_offer as $key => &$value ) {

			if ( $key === 'priceCurrency' ) {
				$value = 'IRR';
			}

			if ( in_array( $key, [ 'price', 'lowPrice', 'highPrice' ], true ) ) {
				$value = $this->convert_to_IRR( $value );
			}

			if ( is_array( $value ) ) {
				$value = $this->fix_prices_in_structured_data( $value );
			}

		}

		return $markup_offer;
	}

	public static function currency_IRR(): string {
		return 'IRR';
	}

	public function convert_to_IRR( $price ): int {

		$price = intval( $price );

		// Default currency is IRT also
		if ( empty( self::$currency ) || self::$currency == 'IRT' ) {
			return $price * 10;
		}

		if ( self::$currency == 'IRHR' ) {
			return $price * 1000;
		}

		if ( self::$currency == 'IRHT' ) {
			return $price * 10000;
		}

		return $price;
	}

}

new Persian_Woocommerce_Currencies();