godaddy-wordpress / wc-plugin-framework

The official SkyVerge WooCommerce plugin framework
Other
137 stars 42 forks source link

Use gateway ID for script handle, if possible #669

Closed itambek-godaddy closed 6 months ago

itambek-godaddy commented 6 months ago

Summary

This PR uses the dasherized block integration ID instead of the plugin ID when creating the main script handle.

Details

Using the Block_Integration_Trait:: get_id_dasherized() will return the current gateway ID, or the plugin ID, depending if the integration is for a gateway or a plugin.

This change helps to ensure that each gateway within a single plugin can manage their own script handle and dependencies.

For example, in Cybersource, the eCheck and Credit Card gateways have different dependencies, but if they share the same handle, it will mean that only the dependencies for the credit card gateway are ever enqueued.

The scripts can ultimately have the same source, but the browser will only download the file once. The file will execute each time it is included, but our entry points simply register payment methods, which is a cheap operation and doing so multiple times does not seem to have any side-effects in my testing.

QA

TODO

Open questions