Skip to content

Commit

Permalink
Module init
Browse files Browse the repository at this point in the history
  • Loading branch information
Marvin-Magmodules committed Sep 4, 2023
0 parents commit 2a3b8a4
Show file tree
Hide file tree
Showing 9 changed files with 779 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea/*
.DS_Store
96 changes: 96 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@

![shopreview](https://github.com/magmodules/magento2-shopreview-hyva/assets/24823946/25bf88eb-c629-46e6-bcf3-3053bc6dbbca)

# Shopreviews Hyvä Compatibility plugin


Shopreview is a powerful Magento extension for collecting and managing customer reviews. It offers full control over review forms, keeps reviews in-house, and provides customizable widgets for seamless integration into your store. With a one-time payment and no monthly subscription costs, it's a cost-effective solution for enhancing your online shop's reputation and customer trust.

The Shopreviews compatibility plugin for the Magento Hyvä theme has the following requirements:
- [Magento 2.4.+](https://github.com/magento/magento2)
- [Hyvä](https://github.com/hyva-themes)
- [Magmodules Shopreviews](https://www.magmodules.eu/magento2-shopreview.html)


## About the Shopreviews Plugin

Enhance your Magento store's reputation with our comprehensive store reviews extension. Our Shopreview extension allows you to effortlessly collect, manage, and showcase customer feedback. With features like import and export functions, you have full control, ensuring reviews stay in-house. Positive customer reviews provide powerful 'Social proof' to boost trust and drive sales in your Magento store.

Shopreview for Magento empowers you to customize review forms to your liking. As an admin, you can add, modify, or remove fields, set mandatory requirements, and define placeholders. Our extension seamlessly integrates with default front-end styles, ensuring your review forms blend seamlessly with your template. Plus, there are no ongoing monthly subscription costs – it's a one-time purchase for long-term benefits. Elevate your store's reputation with Shopreview for Magento today.

## Installation

1. Install the module using composer:

```bash
composer require magmodules/magento2-shopreview-hyva
```

2. Enable the module:

```bash
bin/magento module:enable Magmodules_HyvaShopreview
```

3. Upgrade the database:

```bash
bin/magento setup:upgrade
```

4. Let Hyvä know about the new module:

```bash
php bin/magento hyva:config:generate
```

5. Generate the CSS files:

```bash
npm --prefix vendor/hyva-themes/magento2-default-theme/web/tailwind/ run ci
npm --prefix vendor/hyva-themes/magento2-default-theme/web/tailwind/ run build-prod
```

Or from your theme:

```bash
npm --prefix app/design/frontend/<Vendor>/<Theme>/web/tailwind run ci
npm --prefix app/design/frontend/<Vendor>/<Theme>/web/tailwind run build-prod
```

## Shopreviews Magento plugin features

- Seamless integration
- Full Form control
- Customizable review widgets
- Rich snippet integration
- Review moderation and management

## Magento Support

If you have any questions, please fill out our secure contact form by clicking [here](https://www.magmodules.eu/support-form.html).

## Magmodules & Hyva

Magmodules and Hyva have established a strong partnership, working closely together to provide enhanced e-commerce solutions. As an official Hyva partner, we specializes in developing integrations for various platforms and services.

We have created integrations for well-known providers such as Mollie, Sooqr, Paazl, and many more. This collaboration ensures seamless compatibility and optimized performance for online stores utilizing the Hyva theme. Through our partnership, Magmodules and Hyva strive to deliver comprehensive and tailored solutions to meet the diverse needs of e-commerce businesses.






## Checkout our other Hyva Plugins!

[- Magento 2 Hyvä Shopreview](#)

[- Magento 2 Hyvä Product Review Reminder](#)

[- Magento 2 Hyvä Mollie React Checkout](#)

[- Magento 2 Hyvä Checkout](#)

[- Magento 2 Hyvä Mollie React Checkout](#)

[- Magento 2 Hyvä Paazl](#)
22 changes: 22 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "magmodules/magento2-hyva-shopreview",
"description": "Hyvä Themes Compatibility module for Magmodules Shopreview",
"type": "magento2-module",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"require": {
"magento/framework": "*",
"hyva-themes/magento2-compat-module-fallback": "*",
"magmodules/magento2-shopreview": "*"
},
"autoload": {
"files": [
"src/registration.php"
],
"psr-4": {
"Magmodules\\HyvaShopreview\\": "src/"
}
}
}
14 changes: 14 additions & 0 deletions src/etc/frontend/di.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Hyva\CompatModuleFallback\Model\CompatModuleRegistry">
<arguments>
<argument name="compatModules" xsi:type="array">
<item name="magmodules-magento2-hyva-shopreview" xsi:type="array">
<item name="original_module" xsi:type="string">Magmodules_Shopreview</item>
<item name="compat_module" xsi:type="string">Magmodules_HyvaShopreview</item>
</item>
</argument>
</arguments>
</type>
</config>
17 changes: 17 additions & 0 deletions src/etc/module.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" ?>
<!--
/**
* Hyvä Themes - https://hyva.io
* Copyright © Hyvä Themes 2020-present. All rights reserved.
* This product is licensed per Magento install
* See https://hyva.io/license
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magmodules_HyvaShopreview">
<sequence>
<module name="Magmodules_Shopreview"/>
<module name="Hyva_CompatModuleFallback"/>
</sequence>
</module>
</config>
11 changes: 11 additions & 0 deletions src/registration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
/**
* Hyvä Themes - https://hyva.io
* Copyright © Hyvä Themes 2020-present. All rights reserved.
* This product is licensed per Magento install
* See https://hyva.io/license
*/

use Magento\Framework\Component\ComponentRegistrar;

ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magmodules_HyvaShopreview', __DIR__);
154 changes: 154 additions & 0 deletions src/view/frontend/templates/form/view.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<?php
/**
* Copyright © Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/
?>
<?php
// $formId = $block->getData('form_id');
$formId = '1';

/* @var \Magmodules\Shopreview\ViewModel\Form\View $viewModel */
$viewModel = $block->getViewModel();

if ($formId) {
$viewModel->setFormId($formId);
}

/* @var \Magmodules\Shopreview\Api\Form\DataInterface $form */
$form = $viewModel->getForm();
$description = $viewModel->getFormOption($form, 'description');
?>


<?= /* @noEscape */ $viewModel->renderDescription($description); ?>

<?php if (!$formId): ?>
<form class="review-form"
name='review[<?= $block->escapeHtml($form->getId()) ?>]'
id="review-form"
action="<?= $block->escapeUrl($block->getUrl('shopreview/form/save')) ?>">
<?php endif ?>

<input name='form_id' value="<?= $block->escapeHtml($form->getId()) ?>" type="hidden"/>
<input name='store_id' value="<?= $block->escapeHtml($viewModel->getStoreId()) ?>" type="hidden"/>

<div class="fieldset review-fieldset grid gap-2">
<?php foreach ($form->getFields((int)$viewModel->getStoreId()) as $field): ?>
<?php if (!$viewModel->getFieldOption($field, 'enabled')) {
continue;
} ?>

<?php
$is_required = $viewModel->getFieldOption($field, 'required');
$field_id = $field->getId();
$field_title = $viewModel->getFieldOption($field, 'title');
$field_validation_msg = $viewModel->getFieldOption($field, 'validation');
$field_placeholder = $viewModel->getFieldOption($field, 'placeholder');
$fieldOptions = $viewModel->getFieldOption($field, 'options');
?>

<?php switch ($field->getType()):
case 'text': ?>

<div class="review-field-<?= $block->escapeHtml($field_id); ?>">
<label class="sr-only label" for="field_<?= $block->escapeHtml($field_id); ?>">
<?= $block->escapeHtml($field_title) ?>
</label>
<div class="control">
<input
id="field_<?= $block->escapeHtml($field_id); ?>"
class="form-input text-sm w-full max-w-md"
name="field[<?= $block->escapeHtml($field_id); ?>]"
type="text"
placeholder="<?= $field_placeholder
? $block->escapeHtml($field_placeholder)
: $block->escapeHtml($field_title); ?> <?= $is_required ? '*' : '' ?>"
<?= $is_required ? 'required' : '' ?>
data-msg-required="<?= $block->escapeHtml($field_validation_msg); ?>"
/>
</div>
</div>

<?php break;
case 'select': ?>
<!-- There is no such type, but it was described in the module -->
<?php break;
case 'textarea': ?>

<div class="review-field-<?= $block->escapeHtml($field_id) ?>">
<label class="sr-only label" for="field_<?= $block->escapeHtml($field_id); ?>">
<?= $block->escapeHtml($field_title) ?>
</label>
<div class="control">
<textarea
rows="5"
id="field_<?= $block->escapeHtml($field_id); ?>"
class="form-input text-sm w-full max-w-md"
name="field[<?= $block->escapeHtml($field_id) ?>]"
placeholder="<?= $field_placeholder
? $block->escapeHtml($field_placeholder)
: $block->escapeHtml($field_title); ?> <?= $is_required ? '*' : '' ?>"
<?= $is_required ? 'required' : '' ?>
data-msg-required="<?= $block->escapeHtml($field_validation_msg); ?>"></textarea>
</div>
</div>
<?php break;
case 'rating': ?>

<div class="review-field-<?= $block->escapeHtml($field_id); ?> sm:flex sm:items-center">
<label class="pr-5 text-sm !mb-0"
id="review-field-rating-<?= $block->escapeHtml($field_id) ?>">
<?= $block->escapeHtml($field_title) . ':'; ?>
</label>

<div class="flex flex-row grow-0 -ml-1" x-data="{ clickedRatingId: 0, focusId: 0 }">
<?php $start = $viewModel->getFieldOption($field, 'stars'); ?>
<?php for ($i = 1; $i <= $start; $i++): ?>
<?php
$fieldId = sprintf('field_%s_%s', $field_id, $i);
$for = sprintf('field_%s_%s', $field_id, $i);
?>

<div class="relative"
@click="clickedRatingId = <?= $i ?> || 0"
@mouseover="focusId = <?= $i ?> || 0"
@mouseleave="focusId = 0">

<input type="radio"
class="absolute opacity-0 bottom-0 left-0 cursor-pointer"
name="field[<?= $block->escapeHtml($field_id); ?>]"
id="<?= $block->escapeHtml($fieldId) ?>"
value="<?= $block->escapeHtml($i); ?>"
<?= $is_required ? 'required' : '' ?>>

<label
class="rating-<?= $block->escapeHtml($i) ?> m-0 cursor-pointer text-gray-400"
for="<?= $block->escapeHtml($for) ?>"
title="<?= $block->escapeHtml($i) ?> star">

<span class="text-stone-200"
:class="<?= $i ?> <= focusId ? '!text-yellow-400' : '' ">
<span class="transition-colors duration-300"
:class="<?= $i ?> <= clickedRatingId ? 'text-yellow-400' : '' ">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="w-8 h-8">
<path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"></path>
</svg>
</span>
</sapn>
</label>
</div>
<?php endfor; ?>
</div>
</div>
<?php endswitch; ?>

<?php endforeach; ?>
</div>

<?php if (!$formId): ?>
<button type="submit" name="submit" class="btn btn-primary mt-3">
<?= $block->escapeHtml(__('Save review')) ?>
</button>
</form>
<?php endif ?>
Loading

0 comments on commit 2a3b8a4

Please sign in to comment.