Skip to content

Fix newsletter subscription cleanup on customer update - #136

Merged
Touxten merged 1 commit into
PrestaShop:devfrom
Codencode:fix/135-customer-newsletter-update
Aug 28, 2026
Merged

Fix newsletter subscription cleanup on customer update#136
Touxten merged 1 commit into
PrestaShop:devfrom
Codencode:fix/135-customer-newsletter-update

Conversation

@Codencode

Copy link
Copy Markdown
Member
Questions Answers
Description? This PR fixes #135 by preserving existing emailsubscription records when a customer account is updated without changing the newsletter subscription status.

The customer is reloaded from the database to retrieve the newsletter state before the update, while the object received by the hook already contains the new value. Comparing both states allows the module to detect an actual newsletter subscription transition (0 -> 1) and remove the existing emailsubscription record only in that case.

I also added comments in both hookActionObjectCustomerUpdateBefore() and hookActionCustomerAccountUpdate() to clarify this behavior and make the relationship between the persisted newsletter state and the new customer state easier to understand.
Type? bug fix
BC breaks? no
Deprecations? no
Fixed ticket? Fixes #135
How to test? 1. Subscribe to the newsletter as a guest.
2. Create a customer account using the same email address without selecting the newsletter option.
3. Verify that the corresponding emailsubscription record is still present.
4. Update an unrelated customer field, such as the first name.
5. Verify that the emailsubscription record is preserved.
6. Enable the newsletter option from the customer account.
7. Verify that the emailsubscription record is removed and the customer newsletter status is enabled.

@ps-jarvis ps-jarvis moved this from Ready for review to To be tested in PR Dashboard Aug 26, 2026
@kpodemski kpodemski added the Waiting for QA by Community Status: Action required, Waiting for test feedback by Community label Aug 26, 2026
@Touxten Touxten self-assigned this Aug 28, 2026
@Touxten

Touxten commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

It's ok for me see video :

test-email.mp4

@Touxten Touxten added QA ✔️ Status: Check done, Code approved and removed Waiting for QA by Community Status: Action required, Waiting for test feedback by Community Waiting for QA labels Aug 28, 2026
@Touxten
Touxten merged commit 9240761 into PrestaShop:dev Aug 28, 2026
12 checks passed
@github-project-automation github-project-automation Bot moved this from To be tested to Merged in PR Dashboard Aug 28, 2026
@Codencode
Codencode deleted the fix/135-customer-newsletter-update branch August 28, 2026 09:19
@devmysz

devmysz commented Aug 28, 2026

Copy link
Copy Markdown

Thank you @Codencode for your PR.

QA ✅

Tested successfully.

Covered scenarios:

Existing newsletter subscriber → checkout as guest without newsletter consent:
emailsubscription preserved
customer.newsletter = 0
Guest/customer profile updated without changing newsletter consent:
emailsubscription preserved
customer.newsletter = 0
Guest converted to registered customer without newsletter consent:
emailsubscription preserved
customer.newsletter = 0
Customer account created during checkout without newsletter consent:
emailsubscription preserved
customer.newsletter = 0
Newsletter consent enabled later, both for guest during checkout and for registered customer:
emailsubscription entry removed
customer.newsletter = 1

@Touxten

Touxten commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

@devmysz I'm waiting for this PR, and then I'll release a new version of the module

@Codencode

Copy link
Copy Markdown
Member Author

@devmysz I'm waiting for this PR, and then I'll release a new version of the module

@Touxten, can we wait to resolve this issue: #121 (comment) before releasing the new version?

Keep in mind that if a new PR needs to be created or #121 needs to be modified, I'll do it right away.

@Touxten

Touxten commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Yes i wait Kristian comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

QA ✔️ Status: Check done, Code approved

Projects

Status: Merged

Development

Successfully merging this pull request may close these issues.

Existing newsletter subscription is removed when customer profile is updated

5 participants