Skip to content

fix(ep-commerce): mark EPProductProvider as providesData#332

Merged
field123 merged 1 commit into
masterfrom
fix/ep-product-provider-provides-data
May 26, 2026
Merged

fix(ep-commerce): mark EPProductProvider as providesData#332
field123 merged 1 commit into
masterfrom
fix/ep-product-provider-provides-data

Conversation

@field123
Copy link
Copy Markdown
Collaborator

Summary

  • One-line meta fix on EPProductProvider: providesData: true.
  • Without it Plasmic compiles the component's children slot inline at the parent's render scope, so $ctx.currentProduct.* bindings inside the slot evaluate where currentProduct doesn't exist yet (the <DataProvider name="currentProduct"> the component publishes only takes effect for descendants).
  • With it, the compiler wraps the slot in a descendant function-component with its own useDataEnv()currentProduct resolves correctly and PDPs that wire product to a Plasmic Server Query ($q.<name>.data) actually render the product data instead of throwing TypeError: Cannot read properties of undefined (reading 'name').
  • Matches every sibling data-providing component in the same package (EPCartProvider, EPBundleProvider, EPVariationPicker, EPProductListProvider, etc. — all 11 already declare providesData: true). Looks like the flag was simply missed when EPProductProvider was first added.

Test plan

  • In a consumer app with a Plasmic page whose EPProductProvider.product is bound to $q.<query>.data (Server Query returning a Product), pre-fix: page render throws Cannot read properties of undefined (reading 'name') from any binding inside the provider's slot.
  • After this fix + a rebuild of @elasticpath/plasmic-ep-commerce-elastic-path, the same page renders the product's name, description, price, image etc. correctly.
  • Existing consumers of EPProductProvider that use the legacy client-fetch path (productId prop, no product prop binding) keep working — providesData: true is purely additive at the Studio code-gen level and doesn't change runtime behaviour for the component itself.

Without this flag Plasmic compiles the component's slot inline at the
parent's render scope, so `$ctx.currentProduct.*` bindings inside the
slot evaluate where currentProduct doesn't exist yet (the DataProvider
the component publishes only takes effect for descendants). Setting
providesData makes the compiler wrap the slot in a descendant function
component with its own useDataEnv, where currentProduct resolves.

Matches sibling data-providing components in the same package
(EPCartProvider, EPBundleProvider, EPVariationPicker, etc.) which all
already declare providesData: true.
@field123 field123 merged commit 8edcccc into master May 26, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant