feat(storefront): configure checkout summary type
This commit is contained in:
@@ -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<StorefrontWebsiteTypeExtra, $this> */
|
||||
public function extras(): HasMany
|
||||
{
|
||||
|
||||
@@ -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)),
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('storefront_website_types', function (Blueprint $table): void {
|
||||
$table->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');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user