Linux 软件免费装
Banner图

MHM Currency Switcher

开发者 maxhandmade
更新时间 2026年9月7日 21:22
PHP版本: 7.4 及以上
WordPress版本: 7.1
版权: GPLv2 or later
版权网址: 版权信息

标签

woocommerce currency currency switcher exchange rate multi-currency

下载

2.1.0 2.2.0

详情介绍:

MHM Currency Switcher adds multi-currency support to your WooCommerce store. Customers can browse products, add items to their cart, and complete checkout in their preferred currency with real-time exchange rates. Key Features Cache compatibility mode A page cache stores the HTML your server produced for whoever asked first. When prices are converted on the server, that means the first visitor's currency is what every later visitor is served. Cache compatibility mode, which is on by default, avoids this: anonymous shop, archive and product pages are rendered in your base currency, so the same cached page is correct for everyone, and the browser converts the prices it can see afterwards through a REST request to this plugin. The split is deliberate. Only displayed prices are converted in the browser. Cart, checkout, order totals, order emails and the WooCommerce REST API are always calculated on the server in the currency the customer actually chose, so the amount charged cannot be altered from the browser. You can switch the mode off under WooCommerce > MHM Currency > Advanced, in which case prices are converted on the server as they were before this feature existed. Read "Known limits" below before deciding either way — both settings have consequences, and they are different ones.

安装:

  1. Upload the mhm-currency-switcher folder to the /wp-content/plugins/ directory, or install directly through the WordPress plugin screen.
  2. Activate the plugin through the 'Plugins' screen in WordPress.
  3. Make sure WooCommerce is installed and activated.
  4. Go to WooCommerce > MHM Currency to configure your currencies and exchange rates.

屏幕截图:

  • The switcher added to a site's navigation menu, with its list open.
  • Manage Currencies — each currency has its own rate, fee and rounding rules,
  • Display Options — a live preview of the switcher, what it shows, how large
  • Advanced — geolocation, the automatic rate-update interval, cache
  • How to use — every way the switcher can be placed, including the navigation

升级注意事项:

2.2.0 Privacy fix: geolocation no longer sends visitor IP addresses to a third-party service. With neither CloudFlare nor a MaxMind database, detection now finds nothing -- add a free MaxMind GeoLite2 key to keep it working. Your existing setting is unchanged; new installs get it off by default.

常见问题:

What are the shortcodes?

[mhmcs_currency_switcher] renders the currency dropdown. It accepts one attribute, size, which may be small, medium or large; leave it out to use the size saved in Display Options. [mhmcs_currency_prices] renders the same product price in several currencies. Its attributes are all optional:

  • currencies — comma-separated codes, e.g. currencies="USD,EUR". Without it, the currencies chosen in Display Options are used. Codes you have not configured as currencies are ignored.
  • product_id — price a specific product instead of the one being viewed.
  • price — price a specific amount instead of a product's.
  • show_flagstrue or false, overriding the saved Display Options setting.
Both are also available as Elementor widgets.

How many currencies can I add?

As many as your shop needs — every currency WooCommerce offers can be enabled, and nothing is held back for a paid version. The REST API refuses a request carrying more than 500 currency rows; that is a guard against oversized payloads and is well above the number of codes WooCommerce itself offers, so the panel cannot reach it.

How are exchange rates fetched?

Exchange rates are fetched from ExchangeRate-API in real time, either on demand or on a schedule you configure (hourly, twice daily, or daily) so your rates stay current without manual intervention. If that source cannot be reached, the plugin falls back to the European Central Bank's daily reference rate feed before giving up and leaving your existing rates in place. Both are named, with their terms, under "External services" below. If your network blocks the fallback, the mhmcs_fallback_rates_url filter can point it somewhere else.

Is the plugin compatible with WooCommerce HPOS?

Yes. MHM Currency Switcher fully supports WooCommerce High-Performance Order Storage (HPOS / Custom Order Tables).

Can a per-product fixed price be a sale price?

No. A fixed price is stored per product and currency, not per price type, so the same amount is used for the regular price and the sale price. A product on sale in your base currency shows as not on sale in a currency you have given a fixed price to. If you need the sale to carry across, leave that currency to the exchange rate instead of fixing it.

Is there a limit on how often the conversion endpoint can be called?

Yes. When cache compatibility mode is on, prices on cached pages are converted through a public REST endpoint, and one address may call it 120 times a minute by default. Ordinary browsing is nowhere near that — a page makes one request. If your shop sits behind a reverse proxy or a CDN that makes every visitor look like the same address, raise or disable the limit with the mhmcs_convert_rate_limit filter. Note that the address is read from the proxy headers WooCommerce passes on, which it trusts unconditionally and which can be forged; the limit bounds accidental hammering rather than a determined attacker.

I see a warning that cache compatibility is not being applied. What is it?

Some themes and plugins define WooCommerce's cart constant on every page, usually to show a cart total in the header. When that happens the plugin treats every page as a checkout — the customer's money is at stake — and converts prices on the server, which is exactly what cache compatibility mode exists to avoid. Nothing looks wrong on the site: prices are still correct for whoever loads the page first, and then a page cache can serve that person's currency to everyone else. Because there is no visible symptom, the plugin says so in the admin instead. The notice clears itself as soon as a front-end page renders normally again.

Why does the structured data show a different currency from the price on the page?

With cache compatibility on, the page is generated in your base currency and the browser converts the prices afterwards, so the machine-readable product data a crawler reads stays in the base currency. This is deliberate and is not corrected: pinning it the other way would leave the data disagreeing with the page in the one case where the two currently agree — with cache compatibility switched off, where the page and the structured data are both converted on the server.

Does the WooCommerce REST API return converted prices?

Only when the request asks for a currency: ?currency=EUR on a wc/v3 product request converts price, regular_price and sale_price and adds a currency_code field. Without the parameter the response is pinned to your base currency, so the answer never depends on the cookies of whoever is calling. A per-product fixed price takes precedence over the exchange rate here, exactly as it does on the shop page. One known limit: the price_html field is not pinned in the same way. It cannot be reached in that state by a normal wc/v3 client — only by code that dispatches an internal REST request during a page render — so no integration sees it, but it is not consistent with the three numeric fields and is recorded here rather than left unsaid.

更新日志:

2.2.0 2.1.0 2.0.0 1.3.1 1.3.0 1.2.0 1.1.3 1.1.2 1.1.1 1.1.0 1.0.0