feat(tenant): add checkout editing policy
This commit is contained in:
@@ -2214,7 +2214,7 @@
|
||||
},
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"client_id\": {{client_id}},\n \"codigo\": \"{{tenant_code}}\",\n \"nombre\": \"Tenant Demo\",\n \"dominio\": \"{{tenant_domain}}\",\n \"site_title\": \"ShopIt Demo\",\n \"primary_color\": \"#111827\",\n \"secondary_color\": \"#2563EB\",\n \"danger_color\": \"#DC2626\",\n \"success_color\": \"#16A34A\",\n \"header_bg_color\": \"#FFFFFF\",\n \"footer_bg_color\": \"#111827\",\n \"header_logo\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==\",\n \"footer_logo\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==\",\n \"search_product_layout\": \"column_with_image\",\n \"search_group_layout\": \"paginated\",\n \"search_items_per_page\": 12,\n \"display_categories\": true,\n \"display_seach_bar\": true,\n \"display_cart\": true,\n \"cart_editing_policy\": \"full\",\n \"website_type_code\": \"shopit\"\n}",
|
||||
"raw": "{\n \"client_id\": {{client_id}},\n \"codigo\": \"{{tenant_code}}\",\n \"nombre\": \"Tenant Demo\",\n \"dominio\": \"{{tenant_domain}}\",\n \"site_title\": \"ShopIt Demo\",\n \"primary_color\": \"#111827\",\n \"secondary_color\": \"#2563EB\",\n \"danger_color\": \"#DC2626\",\n \"success_color\": \"#16A34A\",\n \"header_bg_color\": \"#FFFFFF\",\n \"footer_bg_color\": \"#111827\",\n \"header_logo\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==\",\n \"footer_logo\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==\",\n \"search_product_layout\": \"column_with_image\",\n \"search_group_layout\": \"paginated\",\n \"search_items_per_page\": 12,\n \"display_categories\": true,\n \"display_seach_bar\": true,\n \"display_cart\": true,\n \"cart_editing_policy\": \"full\",\n \"checkout_editing_policy\": \"full\",\n \"website_type_code\": \"shopit\"\n}",
|
||||
"options": {
|
||||
"raw": {
|
||||
"language": "json"
|
||||
@@ -2280,7 +2280,7 @@
|
||||
},
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"nombre\": \"Tenant Demo Actualizado\",\n \"site_title\": \"ShopIt Demo\",\n \"primary_color\": \"#111827\",\n \"cart_editing_policy\": \"full\"\n}",
|
||||
"raw": "{\n \"nombre\": \"Tenant Demo Actualizado\",\n \"site_title\": \"ShopIt Demo\",\n \"primary_color\": \"#111827\",\n \"cart_editing_policy\": \"full\",\n \"checkout_editing_policy\": \"full\"\n}",
|
||||
"options": {
|
||||
"raw": {
|
||||
"language": "json"
|
||||
@@ -2320,7 +2320,7 @@
|
||||
},
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"nombre\": \"Tenant Demo Actualizado\",\n \"site_title\": \"ShopIt Demo\",\n \"primary_color\": \"#111827\",\n \"cart_editing_policy\": \"full\"\n}",
|
||||
"raw": "{\n \"nombre\": \"Tenant Demo Actualizado\",\n \"site_title\": \"ShopIt Demo\",\n \"primary_color\": \"#111827\",\n \"cart_editing_policy\": \"full\",\n \"checkout_editing_policy\": \"full\"\n}",
|
||||
"options": {
|
||||
"raw": {
|
||||
"language": "json"
|
||||
|
||||
@@ -46,6 +46,7 @@ use Illuminate\Support\Facades\Schema;
|
||||
'display_seach_bar',
|
||||
'display_cart',
|
||||
'cart_editing_policy',
|
||||
'checkout_editing_policy',
|
||||
'display_cart_item_images',
|
||||
'scanner_category_validation_enabled',
|
||||
'event_title',
|
||||
@@ -65,6 +66,7 @@ class Tenant extends Model
|
||||
'display_seach_bar' => true,
|
||||
'display_cart' => true,
|
||||
'cart_editing_policy' => CartEditingPolicy::Full->value,
|
||||
'checkout_editing_policy' => CartEditingPolicy::Disabled->value,
|
||||
'display_cart_item_images' => true,
|
||||
'scanner_category_validation_enabled' => true,
|
||||
];
|
||||
@@ -116,6 +118,7 @@ class Tenant extends Model
|
||||
'display_seach_bar' => 'boolean',
|
||||
'display_cart' => 'boolean',
|
||||
'cart_editing_policy' => CartEditingPolicy::class,
|
||||
'checkout_editing_policy' => CartEditingPolicy::class,
|
||||
'display_cart_item_images' => 'boolean',
|
||||
'scanner_category_validation_enabled' => 'boolean',
|
||||
];
|
||||
|
||||
@@ -109,6 +109,7 @@ class StoreTenantRequest extends FormRequest
|
||||
'display_seach_bar' => ['sometimes', 'boolean'],
|
||||
'display_cart' => ['sometimes', 'boolean'],
|
||||
'cart_editing_policy' => ['sometimes', Rule::enum(CartEditingPolicy::class)],
|
||||
'checkout_editing_policy' => ['sometimes', Rule::enum(CartEditingPolicy::class)],
|
||||
'display_cart_item_images' => ['sometimes', 'boolean'],
|
||||
'scanner_category_validation_enabled' => ['sometimes', 'boolean'],
|
||||
'website_type_code' => [
|
||||
|
||||
@@ -130,6 +130,7 @@ class UpdateTenantRequest extends FormRequest
|
||||
'display_seach_bar' => ['sometimes', 'boolean'],
|
||||
'display_cart' => ['sometimes', 'boolean'],
|
||||
'cart_editing_policy' => ['sometimes', Rule::enum(CartEditingPolicy::class)],
|
||||
'checkout_editing_policy' => ['sometimes', Rule::enum(CartEditingPolicy::class)],
|
||||
'display_cart_item_images' => ['sometimes', 'boolean'],
|
||||
'scanner_category_validation_enabled' => ['sometimes', 'boolean'],
|
||||
];
|
||||
|
||||
@@ -76,6 +76,7 @@ class TenantResource extends JsonResource
|
||||
'display_seach_bar' => $this->display_seach_bar,
|
||||
'display_cart' => $this->display_cart,
|
||||
'cart_editing_policy' => CartEditingPolicyResource::make($this->cart_editing_policy),
|
||||
'checkout_editing_policy' => CartEditingPolicyResource::make($this->checkout_editing_policy),
|
||||
'display_cart_item_images' => $this->display_cart_item_images,
|
||||
'scanner_category_validation_enabled' => $this->scanner_category_validation_enabled,
|
||||
'social_media' => $this->whenLoaded(
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('tenants', function (Blueprint $table): void {
|
||||
$table->string('checkout_editing_policy')
|
||||
->default('disabled')
|
||||
->after('cart_editing_policy');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('tenants', function (Blueprint $table): void {
|
||||
$table->dropColumn('checkout_editing_policy');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -75,6 +75,7 @@ class DesfilePuraTendenciaSeeder extends Seeder
|
||||
'display_seach_bar' => false,
|
||||
'display_cart' => true,
|
||||
'cart_editing_policy' => 'disabled',
|
||||
'checkout_editing_policy' => 'disabled',
|
||||
'display_cart_item_images' => false,
|
||||
'scanner_category_validation_enabled' => false,
|
||||
'website_type_code' => 'onticket',
|
||||
|
||||
@@ -76,6 +76,7 @@ class TenantSeeder extends Seeder
|
||||
'display_seach_bar' => true,
|
||||
'display_cart' => true,
|
||||
'cart_editing_policy' => 'quantity_and_remove',
|
||||
'checkout_editing_policy' => 'disabled',
|
||||
'header_logo' => $this->uploadedImage('images/tennants/sonder/sonder_header.png', 'sonder_header.png'),
|
||||
'footer_logo' => $this->uploadedImage('images/tennants/sonder/sonder_footer.png', 'sonder_footer.png'),
|
||||
'social_media' => self::SOCIAL_MEDIA,
|
||||
@@ -133,6 +134,7 @@ class TenantSeeder extends Seeder
|
||||
'display_seach_bar' => false,
|
||||
'display_cart' => true,
|
||||
'cart_editing_policy' => 'full',
|
||||
'checkout_editing_policy' => 'disabled',
|
||||
'header_logo' => $this->uploadedImage(
|
||||
'images/tennants/fiesta_futbol_infantil/futbol_infantil_header.png',
|
||||
'futbol_infantil_header.png',
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Migrations;
|
||||
|
||||
use App\Domains\Tenant\Models\Tenant;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AddCheckoutEditingPolicyToTenantsTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_it_disables_checkout_editing_for_every_tenant(): void
|
||||
{
|
||||
Tenant::query()->where('codigo', 'sonder')->update([
|
||||
'cart_editing_policy' => 'disabled',
|
||||
]);
|
||||
Tenant::query()->where('codigo', 'fiesta_futbol_infantil')->update([
|
||||
'cart_editing_policy' => 'quantity_and_remove',
|
||||
]);
|
||||
|
||||
$migration = require database_path(
|
||||
'migrations/2026_08_20_000000_add_checkout_editing_policy_to_tenants.php'
|
||||
);
|
||||
|
||||
$migration->down();
|
||||
$migration->up();
|
||||
|
||||
$this->assertDatabaseHas('tenants', [
|
||||
'codigo' => 'sonder',
|
||||
'cart_editing_policy' => 'disabled',
|
||||
'checkout_editing_policy' => 'disabled',
|
||||
]);
|
||||
$this->assertDatabaseHas('tenants', [
|
||||
'codigo' => 'fiesta_futbol_infantil',
|
||||
'cart_editing_policy' => 'quantity_and_remove',
|
||||
'checkout_editing_policy' => 'disabled',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,7 @@ class DesfilePuraTendenciaSeederTest extends TestCase
|
||||
'display_categories' => false,
|
||||
'display_seach_bar' => false,
|
||||
'cart_editing_policy' => 'disabled',
|
||||
'checkout_editing_policy' => 'disabled',
|
||||
'display_cart_item_images' => false,
|
||||
'site_title' => 'Desfile Pura Tendencia',
|
||||
]);
|
||||
|
||||
@@ -62,6 +62,7 @@ class TenantSeederTest extends TestCase
|
||||
|
||||
$this->assertSame('shopit', $sonder->website_type_code);
|
||||
$this->assertSame('quantity_and_remove', $sonder->cart_editing_policy->value);
|
||||
$this->assertSame('disabled', $sonder->checkout_editing_policy->value);
|
||||
|
||||
$carousel = $sonder->websiteExtras
|
||||
->firstWhere('websiteTypeExtra.codigo', 'carousel');
|
||||
@@ -83,6 +84,7 @@ class TenantSeederTest extends TestCase
|
||||
|
||||
$this->assertSame('onticket', $fiesta->website_type_code);
|
||||
$this->assertSame('full', $fiesta->cart_editing_policy->value);
|
||||
$this->assertSame('disabled', $fiesta->checkout_editing_policy->value);
|
||||
|
||||
$extras = $fiesta->websiteExtras->keyBy('websiteTypeExtra.codigo');
|
||||
$this->assertEqualsCanonicalizing(
|
||||
|
||||
@@ -74,6 +74,7 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
'display_seach_bar' => false,
|
||||
'display_cart' => false,
|
||||
'cart_editing_policy' => 'disabled',
|
||||
'checkout_editing_policy' => 'quantity_and_remove',
|
||||
'display_cart_item_images' => false,
|
||||
]);
|
||||
|
||||
@@ -96,6 +97,11 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
->assertJsonPath('data.cart_editing_policy.allow_delete', false)
|
||||
->assertJsonPath('data.cart_editing_policy.allow_update_quantity', false)
|
||||
->assertJsonPath('data.cart_editing_policy.allow_update_variant', false)
|
||||
->assertJsonPath('data.checkout_editing_policy.code', 'quantity_and_remove')
|
||||
->assertJsonPath('data.checkout_editing_policy.allow_modify', true)
|
||||
->assertJsonPath('data.checkout_editing_policy.allow_delete', true)
|
||||
->assertJsonPath('data.checkout_editing_policy.allow_update_quantity', true)
|
||||
->assertJsonPath('data.checkout_editing_policy.allow_update_variant', false)
|
||||
->assertJsonPath('data.display_cart_item_images', false)
|
||||
->assertJsonPath('data.header_bg_color', '#ffffff')->assertJsonPath('data.footer_bg_color', '#ffffff');
|
||||
|
||||
@@ -763,6 +769,7 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
$response = $this->putJson("/api/tenants/{$tenant->codigo}", [
|
||||
'primary_color' => '#000000',
|
||||
'cart_editing_policy' => 'quantity_and_remove',
|
||||
'checkout_editing_policy' => 'disabled',
|
||||
'display_cart_item_images' => false,
|
||||
]);
|
||||
|
||||
@@ -776,6 +783,8 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
->assertJsonPath('data.cart_editing_policy.allow_delete', true)
|
||||
->assertJsonPath('data.cart_editing_policy.allow_update_quantity', true)
|
||||
->assertJsonPath('data.cart_editing_policy.allow_update_variant', false)
|
||||
->assertJsonPath('data.checkout_editing_policy.code', 'disabled')
|
||||
->assertJsonPath('data.checkout_editing_policy.allow_modify', false)
|
||||
->assertJsonPath('data.display_cart_item_images', false);
|
||||
|
||||
$this->assertDatabaseHas('tenants', [
|
||||
@@ -784,6 +793,7 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
'nombre' => 'Acme',
|
||||
'primary_color' => '#000000',
|
||||
'cart_editing_policy' => 'quantity_and_remove',
|
||||
'checkout_editing_policy' => 'disabled',
|
||||
'display_cart_item_images' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user