Skip to content

Conversation

@GJHypostore
Copy link
Contributor

Description

Add isKlaviyoEnabled to product/viewed.phtml. The logic in this phtml file gets executed even if you disable the module. Other phtml files do have an check.

Manual Testing Steps
Verified that product/viewed.phtml executes regardless of whether the Klaviyo module is enabled or disabled.

Added a check for isKlaviyoEnabled at the top of product/viewed.phtml, matching the logic used in other phtml files.

Confirmed that the Klaviyo script no longer renders when the module is disabled.

Confirmed that the script still renders correctly when the module is enabled.

Logic in product/viewed.phtml is always executed even when you disable the module.
Add isKlaviyoEnabled check to product/viewed.phtml
@GJHypostore GJHypostore requested a review from a team as a code owner July 24, 2025 10:04
@klaviyoit klaviyoit requested a review from smoucka July 24, 2025 10:04
Copy link
Contributor

@smoucka smoucka left a comment

Choose a reason for hiding this comment

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

Thank you @GerritJanHypoStore . Can you please update CHANGELOG.md as well?

@GJHypostore
Copy link
Contributor Author

@smoucka I've updated the CHANGELOG.md and version numbers. Please let me know if there's anything else you'd like me to adjust.

@cykolln
Copy link
Contributor

cykolln commented Aug 11, 2025

@GerritJanHypoStore mind rollin back the version bump and updating the changelog to put this fix under Unreleased? We will likely release it alongside some other changes so we dont want to bump the version just yet

@GJHypostore
Copy link
Contributor Author

@cykolln I’ve rolled back the version bump, updated the changelog to place the fix under Unreleased, and merged it with the latest version. Please let me know if anything else needs to be updated.

@GJHypostore GJHypostore requested a review from smoucka August 19, 2025 08:19
@smoucka
Copy link
Contributor

smoucka commented Sep 4, 2025

@GJHypostore Sorry for the delay here and thank you again. Can you please rebase? We'll get this merged in once that's done.

@GJHypostore
Copy link
Contributor Author

@smoucka No worries at all, I’ve gone ahead and rebased as requested.

@GJHypostore
Copy link
Contributor Author

@smoucka I noticed the changelog issue flagged by the automated tests, so I went ahead and redid the rebase to fix it.

/** @var Klaviyo\Reclaim\Block\Catalog\Product\ViewedProduct $block */
if (!$block->isKlaviyoEnabled()) {
return;
}
Copy link

Choose a reason for hiding this comment

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

Bug: Klaviyo: Missing API Key Validation Causes Render Issues

The template only checks isKlaviyoEnabled() but doesn't verify that a public API key exists. The block's _toHtml() method checks both conditions: isKlaviyoEnabled() && getPublicApiKey(). Other templates like analytics/initialize.phtml also check both. If Klaviyo is enabled but no API key is configured, the template will render and attempt to call getViewedProductJson() and getViewedItemJson(), which may cause issues. The check should be: if (!($block->isKlaviyoEnabled() && $block->getPublicApiKey())) to match the block's logic.

Fix in Cursor Fix in Web

@smoucka smoucka merged commit 1936c80 into klaviyo:master Nov 4, 2025
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.

3 participants