Multiple currencies

I want to do something similar here: Have the option to display multiple currencies

But I have the marketplace extension.

I need to have multiple currencies (crypto ones) and display them in block primary

Please try using any popular currency switched for WooCommerce. Note that it will work for displaying different currencies, but checkout will be completed in the primary currency only.

async function plugin_priceConvertor () {
		const prices = Array.from(document.querySelectorAll(".hp-listing__attribute--price"));
		const allrates = await fetch("").then(e=>e.json());
		const ethereum =>e.symbol == "ETH");
		const bitcoin =>e.symbol == "BTC");
		const usdt =>e.symbol == "USDT");

		//const rate =;

		prices.forEach( function(node) {

			const parent = node.parentNode;
			const container = document.createElement("div");
			container.className = "cryptoprices";
			const price = parseFloat(node.innerText.replaceAll(".", ""));
			// Ethereum Price
			const priceETH = document.createElement("div");
			priceETH.className = "price-eth";
			const finalPrice = parseFloat(price / ethereum.rateUsd); 

			priceETH.innerHTML = finalPrice.toFixed(2) + " <i>ETH</i>";

			// Bitcoin Price
			const priceBTC = document.createElement("div");
			priceBTC.className = "price-btc";
			const finalPriceBTC = parseFloat(price / bitcoin.rateUsd); 

			priceBTC.innerHTML = finalPriceBTC.toFixed(2) + " <i>BTC</i>";

			// USDT Price
			const priceUSDT = document.createElement("div");
			priceUSDT.className = "price-usdt";
			const finalPriceUSDT = parseFloat(price / usdt.rateUsd); 

			priceUSDT.innerHTML = finalPriceUSDT.toFixed(2) + " <i>USDT</i>";

	} catch(e) {
		console.log("API Request Failed.", e.message);

window.addEventListener("load", plugin_priceConvertor);

This is not a recommended solution, but works. You can do it with PHP as well but you need to cache it etc.

So this is what I needed. Maybe you will consider to use this free API and make a plugin to display multiple/convert currencies :). Thanks

1 Like