Skip to content

Migrate the remaining commerce.client call sites to ep.* functions #540

Description

@field123

Parent

#553 — Spec: one session for Elastic Path identity

What to build

The mechanical bulk of the migration: eight internal data hooks stop fetching through the
browser's Elastic Path client and fetch through the server instead. A shopper and a designer
should be unable to tell this happened — same data, same components, same behaviour.

Two components that call the server by raw string name are corrected to go through the wrapper
that chooses the transport, so that no call site names one.

Spec stories 23, 25.

Acceptance criteria

  • Products, product lists, related products, stock, store locations and the three bundle reads all still render exactly as before, with no request from the browser to Elastic Path.
  • No component names a transport or a raw operation string; every call goes through the wrapper that decides.
  • Adding an item to the basket and removing one still work from the components that do it today.
  • The server-side cart actions provider works on the replacement operations rather than on hooks that are about to be deleted.
  • Nothing here is visible to a designer: no registered prop, slot or component changes.

Blocked by

The tracker's dependency graph on this issue is authoritative; this list mirrors it.


Below is the original ticket, kept intact — it carries the research and decisions from #486, #495, #523 and #524.

In brief

The mechanical bulk of the migration, and none of it is visible to a designer or a shopper.

Eight internal data hooks — product, product list, related products, stock, locations, and three bundle hooks — still fetch through the browser's Elastic Path client. This switches them to the equivalent server functions.

Two components also call the server by raw string name instead of going through the normal wrapper, which bypasses the layer that picks the right transport. Those are corrected here too.

Part of the ADR-0003 token architecture. Sized on #495, rule from #491.

Why

Internal work: the hooks are not exported and the components above them do not change. This is the bulk of the "twelve commerce.client call sites" and it is not breaking.

Work

Move to the isomorphic ep.* functions: use-product, use-product-list, use-related-products, use-stock, use-locations, and the three bundle hooks.

Two call sites bypass the isomorphic wrapper and call callEpProxy by raw string name — registerEPAddToCartButton.tsx:175 and EPCartItemRemoveButton.tsx:85. Under ADR-0003 those are defects: call epAddCartItem / epRemoveCartItem.

Once no component passes a raw name, proxy-fn-parity.test.ts shrinks to guarding the ep.* functions' own internal calls.

ServerCartActionsProvider is rebuilt on epAddCartItem / epUpdateCartItem / epRemoveCartItem; it currently sits entirely on hooks that are being deleted.

Blocked by: the new named functions issue and the server-side headers issue.


ADR-0003: plasmicpkgs/commerce-providers/elastic-path/docs/adr/0003-one-session-for-elastic-path-identity.md. Map: #486. Issue set: #496.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestready-for-agentScoped tracer-bullet slice, ready for an agent to pick up

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions