FOX - Currency Switcher for WooCommerce

woocs_woocommerce_available_variation

The woocs_woocommerce_available_variation filter passes the data array of a single variation after FOX has converted its prices into the current currency. This is the array WooCommerce hands to the front end as JSON, so anything you change here reaches the variation form directly — the displayed price HTML, the availability line, the image, the custom fields your theme reads.
add_filter('woocs_woocommerce_available_variation', function ($data, $product, $variation) {
    global $WOOCS;

    if (isset($WOOCS) and $WOOCS->current_currency !== $WOOCS->default_currency) {
        $data['price_html'] .= '<small class="fox-note">approximate</small>';
    }

    return $data;
}, 10, 3);
Parameters:
  • $data (array) - the variation data, prices already converted
  • $product (WC_Product_Variable) - the parent product
  • $variation (WC_Product_Variation) - the variation itself
Returns:
  • (array) the variation data to send to the front end
Note: the filter is applied twice inside the same method — once while building the array and once on the finished result. Write the callback so that running it twice on the same data is harmless.