Skip to content

Commit

Permalink
PrestaShop 8.x support #57
Browse files Browse the repository at this point in the history
This is a full rewrite of the module to reflect the new PrestaShop architecture and use the latest patterns. This change allows adopting patterns required by newer versions of PrestaShop and makes further updates less time-consuming.

The most noticeable changed functionality is that the module now uses the PrestaShop Newsletter Subscriptions modules rendered form for Opt-In subscribers collection instead of providing its form UI. This allows keeping built-in subscription logic while still sending new subscribers to Smaily.

- Update wordings in issue templates, readmes, contributor guides, etc.
- Add composer install in GH workflows release step
- Update pictures of the module
- Use `prestashop-flashlight` image for dev environment
- Add `mailhog` service to the dev environment
- Use services, namespaced classes, and routes configuration introduced in PrestaShop 8.x
- Refactor code to separate functionality into smaller units
- Improve RSS feed by using the `DOMDocument` library to build RSS-feed items
- Reduce the amount of JS required by the module
- Use Twig as a templating engine for module templates
  • Loading branch information
sinukaarel authored May 27, 2024
2 parents b794170 + 60396e4 commit a165861
Show file tree
Hide file tree
Showing 103 changed files with 6,929 additions and 2,372 deletions.
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ A clear and concise description of what actually happened.
**Screenshots**
If applicable, add screenshots to help explain your problem.

**Prestashop version**
Add the Prestashop version you are currently using.
**PrestaShop version**
Add the PrestaShop version you are currently using.

**Module version**
Add the Smaily For Prestashop module version you are currently using.
Add the Smaily For PrestaShop module version you are currently using.

**Additional context**
Add any other context about the problem here.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ A list of changes regarding the next version release:
**After PR merge**

- [ ] Released new version in GitHub
- [ ] Updated plugin on the Prestashop Addons Marketplace
- [ ] Updated plugin on the PrestaShop Addons Marketplace
- [ ] Pinged code owners to inform marketing about new version
11 changes: 11 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,22 @@ jobs:
- name: Rename src directory
run: mv ./src ./smailyforprestashop

- name: Install dependencies
uses: php-actions/composer@v6
with:
dev: no
progress: yes
working_dir: smailyforprestashop

- name: Compress ZIP
uses: TheDoctor0/zip-release@v0.3.0
with:
filename: release.zip
path: smailyforprestashop
exclusions: >
/.git*
/.php-cs-fixer.dist.php
/.phpstan.neon
- name: Get release
id: get_release_url
Expand Down
31 changes: 0 additions & 31 deletions .sandbox/entrypoint.sh

This file was deleted.

9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"aswinkumar863.smarty-template-support",
"mblode.twig-language-2",
"junstyle.php-cs-fixer",
"devsense.phptools-vscode",
"streetsidesoftware.code-spell-checker"
]
}
12 changes: 12 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"[php]": {
"editor.defaultFormatter": "junstyle.php-cs-fixer"
},
"editor.formatOnSave": true,
"files.associations": {
"*.html": "twig"
},
"emmet.includeLanguages": {
"twig": "html"
},
}
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

### 2.0.0

- Total rewrite of the module to support PrestaShop 8 new features and standards. [[#57](https://github.com/sendsmaily/smaily-prestashop-module/pull/57)]
- Module now uses the built-in Newsletter Subscription module to provide functionality for opt-in trigger instead of creating a custom template. This allows to keep internal subscriber addition logic and add required opt-in trigger functionality.

### 1.6.1

- Update user manual links [[#51](https://github.com/sendsmaily/smaily-prestashop-module/pull/51)]
Expand All @@ -12,7 +17,7 @@

- New feature to trigger opt-in if new customer joins with newsletter enabled [[#32](https://github.com/sendsmaily/smaily-prestashop-module/issues/32)]
- Fix missing template variables [[#33](https://github.com/sendsmaily/smaily-prestashop-module/issues/33)]
- Use PrestashopLogger for logs created by module [[#36](https://github.com/sendsmaily/smaily-prestashop-module/issues/36)]
- Use PrestaShopLogger for logs created by module [[#36](https://github.com/sendsmaily/smaily-prestashop-module/issues/36)]

### 1.4.0

Expand Down
59 changes: 40 additions & 19 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
First off, thanks for taking the time to contribute!


# Table of contents

- [Getting started](#getting-started)
- [Internals](#internals))
- [Structure of the repository](#structure-of-the-repository)
- [Internals](#internals)
- [Structure of the repository](#structure-of-the-repository)
- [Deveopment](#development)
- [Starting the environement](#starting-the-environment)
- [Stopping the environment](#stopping-the-environment)
- [Resetting the environment](#resetting-the-environment)

- [Starting the environement](#starting-the-environment)
- [Stopping the environment](#stopping-the-environment)
- [Resetting the environment](#resetting-the-environment)

# Getting started

Expand All @@ -24,16 +22,17 @@ Next, change your working directory to the local repository:

$ cd smaily-prestashop-module

And run the environment:
Install composer dependencies:

$ docker-compose up
$ composer install --working-dir src/

When running the enviroment for the first time, PrestaShop installation will automatically run, and it can take a while.
And run the environment:

Once installation has finished and web server is ready to accept requests, you can access PrestaShop store from `http://localhost:8080` and administration interface from `http://localhost:8080/admin1` URL.
$ docker compose up -d

> Administrator user is `admin@smaily.sandbox` and password `smailydev1`.
You can access PrestaShop store from `http://localhost:8080` and administration interface from `http://localhost:8080/admin-dev` URL.

> Administrator user is `admin@prestashop.com` and password `prestashop`.
# Internals

Expand All @@ -42,33 +41,55 @@ Once installation has finished and web server is ready to accept requests, you c
The repository is split into multiple parts:

- `.github` - GitHub issue and pull request templates, and release workflow;
- `.sandbox` - files needed for running the development environment;
- `assets` - images for the user guide;
- `src` - module files;

Source files must follow standard PrestaShop module structure. Learn more about it from the [Modules Folder structure](https://devdocs.prestashop.com/1.7/modules/creation/module-file-structure/) chapter in the official documentation.

Source files must follow standard PrestaShop module structure. Learn more about it from the [Modules Folder structure](https://devdocs.prestashop-project.org/8/modules/creation/module-file-structure/) chapter in the official documentation.

# Development

All written code must follow PrestaShop's [coding standards](https://devdocs.prestashop.com/1.7/development/coding-standards/) and [naming conventions](https://devdocs.prestashop.com/1.7/development/naming-conventions/).
All written code must follow PrestaShop's [coding standards](https://devdocs.prestashop-project.org/8/development/coding-standards/) and [naming conventions](https://devdocs.prestashop-project.org/8/development/naming-conventions/).

## Starting the environment

You can run the environment by executing:

$ docker-compose up
$ docker compose up -d

> **Note!** Make sure you do not have any other process(es) listening on ports 8080 and 8888.
### Developing in VS Code Remote Container

It is advised to develop the application inside VS Code remote container. This allows to get PHP IntelliSense on PrestaShop classes, includes, etc and provides an debugging option when using latest version of the `prestashop/prestashop-flashlight` image. Open `/var/www/html` directory of `prestashop` container as this provides context for IntelliSense.

## Stopping the environment

Environment can be stopped by executing:

$ docker-compose down
$ docker compose down --remove-orphans

## Resetting the environment

If you need to reset the installation, just simply delete environment's Docker volumes. Easiest way to achieve this is by running:

$ docker-compose down -v
$ docker compose down --remove-orphans -v

## Troubleshooting

### PHP CS Fixer is not working

You may notice that `php-cs-fixer` might not work for some PrestaShop image versions. `php-cs-fixer` output provides a hint that the `/var/www/html/tests` directory does not exist. This is due to the `tests` folder being included in the [PrestaShop repo](https://github.com/PrestaShop/PrestaShop) but not in the docker image. Adding an empty `/var/www/heml/tests` folder enables the `php-cs-fixer`.

## Invalidating cache

There seems to be lot of issues related to cache being invalid. Sometimes the module routes are not found or services configuration is missing etc. Most of them can be fixed by pruning cache folder located in `/var/www/html/var/cache/dev`. Some versions use `admin-dev` folder.

## Translating the module and Extracting translations

PrestaShop allows to extract and translate the module in the admin panel.

First you need to import the localization pack for the translatable language. Navigate to `International` > `Localization` and import the localization pack you want the module to be translated to.

To translate the module navigate to `International` > `Translations`. Under `Modify translations` section select `Installed modules translations` as the type, `Smaily for PrestaShop`.

Export the module translations and add them to `translations` directory.
7 changes: 0 additions & 7 deletions Dockerfile

This file was deleted.

62 changes: 28 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,91 +1,85 @@
# Smaily for Prestashop
# Smaily for PrestaShop

## Description

Smaily email marketing and automation extension module for PrestaShop.

Automatically subscribe newsletter subscribers to a Smaily subscribers list, generate rss-feed based on products for easy template import and add Newsletter Subscribtion form for opt-in sign-up form.
Automatically subscribe newsletter subscribers to a Smaily subscribers list, generate an RSS feed based on products for easy template import and add a Newsletter Subscription form for an opt-in sign-up form.

## Features

### PrestaShop Newsletter Subscribers

- Add subscribers to Smaily subscribers list
- Add new Subscribe Newsletter form to send subscribers directly to Smaily subscribers list
- Use the Subscribe Newsletter modules form to send subscribers directly to the Smaily subscribers list
- Subscribe Newsletter form with CAPTCHA support

### PrestaShop Products RSS-feed

- Generate RSS-feed with 50 latest updated active products for easy import to Smaily template
Generate an RSS feed with the 50 latest updated active products for easy import to the Smaily template

### Two-way synchronization between Smaily and PrestaShop

- Get unsubscribers from Smaily unsubscribed list
- Remove PrestaShop subscribers based on the Smaily unsubscribed list
- Update unsubscribed status in PrestaShop users database
- Collect new user data for subscribed users
- Collect and send new user data to Smaily for subscribers in the store
- Generate data log for each update

### Abandoned cart

- Get customer abandoned cart info and send recovery e-mails with Smaily templates.
- Set prefered delay time when cart is considered abandoned.
- Set preferred delay time when the cart is considered abandoned.

## Requirements

Smaily for Prestashop requires PHP 5.6+ (PHP 7.0+ recommended). You'll also need to be running Prestashop 1.7+.
Smaily for PrestaShop requires PHP 7.2+ (PHP 8.1+ recommended). You'll also need to be running PrestaShop 8.0+.

## Documentation & Support

Online documentation and code samples are available via our [Help Center](https://smaily.com/help/user-manuals/).

## Contribute

All development for Smaily for Prestashop is [handled via GitHub](https://github.com/sendsmaily/smaily-prestashop-module). Opening new issues and submitting pull requests are welcome.
All development for Smaily for PrestaShop is [handled via GitHub](https://github.com/sendsmaily/smaily-prestashop-module). Opening new issues and submitting pull requests are welcome.

## Installation

1. Upload or extract the `smailyforprestashop` folder to your site's `/modules/` directory. You can also find this module in **Modules -> Selection** - section in your admin panel - search for Smaily for Prestashop.
2. Install the plugin from the **Modules** - menu in Prestashop.
1. Upload or extract the `smailyforprestashop` folder to your site's `/modules/` directory. You can also find this module in **Modules -> Selection** - section in your admin panel - search for Smaily for PrestaShop.
2. Install the plugin from the **Modules** - menu in PrestaShop.

## Usage

1. Go to Modules -> Module Manager -> Smaily for Prestashop and click Configure
2. Insert your Smaily API authentication information and click **Validate** to get started.
3. Under **Customer Synchronization** tab select if you want to enable customer synchronization.
4. Select additional fields you want to synchronize (email is automatic), change cron token if you like your own.
5. New customers who sign up with newsletter enabled can be added to Smaily by enabling trigger opt-in on customer signup.
1. Go to Modules -> Module Manager -> Smaily for PrestaShop and click Configure
2. Insert your Smaily API authentication information and click **Connect** to get started.
3. Under the **Customer Sync** tab select if you want to enable customer synchronization.
4. Select additional fields you want to synchronize (email is automatic) and change the cron token if you like your own.
5. New customers who sign up with the newsletter enabled can be added to Smaily by enabling trigger opt-in on customer signup.
6. An autoresponder can be selected for "opt-in on customer sign-up", this will only be triggered if the previous option is enabled.
7. Click **Save** to save customer synchronization settings.
8. Under **Abandoned Cart** tab select if you want to enable abandoned cart synchronization.
8. Under the **Abandoned Cart** tab select if you want to enable abandoned cart synchronization.
9. Select autoresponder for abandoned cart.
10. Select additional fields to send to abandoned cart template. Firstname, lastname and store-url are always added.
11. Add delay time when cart is considered abandoned. Minimum time 15 minutes. Change cron token if you like your own.
10. Select additional fields to send to the abandoned cart template. Firstname, lastname and store-url are always added.
11. Add delay time when the cart is considered abandoned. Minimum time 15 minutes. Change the cron token if you like your own.
12. Click **Save** to save abandoned cart settings.
13. Cron is set up to synchronize contacts when CRON-url is visited. Use host Cpanel, PrestaShop Cron tasks manager or external cron service to automate process.
14. That's it, your PrestaShop store is now integrated with Smaily Plugin!
13. Cron is set up to synchronize contacts when cron-URL is visited. Use host cPanel, PrestaShop cron tasks manager or external cron service to automate the process.
14. That's it, your PrestaShop store is now integrated with the Smaily Plugin!

## Using Newsletter Subscription form
## Using the Newsletter Subscription form

1. Navigate to Design -> Positions -> Transplant a Module section.
2. Select **Smaily for Prestashop** module in Module field.
3. Select hook where you would like to transplant newsletter form. You can chose FooterBefore / LeftColumn / RightColumn.
4. New form is displayed when you have validated your credentials in Smaily for Opencart module settings.
2. Select the **Newsletter subscription** module in the Module field.
3. Select a hook where you would like to transplant the newsletter form.

## Frequently Asked Questions

### Where I can find data-log for Cron?
### How can I access additional Abandoned cart parameters in the Smaily template editor?

Cron update data-log is stored in the root folder of Smaily plugin, inside "smaily-cron.txt" file.

### How can I access additional Abandoned cart parameters in Smaily template editor?

Here is a list of all the parameters available in Smaily email templating engine:
Here is a list of all the parameters available in the Smaily email templating engine:

Customer first name: `{{ first_name }}`.

Customer last name: `{{ last_name }}`.

Up to 10 products can be received in Smaily templating engine. You can reference each product with number 1-10 behind parameter name.
Up to 10 products can be received in the Smaily templating engine. You can reference each product with a number 1-10 behind the parameter name.

Product name: `{{ product_name_[1-10] }}`.

Expand All @@ -99,6 +93,6 @@ Product price: `{{ product_price_[1-10] }}`.

Product base price : `{{ product_base_price_[1-10] }}`.

Also you can determine if customer had more than 10 items in cart
Also, you can determine if a customer had more than 10 items in the cart

More than 10 items: `{{ over_10_products }}`.
Loading

0 comments on commit a165861

Please sign in to comment.