=== Multiple Currencies for Paid Memberships Pro ===
Contributors: jarryd-long, louiswol94
Tags: pmpro, currency, multiple currencies, paid memberships pro, currency switcher
Requires at least: 5.0
Tested up to: 6.8
Stable tag: 1.0.0
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Sell memberships in multiple currencies - assign a currency per level, let visitors switch with a single click, and track revenue by currency.

== Description ==

**Multiple Currencies for Paid Memberships Pro** gives your membership site the flexibility to accept payments in different currencies, whether you charge different regions different amounts or simply want visitors to see pricing in their own currency.

Assign any currency to any membership level, display a sleek frontend switcher so visitors can choose their preferred currency, and let the plugin remember their choice across visits and devices. Every order is stored with its currency so your reports and account pages always show the right symbol - no surprises.

= Key Features =

**Per-Level Currency**
Assign a specific currency to each membership level directly from the level edit screen. The correct currency and symbol is applied automatically at checkout, on the confirmation page, in invoice emails, and on the account page. Levels with no override fall back to your site's default currency.

**Frontend Currency Switcher**
A floating pill-style switcher appears on the frontend so visitors can select their preferred currency at any time. Their choice is saved in a cookie and - for logged-in users - synced to their account so it follows them across devices. The switcher is hidden on the checkout page to avoid confusion mid-purchase.

**Inline Switcher via Shortcode**
Prefer to place the switcher inside your own content or template? Use the `[pmpro_currency_switcher]` shortcode to embed it anywhere - a page, a widget, or a block.

**Geo-Detection (opt-in)**
When enabled, new visitors are automatically offered a currency based on their country, detected via Cloudflare or standard CDN country headers. Visitors can still override using the switcher. This setting is off by default.

**Available Currencies Restriction**
By default the plugin works with all currencies registered in Paid Memberships Pro. Use the Available Currencies setting to restrict the list to only the currencies your site actually uses - keeping level dropdowns and the frontend switcher clean.

**Widget Placement Control**
Choose where the floating switcher appears: on all pages (except checkout), on PMPro pages only, or hide it entirely and rely on the shortcode instead.

**Sales by Currency Report**
A dedicated report under Memberships > Reports shows order count and revenue broken down by currency, with filters for today, this month, this year, all time, or a custom date range. A summary tile also appears on the PMPro reports dashboard.

**Accurate Order History**
The currency and symbol are saved to order meta at the moment of checkout. This means the account page, admin order screen, invoices, and confirmation emails always reflect the currency the member actually paid in - even if your site default changes later.

= Settings =

All plugin settings live under **Memberships > Settings > Advanced**.

* **Available Currencies** - check the currencies you want to make available for level assignment and the frontend switcher. Leave all unchecked to allow all PMPro currencies.
* **Widget Placement** - controls the floating currency switcher. Hidden by default — each level uses its assigned currency and no floating widget is shown. Visitors can still switch using the `[pmpro_currency_switcher]` shortcode. Set to all pages or PMPro pages only to show the floating widget automatically.
* **Enable Geo-Detection** - when checked, new visitors are automatically detected by country and offered the matching currency.

= Shortcode =

`[pmpro_currency_switcher]`

Embeds the currency switcher inline in any page, post, or widget. Only renders when two or more currencies are enabled.

= Developer Notes =

Enable the debug overlay by adding `define( 'PMPRO_MC_DEBUG', true );` to your `wp-config.php`. The overlay shows the active currency, cookie value, user meta value, geo-detected currency, and the list of enabled currencies - useful for troubleshooting.

This plugin is not an official Paid Memberships Pro add on.

== Installation ==

1. Upload the `pmpro-multiple-currencies` folder to the `/wp-content/plugins/` directory, or install it directly through the WordPress plugin screen.
2. Activate the plugin through the **Plugins** screen in WordPress.
3. Make sure Paid Memberships Pro is installed and active.
4. Go to **Memberships > Settings > Advanced** to configure Available Currencies, widget placement, and geo-detection.
5. Edit any membership level under **Memberships > Membership Levels** and scroll to the **Currency Settings** section to assign a currency to that level.

== Frequently Asked Questions ==

= Does this plugin convert prices automatically? =

No. Prices are set manually per membership level. This gives you full control - you decide exactly what to charge in each currency, which is important when exchange rates fluctuate or when you want to use regional pricing that isn't a straight conversion.

= What happens to levels that don't have a currency set? =

They use the site's default currency, the same one set in **Memberships > Settings > Payment Settings**.

= Will the currency switcher show on the checkout page? =

No. The floating widget is hidden on the checkout page to prevent visitors from switching currency mid-purchase. If you need switcher access near checkout, use the `[pmpro_currency_switcher]` shortcode on a page of your choice.

= How does geo-detection work? =

When enabled, the plugin reads the visitor's country from the `HTTP_CF_IPCOUNTRY` header (Cloudflare) or `HTTP_X_COUNTRY_CODE` / `HTTP_X_GEO_COUNTRY` headers set by other CDN/proxy providers. If a matching currency is found and it is in your enabled list, it is applied automatically. Visitors can always override with the switcher.

= Does geo-detection work without Cloudflare? =

It works with any CDN or reverse proxy that sets a country header. Without one of these headers the detection is skipped and no currency is auto-applied.

= Will the currency preference follow a logged-in user across devices? =

Yes. For logged-in users the active currency is synced to their user account, so switching on one device is reflected when they log in on another.

= Where are the sales-by-currency reports? =

Under **Memberships > Reports**, select **Sales by Currency**. A summary tile also appears on the main Reports dashboard.

= Is this an official Paid Memberships Pro add on? =

No. It is an independent, community-built add on maintained by Jarryd Long.

== Screenshots ==

1. Currency setting on the membership level edit screen
2. Currency options in the level dropdown
3. Currency column on the admin Membership Levels list
4. Currency switcher as seen by members on the frontend
5. Checkout page showing the level's assigned currency
6. Membership confirmation page with correct currency
7. Membership invoice with correct currency

== Upgrade Notice ==

= 1.0.0 =
Major release with a new owner and significant new features - a frontend currency switcher, geo-detection, cross-device preference persistence, a Sales by Currency report, and security hardening throughout. Fully backwards compatible with existing level currency settings. Recommended for all users.

== Changelog ==

= 1.0.0 =
* Ownership: Plugin has a new maintainer - Jarryd Long, ex-PMPro support manager and developer, has taken over from the original author Louis Wolmarans
* Feature: Floating frontend currency switcher widget - visitors can click a pill to select their preferred currency; choice is stored in a cookie and persisted to user meta for logged-in users across devices
* Feature: Inline currency switcher via `[pmpro_currency_switcher]` shortcode - embed the switcher anywhere in page content
* Feature: Geo-detection - automatically suggests a currency based on the visitor's country (via Cloudflare/CDN headers); opt-in via PMPro Advanced Settings
* Feature: Widget placement control - choose to show the floating switcher on all pages, PMPro pages only, or hide it entirely (PMPro Advanced Settings)
* Feature: Available Currencies setting - restrict which currencies can be assigned to levels and shown in the switcher (PMPro Advanced Settings)
* Feature: Currency column in the membership levels list table - shows the assigned currency for each level, including site default for unset levels
* Feature: "Sales by Currency" PMPro report - shows order count and revenue broken down by currency, with a period filter (today / this month / this year / all time / custom range) and a dashboard summary widget
* Feature: Order meta - saves the currency code and symbol to order meta at checkout so orders always display in the correct currency, including on the account page, admin order screen, invoices, and confirmation emails
* Security: Full hardening pass - output escaping throughout, capability checks on all save functions, input guards, and strict comparisons
* Fix: Currency symbol on the confirmation page, invoice, and account page now reflects the currency the order was placed in rather than the current visitor currency

= 0.0.5 - 2024-11-18 =
* Tweak: Added support for the remaining pages and emails

= 0.0.4 - 2024-05-14 =
* Tweak: Improve currency update on Invoice and Confirmation page

= 0.0.3 - 2024-05-14 =
* Tweak: Add support for Invoice and Confirmation pages (props @andrewza for the direction)

= 0.0.2 - 2022-03-17 =
* Fix: Undefined index on the symbol array key
* Tweak: Minor localization changes

= 0.0.1 =
* Initial release
