### Manage Currency Formatting and Conversion in PHP Source: https://context7.com/oscommerce/oscommerce2/llms.txt Provides examples for formatting prices, performing currency conversions, and calculating totals using the `currencies` class. It covers automatic conversion based on session currency, manual formatting, tax calculations, and retrieving currency-specific information like exchange rates and decimal places. Requires the global `$currencies` object to be initialized. ```php global $currencies; // Initialize currencies (happens automatically in application_top.php) // $currencies = new currencies(); // Format price with currency conversion $formatted = $currencies->format( $number = 29.99, $calculate_currency_value = true, $currency_type = 'USD', $currency_value = '' ); // Returns: "$29.99" (with appropriate symbol and formatting) // Format without currency conversion (already in target currency) $formatted = $currencies->format( $number = 29.99, $calculate_currency_value = false, $currency_type = 'EUR' ); // Returns: "€29.99" // Calculate price with tax and quantity $price = $currencies->calculate_price( $products_price = 19.99, $products_tax = 20, // 20% tax $quantity = 3 ); // Returns: 23.99 * 3 = 71.97 // Display formatted price with tax $display = $currencies->display_price( $products_price = 19.99, $products_tax = 20, $quantity = 2 ); // Returns: "$47.98" (formatted with currency symbol) // Check if currency code exists if ($currencies->is_set('GBP')) { echo "British Pound is available"; } // Get currency exchange rate value $rate = $currencies->get_value('EUR'); // Returns: 0.85 (example rate) // Get decimal places for currency $decimals = $currencies->get_decimal_places('JPY'); // Returns: 0 (Yen has no decimals) // Format raw number without currency symbols (for calculations) $raw = $currencies->format_raw( $number = 29.99, $calculate_currency_value = true, $currency_type = 'USD' ); // Returns: "29.99" (number only, no symbols) // Display raw price (useful for hidden form fields) $raw_display = $currencies->display_raw( $products_price = 19.99, $products_tax = 20, $quantity = 1 ); // Returns: "23.99" ``` -------------------------------- ### Manage Payment Modules in osCommerce 2 Source: https://context7.com/oscommerce/oscommerce2/llms.txt Handles initialization, management, and processing of payment methods using dynamic module loading. It supports automatic discovery of installed payment gateways and provides methods for accessing, validating, and processing payments throughout the checkout flow. Dependencies include the `payment` class and potentially session management. ```php use OSC\OM\Registry; // Initialize payment class with all available methods $payment = new payment(); // Automatically loads all installed payment modules from MODULE_PAYMENT_INSTALLED // Initialize with specific payment module $payment = new payment('paypal_express'); // Access available payment modules foreach ($payment->modules as $module_name) { echo "Available: " . $module_name . "\n"; } // Output: paypal_express.php, stripe.php, cod.php // Get selected payment module if (isset($payment->selected_module)) { echo "Selected payment: " . $payment->selected_module; } // Access payment module form action URL (for external gateways) if (isset($payment->form_action_url)) { echo '