Skip to content

Commit

Permalink
First release
Browse files Browse the repository at this point in the history
  • Loading branch information
sangnguyenplus committed Jul 10, 2024
0 parents commit ca42eda
Show file tree
Hide file tree
Showing 35 changed files with 1,006 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

All notable changes to `fob-floatting-buttons` will be documented in this file

## 1.0.0 - 2024-01-20

- First release 🥳
55 changes: 55 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Contributing

Contributions are **welcome** and will be fully **credited**.

Please read and understand the contribution guide before creating an issue or pull request.

## Etiquette

This project is open source, and as such, the maintainers give their free time to build and maintain the source code
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
extremely unfair for them to suffer abuse or anger for their hard work.

Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
world that developers are civilized and selfless people.

It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
quality to benefit the project. Many developers have different skill-sets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.

## Viability

When requesting or submitting new features, first consider whether it might be useful to others. Open
source projects are used by many developers, who may have entirely different needs to your own. Think about
whether your feature is likely to be used by other users of the project.

## Procedure

Before filing an issue:

- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
- Check to make sure your feature suggestion isn't already present within the project.
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
- Check the pull requests tab to ensure that the feature isn't already in progress.

Before submitting a pull request:

- Check the codebase to ensure that your feature doesn't already exist.
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.

## Requirements

If the project maintainer has any additional requirements, you will find them listed here.

- **[PSR-12 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-12-extended-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer).

- **Add tests!** - Your patch won't be accepted if it doesn't have tests.

- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.

- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.

- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.

- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.

**Happy coding**!
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Friends Of Botble

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# FOB Custom Fields for eCommerce

This plugin helps you to create custom fields in product details or checkout page for ecommerce on your website.

### Demo for product detail fields

![Screenshot](./art/screenshot-1.png)

![Screenshot](./art/screenshot-2.png)

![Screenshot](./art/screenshot-3.png)

![Screenshot](./art/screenshot-4.png)

![Screenshot](./art/screenshot-5.png)

### Demo for checkout fields

![Screenshot](./art/screenshot-6.png)

![Screenshot](./art/screenshot-7.png)

![Screenshot](./art/screenshot-8.png)

## Requirements

- Botble core 7.3.0 or higher.

## Installation

### Install via Admin Panel

Go to the **Admin Panel** and click on the **Plugins** tab. Click on the "Add new" button, find the **Custom Fields for eCommerce** plugin and click on the "Install" button.

### Install manually

1. Download the plugin from the [Botble Marketplace](https://marketplace.botble.com/products/friendsofbotble/fob-ecommerce-custom-field).
2. Extract the downloaded file and upload the extracted folder to the `platform/plugins` directory.
3. Go to **Admin** > **Plugins** and click on the **Activate** button.

## Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

## Contributing

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

## Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

## Credits

- [Friends Of Botble](https://github.com/FriendsOfBotble)
- [All Contributors](../../contributors)

## License

The MIT License (MIT). Please see [License File](LICENSE) for more information.
Binary file added art/screenshot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/screenshot-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/screenshot-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/screenshot-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/screenshot-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/screenshot-6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/screenshot-7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/screenshot-8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions config/permissions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

return [
[
'name' => 'Custom Fields for eCommerce',
'flag' => 'ecommerce-custom-fields.index',
],
[
'name' => 'Create',
'flag' => 'ecommerce-custom-fields.create',
'parent_flag' => 'ecommerce-custom-fields.index',
],
[
'name' => 'Edit',
'flag' => 'ecommerce-custom-fields.edit',
'parent_flag' => 'ecommerce-custom-fields.index',
],
[
'name' => 'Delete',
'flag' => 'ecommerce-custom-fields.destroy',
'parent_flag' => 'ecommerce-custom-fields.index',
],
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

use Botble\Base\Enums\BaseStatusEnum;
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::create('ec_custom_fields', function (Blueprint $table) {
$table->id();
$table->string('label');
$table->string('name');
$table->string('placeholder')->nullable();
$table->string('type', 60)->default('text');
$table->string('status', 60)->default(BaseStatusEnum::PUBLISHED);
$table->text('options')->nullable();
$table->string('display_location', 60);
$table->timestamps();
});

Schema::create('ec_custom_field_values', function (Blueprint $table) {
$table->id();
$table->foreignId('custom_field_id');
$table->morphs('model');
$table->text('value')->nullable();
$table->timestamps();
});

Schema::create('ec_custom_fields_translations', function (Blueprint $table) {
$table->foreignId('ec_custom_fields_id');
$table->string('lang_code');
$table->string('label')->nullable();
$table->string('placeholder')->nullable();
$table->text('options')->nullable();

$table->primary(['lang_code', 'ec_custom_fields_id']);
});
}

public function down(): void
{
Schema::dropIfExists('ec_custom_fields');
Schema::dropIfExists('ec_custom_field_values');
Schema::dropIfExists('ec_custom_fields_translations');
}
};
14 changes: 14 additions & 0 deletions plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"id": "friendsofbotble/ecommerce-custom-field",
"name": "Custom Fields for eCommerce",
"namespace": "FriendsOfBotble\\EcommerceCustomField\\",
"provider": "FriendsOfBotble\\EcommerceCustomField\\Providers\\EcommerceCustomFieldServiceProvider",
"author": "FriendsOfBotble",
"url": "https://friendsofbotble.com",
"version": "1.0.0",
"description": "Add custom fields to product details or checkout page for eCommerce scripts",
"minimum_core_version": "7.3.0",
"require": [
"botble/ecommerce"
]
}
32 changes: 32 additions & 0 deletions resources/lang/en/custom-field.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

return [
'dashboard_menu_label' => 'Custom Fields',
'name' => 'Custom Fields for eCommerce',
'create' => 'Create Custom Field',
'edit' => 'Edit Custom Field :name',
'label' => 'Label',
'value' => 'Value',
'label_helper' => 'The label of the field.',
'name_helper' => 'The alias of the field, accept only letters, numbers, and underscores.',
'placeholder' => 'Placeholder',
'placeholder_helper' => 'The placeholder of the field, this help user know what to enter.',
'type' => 'Type',
'options' => 'Options',
'option' => 'Option',
'display_location' => 'Display Location',
'display_location_helper' => 'Where to display this field.',
'display_locations' => [
'product' => 'Product Page',
'checkout' => 'Checkout Page',
],
'types' => [
'text' => 'Text',
'number' => 'Number',
'time' => 'Time',
'date' => 'Date',
'datetime' => 'Datetime',
'textarea' => 'Textarea',
'select' => 'Select',
],
];
8 changes: 8 additions & 0 deletions resources/views/cart-item.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<dl class="mt-1">
@foreach($customFields as $name => $value)
<div @class(['small d-flex gap-1', 'mb-1' => ! $loop->last])>
<dt>{{ $name }}:</dt>
<dd class="mb-0">{{ $value }}</dd>
</div>
@endforeach
</dl>
43 changes: 43 additions & 0 deletions resources/views/fields.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<div class="ec-custom-field-wrapper my-3">
@foreach($customFields as $key => $customField)
<div class="mb-3 ec-custom-field">
<label for="custom_fields-{{ $customField->getKey() }}" class="form-label ec-custom-field-label">{{ $customField->label }}</label>

@if (in_array($customField->type, ['text', 'number', 'date', 'time', 'datetime']))
<input
type="{{ $customField->type == 'datetime' ? 'datetime-local' : $customField->type }}"
name="extras[custom_fields][{{ $customField->getKey() }}]"
id="custom_fields-{{ $customField->getKey() }}"
class="form-control ec-custom-field-input"
@if ($customField->placeholder)
placeholder="{{ $customField->placeholder }}"
@endif
>
@elseif ($customField->type == 'textarea')
hehe
<textarea
name="extras[custom_fields][{{ $customField->getKey() }}]"
id="custom_fields-{{ $customField->getKey() }}"
class="form-control ec-custom-field-input"
rows="3"
@if($customField->placeholder)
placeholder="{{ $customField->placeholder }}"
@endif
></textarea>
@elseif ($customField->type == 'select')
<select
name="extras[custom_fields][{{ $customField->getKey() }}]"
id="custom_fields-{{ $customField->getKey() }}"
class="form-select ec-custom-field-input"
>
@if($customField->placeholder)
<option value="">{{ $customField->placeholder }}</option>
@endif
@foreach($customField->formatted_options as $key => $value)
<option value="{{ $key }}">{{ $value }}</option>
@endforeach
</select>
@endif
</div>
@endforeach
</div>
6 changes: 6 additions & 0 deletions resources/views/invoice.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@foreach($customFieldValues as $customFieldValue)
<p class="mb-1">
{{ $customFieldValue->customField->label }}:
<strong class="text-warning">{{ $customFieldValue->value }}</strong>
</p>
@endforeach
8 changes: 8 additions & 0 deletions resources/views/order-product.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<dl class="my-1">
@foreach($customFieldValues as $customFieldValue)
<div @class(['d-flex align-items-center gap-1', 'mb-1' => ! $loop->last])>
<dt>{{ $customFieldValue->customField->label }}:</dt>
<dd class="mb-0">{{ $customFieldValue->value }}</dd>
</div>
@endforeach
</dl>
10 changes: 10 additions & 0 deletions resources/views/order.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@foreach($customFieldValues as $customFieldValue)
<x-core::table.body.row>
<x-core::table.body.cell>
{{ $customFieldValue->customField->label }}
</x-core::table.body.cell>
<x-core::table.body.cell class="fw-bold">
{{ $customFieldValue->value }}
</x-core::table.body.cell>
</x-core::table.body.row>
@endforeach
10 changes: 10 additions & 0 deletions resources/views/thank-you.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<dl class="bg-body-secondary rounded p-2 mt-3">
<h6 class="mb-2">{{ __('Extra Information') }}</h6>

@foreach($customFieldValues as $customFieldValue)
<div @class(['d-flex align-items-center', 'mb-1' => ! $loop->last])>
<dt class="d-inline-block">{{ $customFieldValue->customField->label }}:</dt>
<dd class="order-customer-info-meta mb-0">{{ $customFieldValue->value }}</dd>
</div>
@endforeach
</dl>
11 changes: 11 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

use Botble\Base\Facades\AdminHelper;
use FriendsOfBotble\EcommerceCustomField\Http\Controllers\CustomFieldController;
use Illuminate\Support\Facades\Route;

AdminHelper::registerRoutes(function () {
Route::prefix('ecommerce-custom-fields')->name('ecommerce-custom-fields.')->group(function () {
Route::resource('', CustomFieldController::class)->parameters(['' => 'custom-field']);
});
});
13 changes: 13 additions & 0 deletions src/Contracts/CustomFieldValuable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace FriendsOfBotble\EcommerceCustomField\Contracts;

use Illuminate\Database\Eloquent\Relations\MorphMany;

/**
* @property-read \Illuminate\Database\Eloquent\Collection|\FriendsOfBotble\EcommerceCustomField\Models\CustomFieldValue[] $customFieldValues
*/
interface CustomFieldValuable
{
public function customFieldValues(): MorphMany;
}
Loading

0 comments on commit ca42eda

Please sign in to comment.