Hello @robertrosanke
The plugin already restricts this stylesheet to the cart, checkout, and order-payment pages. The relevant code in LocalAlternativePaymentMethodsModule.php contains the following guard:
add_action(
'wp_enqueue_scripts',
function () use ( $c ) {
if ( ! is_checkout() && ! is_cart() && ! is_wc_endpoint_url( 'order-pay' ) ) {
return;
}
// ...
wp_enqueue_style(
'ppcp-local-apms-gateway',
$asset_getter->get_asset_url( 'gateway.css' ),
// ...
);
}
);
Therefore, under normal circumstances, this file should not be loaded on the homepage.
Its presence there is likely specific to your setup, for example, a caching or CSS-optimization serving an aggregated stylesheet, a cached page containing the reference, or another component causing WC to identify the homepage as a checkout-related page. Please temporarily disable CSS aggregation and optimization, purge all site and CDN caches, and check the homepage source again.
Your observation regarding the cart page is valid: the stylesheet is currently also loaded there, although the .payment_methods list is generally not present. We can consider restricting that further as a minor optimization.
Kind Regards
Krystian
Hallo @inpsydekrystian ,
Thanks for the quick response.
This ticket is regarding the style handle “pppc-pwc-payment-method-css”.
It seems like it is located unter “/modules/ppcp-local-alternative-payment-methods/src/PWCPaymentMethod.php“, class PWCPaymentMethod .
public function get_payment_method_script_handles(): array {
wp_register_script(
'ppcp-pwc-payment-method',
$this->asset_getter->get_asset_url( 'pwc-payment-method.js' ),
array(),
$this->version,
true
);
wp_enqueue_style(
'ppcp-pwc-payment-method',
$this->asset_getter->get_asset_url( 'gateway.css' ),
array(),
$this->version
);
return array( 'ppcp-pwc-payment-method' );
}
It is always included, and there is no prior check to see if it is actually necessary in the current context.
Hello @robertrosanke
This issue has already been fixed in the development version through the following change: PR #4465 – Remove unconditional CSS enqueue from PWCPaymentMethod
The unconditional wp_enqueue_style() call has been removed from PWCPaymentMethod::get_payment_method_script_handles(). The method now only registers and returns the JavaScript handle.
The CSS is instead enqueued through LocalAlternativePaymentMethodsModule.php, where it is restricted to the relevant pages:
if ( ! is_checkout() && ! is_cart() && ! is_wc_endpoint_url( 'order-pay' ) ) {
return;
}
Therefore, the stylesheet should only load on the checkout, cart, and order-payment pages once this change is included in the released plugin version. Let me know if things work differently on your end; I’ve already confirmed this with the devs to be sure.
Kind Regards
Krystian
Hello @inpsydekrystian ,
Thanks for the info. In that case, that issue is resolved, and we’re looking forward to the new plugin version.
Have a great start to the week!
Hello @robertrosanke
No worries, wishing you a great week aswell!
If this helped and you’re happy with the support, feel free to leave a quick review on WordPress. It means a lot to us and shows that we are needed as support.
Kind regards,
Krystian