Skip to content

[Issue] Move SetGuestEmailOnCart logic in a separated class #40398

@m2-assistant

Description

@m2-assistant

This issue is automatically created based on existing pull request: #40395: Move SetGuestEmailOnCart logic in a separated class


Description (*)

This PR refactors the setGuestEmailOnCart GraphQL mutation by extracting business logic from the resolver into a dedicated model class, improving code organization and testability.

Changes

  • New Model Class: Created Magento\QuoteGraphQl\Model\Cart\SetGuestEmailOnCart to handle the business logic of setting guest email on cart
  • Refactored Resolver: Updated Magento\QuoteGraphQl\Model\Resolver\SetGuestEmailOnCart to delegate business logic to the new model class
  • Unit Tests: Added comprehensive unit test coverage for the new model class (SetGuestEmailOnCartTest)

Motivation

The objective of this modification is to be able to more easily add logic (such as a custom control) before saving the email.

Today, the only solution is to make a beforeExecute plugin on the SetShippingMethodsOnCart class without benefiting from the controls already in place.

Manual testing scenarios (*)

Execute the graphQL setGuestEmailOnCart mutation, it must not have an error.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

Metadata

Metadata

Assignees

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions