<?php

namespace BWDK\Support;

class WooCompatibility
{

    public static function convert_to_BWDK_currency($amount, $convert_type = Constant::TOMAN): float
    {
        $amount         = (float)$amount;
        if (BWDK_STORE_CURRENCY === Constant::TOMAN && $convert_type === Constant::RIAL) {
            return round($amount *= 10, BWDK_STORE_GET_PRICE_DECIMALS);
        }
        if (BWDK_STORE_CURRENCY === Constant::RIAL && $convert_type === Constant::TOMAN) {
            return round($amount /= 10, BWDK_STORE_GET_PRICE_DECIMALS);
        }
        return round($amount, BWDK_STORE_GET_PRICE_DECIMALS);
    }

    public static function convert_to_store_currency($amount, $convert_type = Constant::TOMAN): float
    {
        $amount         = (float)$amount;
        if (BWDK_STORE_CURRENCY === Constant::RIAL && $convert_type === Constant::TOMAN) {
            return round($amount *= 10, BWDK_STORE_GET_PRICE_DECIMALS);
        }
        if (BWDK_STORE_CURRENCY === Constant::TOMAN && $convert_type === Constant::RIAL) {
            return round($amount /= 10, BWDK_STORE_GET_PRICE_DECIMALS);
        }
        return round($amount, BWDK_STORE_GET_PRICE_DECIMALS);
    }



}
