Skip to content

Duplicate blockonomics_data declaration causing checkout failure #405

@anktd

Description

@anktd

This issue was reported on freshdesk tickets 338861 and 338857
The add_blockonomics_checkout_style function adds an inline script via add_action('wp_footer'):

    add_action('wp_footer', function() use ($additional_script) {
        printf('<script type="text/javascript">%s</script>', $additional_script);
    });

The script contains const blockonomics_data = '...'

Each time the shortcode [blockonomics_payment] executes, a new action is added to wp_footer. If the shortcode runs multiple times (could be due to themes, page builders, SEO plugins, caching), the script is output multiple times. Since const cannot be redeclared in JavaScript, this throws a SyntaxError. The error stops script execution, so the checkout container never initializes.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions