From 6d077647baedd8181bbe1fe9127edfe6f2359cd9 Mon Sep 17 00:00:00 2001 From: ncoronel Date: Mon, 21 Sep 2026 10:59:28 -0300 Subject: [PATCH] feat(storefront): configure checkout summary type --- .../Tenant/Models/StorefrontWebsiteType.php | 10 ++++++- .../Core/Tenant/Resources/TenantResource.php | 3 +++ .../Services/TenantInformationService.php | 3 ++- ...mmary_type_to_storefront_website_types.php | 27 +++++++++++++++++++ database/seeders/WebsiteTypeSeeder.php | 20 +++++++++++--- .../Feature/Seeders/WebsiteTypeSeederTest.php | 5 +++- .../Tenant/BootstrapTenantControllerTest.php | 4 ++- 7 files changed, 64 insertions(+), 8 deletions(-) create mode 100644 database/migrations/2026_09_21_030000_add_checkout_summary_type_to_storefront_website_types.php diff --git a/app/Domains/Core/Tenant/Models/StorefrontWebsiteType.php b/app/Domains/Core/Tenant/Models/StorefrontWebsiteType.php index f0872d9..2f31a91 100644 --- a/app/Domains/Core/Tenant/Models/StorefrontWebsiteType.php +++ b/app/Domains/Core/Tenant/Models/StorefrontWebsiteType.php @@ -7,13 +7,21 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; -#[Fillable(['codigo', 'nombre', 'header_type'])] +#[Fillable(['codigo', 'nombre', 'header_type', 'checkout_summary_type'])] class StorefrontWebsiteType extends Model { use HasFactory; + public const CHECKOUT_SUMMARY_DEFAULT = 'default'; + + public const CHECKOUT_SUMMARY_EVENT = 'event'; + protected $table = 'storefront_website_types'; + protected $attributes = [ + 'checkout_summary_type' => self::CHECKOUT_SUMMARY_DEFAULT, + ]; + /** @return HasMany */ public function extras(): HasMany { diff --git a/app/Domains/Core/Tenant/Resources/TenantResource.php b/app/Domains/Core/Tenant/Resources/TenantResource.php index 4bd3c2e..7094db4 100644 --- a/app/Domains/Core/Tenant/Resources/TenantResource.php +++ b/app/Domains/Core/Tenant/Resources/TenantResource.php @@ -4,6 +4,7 @@ namespace App\Domains\Core\Tenant\Resources; use App\Domains\Commerce\Catalog\Models\Category; use App\Domains\Core\Menu\Models\Menu; +use App\Domains\Core\Tenant\Models\StorefrontWebsiteType; use App\Domains\Core\Tenant\Models\Tenant; use App\Domains\Ticketing\Event\Models\Event; use App\Domains\Ticketing\Event\Models\EventDate; @@ -50,6 +51,8 @@ class TenantResource extends JsonResource 'admin_website_type_code' => $this->admin_website_type_code, 'storefront_website_type_code' => $this->storefront_website_type_code, 'header_type' => $this->storefrontWebsiteType?->header_type ?? 'standard', + 'checkout_summary_type' => $this->storefrontWebsiteType?->checkout_summary_type + ?? StorefrontWebsiteType::CHECKOUT_SUMMARY_DEFAULT, 'active_event_id' => $this->active_event_id, 'event' => $this->whenLoaded('activeEvent', fn () => $this->activeEvent === null ? null : $this->formatEvent($this->activeEvent, $eventDateChanges)), diff --git a/app/Domains/Core/Tenant/Services/TenantInformationService.php b/app/Domains/Core/Tenant/Services/TenantInformationService.php index bd34194..fcbdcba 100644 --- a/app/Domains/Core/Tenant/Services/TenantInformationService.php +++ b/app/Domains/Core/Tenant/Services/TenantInformationService.php @@ -2,9 +2,9 @@ namespace App\Domains\Core\Tenant\Services; -use App\Shared\Attachable\Models\Attachment; use App\Domains\Core\Tenant\Models\Tenant; use App\Domains\Core\Tenant\Models\WebsiteExtra; +use App\Shared\Attachable\Models\Attachment; use Illuminate\Database\Eloquent\Collection as EloquentCollection; use Illuminate\Support\Collection; @@ -16,6 +16,7 @@ class TenantInformationService 'favicon', 'headerBackgroundImage', 'footerBackgroundImage', + 'storefrontWebsiteType', 'socialMedia', 'websiteExtras.websiteTypeExtra', 'activeEvent.dates', diff --git a/database/migrations/2026_09_21_030000_add_checkout_summary_type_to_storefront_website_types.php b/database/migrations/2026_09_21_030000_add_checkout_summary_type_to_storefront_website_types.php new file mode 100644 index 0000000..cc7cd72 --- /dev/null +++ b/database/migrations/2026_09_21_030000_add_checkout_summary_type_to_storefront_website_types.php @@ -0,0 +1,27 @@ +string('checkout_summary_type')->default('default')->after('header_type'); + }); + + DB::table('storefront_website_types') + ->where('codigo', 'onticket_multi_event') + ->update(['checkout_summary_type' => 'event']); + } + + public function down(): void + { + Schema::table('storefront_website_types', function (Blueprint $table): void { + $table->dropColumn('checkout_summary_type'); + }); + } +}; diff --git a/database/seeders/WebsiteTypeSeeder.php b/database/seeders/WebsiteTypeSeeder.php index 7847d56..230a876 100644 --- a/database/seeders/WebsiteTypeSeeder.php +++ b/database/seeders/WebsiteTypeSeeder.php @@ -2,8 +2,8 @@ namespace Database\Seeders; -use App\Domains\Core\Tenant\Services\AdminWebsiteTypeService; use App\Domains\Core\Tenant\Models\StorefrontWebsiteType; +use App\Domains\Core\Tenant\Services\AdminWebsiteTypeService; use Illuminate\Database\Seeder; use Illuminate\Http\UploadedFile; use RuntimeException; @@ -56,7 +56,11 @@ class WebsiteTypeSeeder extends Seeder $shopItStorefront = StorefrontWebsiteType::query()->updateOrCreate( ['codigo' => 'shopit'], - ['nombre' => 'ShopIt', 'header_type' => 'standard'], + [ + 'nombre' => 'ShopIt', + 'header_type' => 'standard', + 'checkout_summary_type' => StorefrontWebsiteType::CHECKOUT_SUMMARY_DEFAULT, + ], ); $shopItStorefront->extras()->updateOrCreate( @@ -85,12 +89,20 @@ class WebsiteTypeSeeder extends Seeder $onTicketStorefront = StorefrontWebsiteType::query()->updateOrCreate( ['codigo' => 'onticket'], - ['nombre' => 'OnTicket - evento único', 'header_type' => 'standard'], + [ + 'nombre' => 'OnTicket - evento único', + 'header_type' => 'standard', + 'checkout_summary_type' => StorefrontWebsiteType::CHECKOUT_SUMMARY_DEFAULT, + ], ); $multiEventStorefront = StorefrontWebsiteType::query()->updateOrCreate( ['codigo' => 'onticket_multi_event'], - ['nombre' => 'OnTicket - múltiples eventos', 'header_type' => 'immersive'], + [ + 'nombre' => 'OnTicket - múltiples eventos', + 'header_type' => 'immersive', + 'checkout_summary_type' => StorefrontWebsiteType::CHECKOUT_SUMMARY_EVENT, + ], ); $multiEventStorefront->extras()->updateOrCreate( diff --git a/tests/Feature/Seeders/WebsiteTypeSeederTest.php b/tests/Feature/Seeders/WebsiteTypeSeederTest.php index 3851d8a..2678ca3 100644 --- a/tests/Feature/Seeders/WebsiteTypeSeederTest.php +++ b/tests/Feature/Seeders/WebsiteTypeSeederTest.php @@ -2,9 +2,9 @@ namespace Tests\Feature\Seeders; -use App\Shared\Attachable\Models\Attachment; use App\Domains\Core\Tenant\Models\AdminWebsiteType; use App\Domains\Core\Tenant\Models\StorefrontWebsiteType; +use App\Shared\Attachable\Models\Attachment; use Database\Seeders\WebsiteTypeSeeder; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\Storage; @@ -54,6 +54,7 @@ class WebsiteTypeSeederTest extends TestCase Storage::disk('s3')->assertExists($shopIt->favicon->path); $shopItStorefront = StorefrontWebsiteType::query()->where('codigo', 'shopit')->with('extras')->sole(); $this->assertSame('standard', $shopItStorefront->header_type); + $this->assertSame(StorefrontWebsiteType::CHECKOUT_SUMMARY_DEFAULT, $shopItStorefront->checkout_summary_type); $this->assertSame(['carousel'], $shopItStorefront->extras->pluck('codigo')->all()); $this->assertSame('Carrusel principal', $shopItStorefront->extras->sole()->nombre); $this->assertSame([ @@ -87,8 +88,10 @@ class WebsiteTypeSeederTest extends TestCase $this->assertSame('onticket_favicon.svg', $onTicket->favicon->filename); $onTicketStorefront = StorefrontWebsiteType::query()->where('codigo', 'onticket')->with('extras')->sole(); $this->assertSame('standard', $onTicketStorefront->header_type); + $this->assertSame(StorefrontWebsiteType::CHECKOUT_SUMMARY_DEFAULT, $onTicketStorefront->checkout_summary_type); $multiEventStorefront = StorefrontWebsiteType::query()->where('codigo', 'onticket_multi_event')->with('extras')->sole(); $this->assertSame('immersive', $multiEventStorefront->header_type); + $this->assertSame(StorefrontWebsiteType::CHECKOUT_SUMMARY_EVENT, $multiEventStorefront->checkout_summary_type); $this->assertEqualsCanonicalizing(['immersiveHeroCarousel', 'immersiveHero'], $multiEventStorefront->extras->pluck('codigo')->all()); $this->assertSame($shopItStorefront->extras->sole()->config_schema, $multiEventStorefront->extras->firstWhere('codigo', 'immersiveHeroCarousel')->config_schema); $this->assertEqualsCanonicalizing( diff --git a/tests/Feature/Tenant/BootstrapTenantControllerTest.php b/tests/Feature/Tenant/BootstrapTenantControllerTest.php index 7ad8228..b4c4fdc 100644 --- a/tests/Feature/Tenant/BootstrapTenantControllerTest.php +++ b/tests/Feature/Tenant/BootstrapTenantControllerTest.php @@ -37,7 +37,8 @@ class BootstrapTenantControllerTest extends TestCase ->assertJsonCount(1, 'data.event_categories') ->assertJsonPath('data.event_categories.0.id', $eventCategory->id) ->assertJsonPath('data.event_categories.0.nombre', 'Música') - ->assertJsonPath('data.event_categories.0.subcategories', []); + ->assertJsonPath('data.event_categories.0.subcategories', []) + ->assertJsonPath('data.checkout_summary_type', StorefrontWebsiteType::CHECKOUT_SUMMARY_EVENT); } public function test_it_bootstraps_a_tenant_by_domain(): void @@ -125,6 +126,7 @@ class BootstrapTenantControllerTest extends TestCase ->assertJsonPath('data.checkout_editing_policy.allow_delete', false) ->assertJsonPath('data.checkout_editing_policy.allow_update_quantity', false) ->assertJsonPath('data.checkout_editing_policy.allow_update_variant', false) + ->assertJsonPath('data.checkout_summary_type', StorefrontWebsiteType::CHECKOUT_SUMMARY_DEFAULT) ->assertJsonPath('data.display_cart_item_images', false) ->assertJsonPath('data.header_bg_color', '#ffffff')->assertJsonPath('data.footer_bg_color', '#ffffff');