FOX - Currency Switcher for WooCommerce

How to Set a Fixed Price per Currency Programmatically

Products arriving through the WooCommerce API, an importer or a feed can carry their fixed per-currency prices with them. FOX stores those prices as ordinary post meta, so anything that can write meta can set them.

The meta keys

  • _woocs_regular_price_XXX — fixed regular price in currency XXX
  • _woocs_sale_price_XXX — fixed sale price in currency XXX

XXX is the three-letter currency code, exactly as it is written in the plugin settings.

// 45.00 EUR as the fixed regular price of product 1234
update_post_meta(1234, '_woocs_regular_price_EUR', 45.00);
update_post_meta(1234, '_woocs_sale_price_EUR', 39.00);

Write the base price the normal WooCommerce way as well — _regular_price and _price. The fixed values are used when the visitor is in that currency; the base price is what everything else is calculated from.

Two settings this depends on

Fixed prices are read only when multi currency mode and individual fixed prices are both enabled in the plugin settings. Write the meta without them and nothing changes on the front end — the values sit in the database unused, which is the usual reason this looks like it "does not work".

Importing rather than coding

Any importer that writes post meta does the same job without PHP — add the per-currency columns to the CSV or map them in the feed, and the prices arrive with the products. For editing prices that already exist, see bulk editing currency switcher meta fields.

Reference: update_post_meta() in the WordPress developer handbook.