Skip to content

Fix customerId always returning null in Cart API responses#41364

Open
axel-paillaud wants to merge 1 commit into
PrestaShop:9.1.xfrom
axel-paillaud:fix/add_missing_customer_id_field
Open

Fix customerId always returning null in Cart API responses#41364
axel-paillaud wants to merge 1 commit into
PrestaShop:9.1.xfrom
axel-paillaud:fix/add_missing_customer_id_field

Conversation

@axel-paillaud
Copy link
Copy Markdown
Contributor

@axel-paillaud axel-paillaud commented Apr 30, 2026

Questions Answers
Branch? 9.1.x
Description? Fix missing customerId in GetCartForOrderCreation query result
Type? bug fix
Category? CO
BC breaks? no
Deprecations? no
How to test? Call the Cart-POST create endpoint with a customer ID. The response body now correctly returns the customer ID instead of null.
UI Tests https://github.com/axel-paillaud/ga.tests.ui.pr/actions/runs/25147314600
Fixed issue or discussion? Fix Admin API endpoint Cart response customer id = null (in progress)
Related PRs If theme, autoupgrade or other module change is needed to make this change work, provide a link to related PRs here.
Sponsor company axel-paillaud

The Cart API resource exposes a customerId field, but it was always null in responses
(GET /carts/{cartId} and POST /carts).

Screenshot_2026-04-30_06-13-36

The root cause was in CartForOrderCreation, the query result returned by GetCartForOrderCreation:
it did not include the customer ID at all. Since API Platform maps query result getters to the
resource properties by name, the field was present in the response but never populated.

The fix adds customerId to CartForOrderCreation (property, constructor parameter, and getter),
and updates GetCartForOrderCreationHandler to pass $cart->id_customer when building the result

Screenshot_2026-04-30_06-12-00

Cart endpoints available here

@axel-paillaud axel-paillaud requested a review from a team as a code owner April 30, 2026 04:24
@github-project-automation github-project-automation Bot moved this to Ready for review in PR Dashboard Apr 30, 2026
@ps-jarvis
Copy link
Copy Markdown

Hi, thanks for this contribution!

Please consider opening an issue before submitting a Pull Request:

  • If it's a bug fix, it helps maintainers verify that the bug is effectively due to a defect in the code, and that it hasn't been fixed already.
  • It can help trigger a discussion about the best implementation path before a single line of code is written.
  • It may lead the Core Product team to mark that issue as a priority, further attracting the maintainers' attention.

(Note: this is an automated message, but answering it will reach a real human)

@ps-jarvis ps-jarvis added Bug fix Type: Bug fix 9.1.x Branch labels Apr 30, 2026
@github-actions github-actions Bot added this to the 9.1.2 milestone Apr 30, 2026
@Progi1984 Progi1984 modified the milestones: 9.1.2, 9.1.3 May 13, 2026
@Progi1984 Progi1984 modified the milestones: 9.1.3, 9.1.4 May 21, 2026
Copy link
Copy Markdown
Contributor

@Hlavtox Hlavtox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BC break, you are adding required parameters

@ps-jarvis ps-jarvis added the Waiting for author Status: action required, waiting for author feedback label Jun 1, 2026
@ps-jarvis ps-jarvis moved this from Ready for review to Waiting for author in PR Dashboard Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

9.1.x Branch Bug fix Type: Bug fix Waiting for author Status: action required, waiting for author feedback

Projects

Status: Waiting for author

Development

Successfully merging this pull request may close these issues.

4 participants