Fix: Guarding against order status, fixing store details render in email
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Modules\Core\Store\Services;
|
||||
|
||||
use Filament\Forms\Components\RichEditor\RichContentRenderer;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Lunar\Models\Language;
|
||||
@@ -45,6 +46,13 @@ class StoreDetailsService
|
||||
* arrived). Null also when the store hasn't filled the field in for
|
||||
* $locale, so the caller's own @if($bankTransferInstructions) guard
|
||||
* covers both cases identically.
|
||||
*
|
||||
* bank_transfer_instructions is a TranslatedRichEditor field (see
|
||||
* ManageStoreDetails), so translate() returns Filament's Tiptap JSON
|
||||
* document structure for that locale, not a plain string —
|
||||
* RichContentRenderer::make() is Filament's own converter from that
|
||||
* structure to sanitized HTML (the same one the admin panel itself
|
||||
* uses to render a RichEditor's content read-only).
|
||||
*/
|
||||
public function bankTransferInstructionsFor(Order $order, string $locale): ?string
|
||||
{
|
||||
@@ -52,7 +60,13 @@ class StoreDetailsService
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->current()->translate('bank_transfer_instructions', $locale) ?: null;
|
||||
$content = $this->current()->translate('bank_transfer_instructions', $locale);
|
||||
|
||||
if (blank($content)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return RichContentRenderer::make($content)->toHtml();
|
||||
}
|
||||
|
||||
public function update(array $attributes): StoreDetails
|
||||
|
||||
Reference in New Issue
Block a user