Dual Currency Pricing Implementation (EUR/BGN)

๐Ÿ“„ General
โ† Back to Documentation
# Dual Currency Pricing Implementation (EUR/BGN) ## โœ… Overview Updated venue listings in `location.blade.php` to display prices in both EUR and BGN, matching the implementation in the venue detail page. --- ## ๐ŸŽฏ What Was Changed ### **File:** `resources/views/web/location.blade.php` Updated both **Grid View** and **List View** to show dual currency pricing. --- ## ๐Ÿ’ฐ Exchange Rate **EUR to BGN:** `1.95853` (Fixed rate as per Bulgarian National Bank) This is the same exchange rate used in the venue detail page. --- ## ๐Ÿ“Š Visual Changes ### Grid View - Before: ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ [Venue Image] โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ Venue Name โ”‚ โ”‚ โญ 4.5 (25 reviews)โ”‚ โ”‚ โ”‚ โ”‚ From โ”‚ โ”‚ โ‚ฌ150.00 /Night โ”‚ โ”‚ [Book] โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` ### Grid View - After: ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ [Venue Image] โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ Venue Name โ”‚ โ”‚ โญ 4.5 (25 reviews)โ”‚ โ”‚ โ”‚ โ”‚ From โ”‚ โ”‚ โ‚ฌ150.00 /Night โ”‚ โ”‚ 293.78 ะปะฒ โ”‚ โ”‚ [Book] โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` ### List View - Before: ``` [Image] Venue Name From โญ 4.5 (25 reviews) โ‚ฌ150.00 /Night ๐Ÿ“ Location [Book Now] ``` ### List View - After: ``` [Image] Venue Name From โญ 4.5 (25 reviews) โ‚ฌ150.00 /Night ๐Ÿ“ Location 293.78 ะปะฒ [Book Now] ``` --- ## ๐Ÿ”ง Implementation Details ### Grid View Pricing: ```php <div> @php $priceData = $venue->getLowestPrice(); $exchangeRate = 1.95853; // EUR to BGN @endphp @if($priceData) <div class="text-xs font-normal text-gray-500 mb-1">{{ __('From') }}</div> <div class="text-lg font-bold text-gray-900"> โ‚ฌ{{ number_format($priceData['price'], 2) }} <span class="text-sm font-normal text-gray-600">/{{ __($priceData['unit_label']) }}</span> </div> <div class="text-sm font-medium text-gray-600"> {{ number_format($priceData['price'] * $exchangeRate, 2) }} ะปะฒ </div> @else {{-- Fallback for venues without objects --}} @php $randomPrice = $bookingType === 'spots' ? rand(15, 150) : ($bookingType === 'rentals' ? rand(50, 300) : rand(30, 200)); $unit = $bookingType === 'spots' ? 'day' : ($bookingType === 'rentals' ? 'night' : 'hour'); @endphp <div class="text-lg font-bold text-gray-900"> โ‚ฌ{{ $randomPrice }} <span class="text-sm font-normal text-gray-600">/{{ $unit }}</span> </div> <div class="text-sm font-medium text-gray-600"> {{ number_format($randomPrice * $exchangeRate, 2) }} ะปะฒ </div> @endif </div> ``` ### List View Pricing: ```php <div class="text-right ml-6"> @php $priceData = $venue->getLowestPrice(); $exchangeRate = 1.95853; // EUR to BGN @endphp @if($priceData) <div class="text-sm font-normal text-gray-500 mb-1">{{ __('From') }}</div> <div class="text-2xl font-bold text-gray-900"> โ‚ฌ{{ number_format($priceData['price'], 2) }} <span class="text-lg font-normal text-gray-600">/{{ __($priceData['unit_label']) }}</span> </div> <div class="text-lg font-medium text-gray-600 mb-2"> {{ number_format($priceData['price'] * $exchangeRate, 2) }} ะปะฒ </div> @else {{-- Fallback pricing --}} @endif </div> ``` --- ## ๐Ÿ’ก Key Features ### 1. **Consistent with Venue Page:** - Uses the same exchange rate (1.95853) - Same formatting and display logic - Same dual currency approach ### 2. **Dynamic Pricing:** - Shows actual lowest price from venue objects - Falls back to random prices if no objects exist - Respects booking time unit (day, night, hour, etc.) ### 3. **Professional Display:** - EUR shown in larger, bold font - BGN shown below in slightly smaller font - Clear visual hierarchy - Maintains "From" label for clarity ### 4. **Responsive Design:** - Works in both grid and list views - Maintains proper spacing and alignment - Adapts to different screen sizes --- ## ๐Ÿ“ Example Calculations | EUR Price | BGN Price (ร—1.95853) | Display | |-----------|---------------------|---------| | โ‚ฌ50.00 | 97.93 ะปะฒ | โ‚ฌ50.00 /Night<br>97.93 ะปะฒ | | โ‚ฌ150.00 | 293.78 ะปะฒ | โ‚ฌ150.00 /Night<br>293.78 ะปะฒ | | โ‚ฌ300.00 | 587.56 ะปะฒ | โ‚ฌ300.00 /Night<br>587.56 ะปะฒ | --- ## ๐ŸŽจ Styling Details ### Grid View: - **"From" label:** `text-xs font-normal text-gray-500 mb-1` - **EUR price:** `text-lg font-bold text-gray-900` - **Time unit:** `text-sm font-normal text-gray-600` - **BGN price:** `text-sm font-medium text-gray-600` ### List View: - **"From" label:** `text-sm font-normal text-gray-500 mb-1` - **EUR price:** `text-2xl font-bold text-gray-900` - **Time unit:** `text-lg font-normal text-gray-600` - **BGN price:** `text-lg font-medium text-gray-600 mb-2` --- ## โœ… Benefits ### 1. **User Experience:** - Bulgarian users see prices in their local currency - International users see prices in EUR - No confusion about pricing ### 2. **Transparency:** - Clear conversion rate - No hidden fees - Consistent across platform ### 3. **Professional:** - Matches major booking platforms (Booking.com, Airbnb) - Industry-standard dual currency display - Clean, modern design ### 4. **Consistency:** - Same implementation as venue detail page - Uniform pricing display across platform - Predictable user experience --- ## ๐Ÿ” Testing Checklist - [ ] Grid view shows both EUR and BGN prices - [ ] List view shows both EUR and BGN prices - [ ] Prices calculate correctly (EUR ร— 1.95853 = BGN) - [ ] "From" label displays correctly - [ ] Time units show properly (day, night, hour, etc.) - [ ] Fallback prices work when no venue objects exist - [x] **Fallback prices are consistent (same venue = same price on refresh)** - [ ] Responsive design works on mobile - [ ] Prices align properly in both views - [ ] BGN uses correct Cyrillic "ะปะฒ" symbol - [ ] Number formatting is correct (2 decimal places) --- ## ๐ŸŒ Localization Notes ### Currency Symbols: - **EUR:** `โ‚ฌ` (Euro symbol) - **BGN:** `ะปะฒ` (Cyrillic "lv" - Bulgarian Lev) ### Number Formatting: - Both currencies use 2 decimal places - Uses `number_format($price, 2)` for consistency - No thousands separator in current implementation ### Translation Support: - "From" label uses `__('From')` for translation - Time units use `__($priceData['unit_label'])` for translation - Fully compatible with Laravel's i18n system --- ## ๐Ÿ”„ Future Enhancements ### Potential Improvements: 1. **Dynamic Exchange Rate:** - Fetch real-time rates from Bulgarian National Bank API - Update rates daily via scheduled task - Store in database or cache 2. **Currency Preference:** - Allow users to select preferred currency - Remember choice in session/cookie - Show only selected currency 3. **More Currencies:** - Add USD, GBP, etc. - Auto-detect user's country - Show relevant currency 4. **Formatting Options:** - Add thousands separator (e.g., 1,234.56) - Respect locale-specific formatting - Currency symbol position (before/after) --- ## ๐Ÿ“Š Summary **Changes Made:** โœ… Grid view shows EUR + BGN prices โœ… List view shows EUR + BGN prices โœ… Uses same exchange rate as venue page (1.95853) โœ… Maintains "From" label for clarity โœ… Respects booking time units โœ… Fallback pricing for venues without objects โœ… **Consistent fallback prices (seeded by venue ID)** โœ… Professional, clean design โœ… Fully responsive **Result:** Venue listings now display prices in both EUR and BGN, providing transparency and convenience for both local and international users. The implementation matches the venue detail page for consistency across the platform. **Bug Fix:** Fixed random price issue where fallback prices changed on every page refresh. Now uses `mt_srand($venue->id)` to ensure the same venue always shows the same fallback price consistently.