diff --git a/database/migrations/2023_12_27_190234_ecommerce_structure_tables.php b/database/migrations/2023_12_27_190234_ecommerce_structure_tables.php index edaa32b..775d8e2 100644 --- a/database/migrations/2023_12_27_190234_ecommerce_structure_tables.php +++ b/database/migrations/2023_12_27_190234_ecommerce_structure_tables.php @@ -63,6 +63,7 @@ public function up(): void */ Schema::create('s_products', function (Blueprint $table) { $table->id('id'); + $table->uuid('uuid')->default(DB::raw('(UUID())')); $table->unsignedTinyInteger('published')->default(0)->index()->comment('0-Unpublished|1-Published'); $table->unsignedTinyInteger('availability')->default(0)->index()->comment('0-Not available|1-In stock|2-On order'); $table->string('sku')->index()->comment('It is the SKU Product code'); @@ -71,11 +72,15 @@ public function up(): void $table->unsignedInteger('views')->default(0)->index()->comment('Count view the product'); $table->unsignedInteger('rating')->default(5)->index()->comment('Rating the product base on votes'); $table->unsignedInteger('type')->default(0)->comment('Type the product'); - $table->unsignedDecimal('price_regular', 9, 2)->default(0); - $table->unsignedDecimal('price_special', 9, 2)->default(0); - $table->unsignedDecimal('price_opt_regular', 9, 2)->default(0); - $table->unsignedDecimal('price_opt_special', 9, 2)->default(0); - $table->unsignedDecimal('weight', 11, 4)->default(0); + $table->unsignedDecimal('price_regular', 9, 2)->default(0)->comment('The regular price of the product'); + $table->unsignedDecimal('price_special', 9, 2)->default(0)->comment('The special price of the product'); + $table->unsignedDecimal('price_opt_regular', 9, 2)->default(0)->comment('The wholesale price of the product'); + $table->unsignedDecimal('price_opt_special', 9, 2)->default(0)->comment('The special wholesale price of the product'); + $table->unsignedDecimal('weight', 11, 4)->default(0)->comment('The weight of production is indicated if necessary for technical purposes'); + $table->unsignedDecimal('width', 11, 4)->default(0)->comment('The width of production is indicated if necessary for technical purposes'); + $table->unsignedDecimal('height', 11, 4)->default(0)->comment('The height of production is indicated if necessary for technical needs'); + $table->unsignedDecimal('length', 11, 4)->default(0)->comment('The length of production is indicated if necessary for technical needs'); + $table->unsignedDecimal('volume', 11, 4)->default(0)->comment('The volume of production is indicated if necessary for technical needs'); $table->integer('quantity')->default(0)->comment('Quantity products in stock'); $table->char('currency', 3)->default('USD')->comment('Currency price this product'); $table->string('cover', 512)->default('')->comment('Cover image file link'); diff --git a/lang/en/global.php b/lang/en/global.php index 57d0e30..1377791 100644 --- a/lang/en/global.php +++ b/lang/en/global.php @@ -51,6 +51,7 @@ "finish_configuring" => "Finish configuring the module according to the instructions.", "gallery" => "File gallery", "gallery_help" => "The first image of the gallery is used as a product preview. You can sort the images by moving them with the mouse.", + "height" => "Height", "helptext" => "Help text", "helptext_help" => "Description about this Attribute in adminpanel.", "icon" => "fa fa-store", @@ -68,6 +69,7 @@ "items_on_page" => "Items on the page", "key" => "Key", "key_help" => "The key must have a unique value. Only lowercase Latin characters, numbers, and dashes are supported.", + "length" => "Length", "list_texts" => "List of texts", "main_currency" => "Main currency", "main_currency_help" => "The store's base currency, which is default used.", @@ -123,6 +125,7 @@ "published_help" => "Mark to publish immediately after saving.", "publisheds" => "Published", "quantity" => "Quantity", + "quantity_help" => "Shows the remaining stock of the product.", "quantity_on_help" => "Enable the product balance functionality.", "rating" => "Rating", "rating_on_help" => "Enable product rating calculation functionality.", @@ -149,6 +152,7 @@ "sortproducts_help" => "Sorting products by position in a category", "sortproducts_icon" => "fa fa-sort", "text_block" => "Text block", + "technical_parameter_for_delivery" => "technical parameter of the product that can be taken into account during delivery.", "title" => "Commerce", "to_list_attributes" => "To list attributes", "to_list_products" => "To list products", @@ -179,7 +183,10 @@ "views_on_help" => "Enable product views counter functionality.", "visibility" => "Visibility", "visual_editor_for" => "Visual editor for", + "volume" => "Volume", "websites" => "Websites", + "weight" => "Weight", + "width" => "Width", "with_id" => "With ID", "you_sure" => "Are you sure?", "you_sure_duplicate" => "Are you sure you want to duplicate?", diff --git a/lang/ru/global.php b/lang/ru/global.php index 1785d69..bdeba94 100644 --- a/lang/ru/global.php +++ b/lang/ru/global.php @@ -51,6 +51,7 @@ "finish_configuring" => "Завершите настройку модуля согласно инструкции.", "gallery" => "Галерея файлов", "gallery_help" => "Первое изображение галереи используется в качестве превью товара. Вы можете сортировать изображение путем их перемещения мышкой.", + "height" => "Высота", "helptext" => "Справочный текст", "helptext_help" => "Описание этого атрибута в палитре администратора.", "icon" => "fa fa-store", @@ -68,6 +69,7 @@ "items_on_page" => "Записей на странице", "key" => "Ключ", "key_help" => "Ключ должен иметь уникальное значение. Поддерживаются только символы латинского алфавита в нижнем регистре, цифры и тире.", + "length" => "Длина", "list_texts" => "Список текстов", "main_currency" => "Основная валюта", "main_currency_help" => "Базовая валюта магазина, которая используется по умолчанию.", @@ -123,6 +125,7 @@ "published_help" => "Отметьте что бы опубликовать сразу после сохранения.", "publisheds" => "Опубликованых", "quantity" => "Остаток", + "quantity_help" => "Показывает остаток товара на складе.", "quantity_on_help" => "Включить функционал остатка товаров.", "rating" => "Рейтинг", "rating_on_help" => "Включить функционал подсчета рейтинга продукта.", @@ -149,6 +152,7 @@ "sortproducts_help" => "Сортировка товаров по позиции в категории", "sortproducts_icon" => "fa fa-sort", "text_block" => "Текстовый блок", + "technical_parameter_for_delivery" => "технический параметр товара, который можно учитывать при доставке.", "title" => "Коммерция", "to_list_attributes" => "К списку атрибутов", "to_list_products" => "К списоку товаров", @@ -179,7 +183,10 @@ "views_on_help" => "Включить функционал подсчета просмотров товара.", "visibility" => "Видимость", "visual_editor_for" => "Визуальный редактор для", + "volume" => "Объем", "websites" => "Сайти", + "weight" => "Вес", + "width" => "Ширина", "with_id" => "с ID", "you_sure" => "Вы уверены, что хотите удалить запись", "you_sure_copy" => "Вы уверены, что хотите скопировать запись", diff --git a/lang/uk/global.php b/lang/uk/global.php index df49b48..279f7e0 100644 --- a/lang/uk/global.php +++ b/lang/uk/global.php @@ -51,6 +51,7 @@ "finish_configuring" => "Завершіть налаштування модуля згідно інструкції.", "gallery" => "Галерея файлів", "gallery_help" => "Перше зображення галереї використовується в якості превю товара. Ви маєте можливість сортувати зображення шляхом їх переміщення мишкою.", + "height" => "Висота", "helptext" => "Довідковий текст", "helptext_help" => "Опис цього атрибута в панелі адміністратора.", "icon" => "fa fa-store", @@ -68,6 +69,7 @@ "items_on_page" => "Записів на сторінці", "key" => "Ключ", "key_help" => "Ключ має мати унікальне значення. Підтримуються лише символи латинського алфавіту в нижньому регістрі, цифри та тире.", + "length" => "Довжина", "list_texts" => "Список текстів", "main_currency" => "Основна валюта", "main_currency_help" => "Базова валюта магазину, що використовується типово.", @@ -123,6 +125,7 @@ "published_help" => "Відзначте, щоб опублікувати відразу після збереження.", "publisheds" => "Опублікованих", "quantity" => "Залишок", + "quantity_help" => "Показує залишок товару на складі.", "quantity_on_help" => "Ввімкнути функціонал залишку товарів.", "rating" => "Рейтинг", "rating_on_help" => "Ввімкнути функціонал підрахунку рейтингу товара.", @@ -148,6 +151,7 @@ "sortproducts" => "Сортування за позицією", "sortproducts_help" => "Сортування товарів за позицією в категорії ", "sortproducts_icon" => "fa fa-sort", + "technical_parameter_for_delivery" => "технічний параметр товару, який можна враховувати під час доставки.", "text_block" => "Текстовий блок", "title" => "Комерція", "to_list_attributes" => "До списку атрибутів", @@ -179,7 +183,10 @@ "views_on_help" => "Ввімкнути функціонал підрахунку переглядів товару.", "visibility" => "Видимість", "visual_editor_for" => "Візуальний редактор для", + "volume" => "Об'єм", "websites" => "Сайти", + "weight" => "Вага", + "width" => "Ширина", "with_id" => "з ID", "you_sure" => "Ви впевнені, що хочете видалити запис", "you_sure_copy" => "Ви впевнені, що хочете скопіювати запис", diff --git a/module/sCommerceModule.php b/module/sCommerceModule.php index 242e592..d99e01b 100644 --- a/module/sCommerceModule.php +++ b/module/sCommerceModule.php @@ -264,7 +264,11 @@ $product->price_opt_regular = $sCommerceController->validatePrice(request()->input('price_opt_regular', 0)); $product->price_opt_special = $sCommerceController->validatePrice(request()->input('price_opt_special', 0)); $product->currency = request()->input('currency', sCommerce::config('basic.main_currency', 'USD')); - $product->weight = (float)request()->input('weight', 0); + $product->weight = $sCommerceController->validateNumber(request()->input('weight', 0)); + $product->width = $sCommerceController->validateNumber(request()->input('width', 0)); + $product->height = $sCommerceController->validateNumber(request()->input('height', 0)); + $product->length = $sCommerceController->validateNumber(request()->input('length', 0)); + $product->volume = $sCommerceController->validateNumber(request()->input('volume', 0)); $product->cover = str_replace(MODX_SITE_URL, '', $cover->src ?? '/assets/site/noimage.png'); $product->relevants = json_encode(request()->input('relevants', [])); $product->similar = json_encode(request()->input('similar', [])); @@ -344,6 +348,10 @@ $newProduct->price_opt_special = $product->price_opt_special; $newProduct->currency = $product->currency; $newProduct->weight = $product->weight; + $newProduct->width = $product->width; + $newProduct->height = $product->height; + $newProduct->length = $product->length; + $newProduct->volume = $product->volume; $newProduct->cover = $product->cover; $newProduct->relevants = $product->relevants; $newProduct->similar = $product->similar; diff --git a/src/Controllers/sCommerceController.php b/src/Controllers/sCommerceController.php index bc48e3f..57f6271 100644 --- a/src/Controllers/sCommerceController.php +++ b/src/Controllers/sCommerceController.php @@ -410,6 +410,24 @@ public function removeDirRecursive(string $dir): void rmdir($dir); } + /** + * Validate and sanitize a number value. + * + * @param mixed $number The number value to be validated. + * @return int|float The validated and sanitized price value. + */ + public function validateNumber(mixed $number): int|float + { + $validateNumber = 0; + $number = str_replace(',', '.', $number); + + if (is_numeric($number)) { + $number = intval($number) == floatval($number) ? intval($number) : floatval($number); + } + + return $number; + } + /** * Validate and sanitize a price value. * diff --git a/views/productTab.blade.php b/views/productTab.blade.php index eefcc9a..8de38a6 100644 --- a/views/productTab.blade.php +++ b/views/productTab.blade.php @@ -141,7 +141,7 @@
- +
@@ -232,10 +232,7 @@
@endif - -
-
- @if(sCommerce::config('product.show_field_relevant', 1) == 1) + @if(sCommerce::config('product.show_field_relevant', 1))
@@ -255,6 +252,76 @@
@endif
+ @if(sCommerce::config('product.show_field_weight', 1) || sCommerce::config('product.show_field_width', 1) || sCommerce::config('product.show_field_height', 1) || sCommerce::config('product.show_field_length', 1) || sCommerce::config('product.show_field_volume', 1)) +
+
+ @if(sCommerce::config('product.show_field_weight', 1)) +
+
+
+ + +
+
+ +
+
+
+ @endif + @if(sCommerce::config('product.show_field_width', 1)) +
+
+
+ + +
+
+ +
+
+
+ @endif + @if(sCommerce::config('product.show_field_height', 1)) +
+
+
+ + +
+
+ +
+
+
+ @endif + @if(sCommerce::config('product.show_field_length', 1)) +
+
+
+ + +
+
+ +
+
+
+ @endif + @if(sCommerce::config('product.show_field_volume', 1)) +
+
+
+ + +
+
+ +
+
+
+ @endif +
+ @endif
@php($mainAttributes = sCommerce::config('constructor.main_product', [])) @if(count($mainAttributes)) diff --git a/views/productsTab.blade.php b/views/productsTab.blade.php index 36c9540..289693f 100644 --- a/views/productsTab.blade.php +++ b/views/productsTab.blade.php @@ -94,6 +94,31 @@ class="form-control rounded-left scom-input seiger__search" @endif + @if (sCommerce::config('products.show_field_weight', 1) && sCommerce::config('product.show_field_weight', 1)) + + + + @endif + @if (sCommerce::config('products.show_field_width', 1) && sCommerce::config('product.show_field_width', 1)) + + + + @endif + @if (sCommerce::config('products.show_field_height', 1) && sCommerce::config('product.show_field_height', 1)) + + + + @endif + @if (sCommerce::config('products.show_field_length', 1) && sCommerce::config('product.show_field_length', 1)) + + + + @endif + @if (sCommerce::config('products.show_field_volume', 1) && sCommerce::config('product.show_field_volume', 1)) + + + + @endif @if (sCommerce::config('products.show_field_visibility', 1) == 1) @@ -186,6 +211,21 @@ class="form-control rounded-left scom-input seiger__search" @endforeach @endif + @if (sCommerce::config('products.show_field_weight', 1) && sCommerce::config('product.show_field_weight', 1)) + {{round($item->weight, 4)}} + @endif + @if (sCommerce::config('products.show_field_width', 1) && sCommerce::config('product.show_field_width', 1)) + {{round($item->width, 4)}} + @endif + @if (sCommerce::config('products.show_field_height', 1) && sCommerce::config('product.show_field_height', 1)) + {{round($item->height, 4)}} + @endif + @if (sCommerce::config('products.show_field_length', 1) && sCommerce::config('product.show_field_length', 1)) + {{round($item->length, 4)}} + @endif + @if (sCommerce::config('products.show_field_volume', 1) && sCommerce::config('product.show_field_volume', 1)) + {{round($item->volume, 4)}} + @endif @if (sCommerce::config('products.show_field_visibility', 1) == 1) @if($item->published) diff --git a/views/settingsTab.blade.php b/views/settingsTab.blade.php index 4a97593..85f3aa8 100644 --- a/views/settingsTab.blade.php +++ b/views/settingsTab.blade.php @@ -271,6 +271,19 @@

@lang('sCommerce::global.management_product_functionality')

+
+
+ + +
+
+ +
+
@@ -386,15 +399,52 @@
- - + +
-
- +
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ +
@@ -511,6 +561,56 @@
@endif +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+