pexila
Forum Replies Created
-
Hello there, i would like to say we had the same issue with cache. he is there exact reason why your plugin has conflict with caching. The
Cache‑Controlheader is set tono‑cache, must‑revalidate, max‑age=0, no‑store, privateand thePragmaheader isno‑cache. StallerPay registers aDeletePaymentMethodcontroller on every front‑end page viaHooks::addAction('wp', DeletePaymentMethod::class, '__invoke', 9)in the WooCommerce service provider. When that controller runs, it checks whether thedelete-payment-methodquery variable is present. If it isn’t present, it callswc_nocache_headers()
solution?<?php
// Disable StallerPay’s DeletePaymentMethod hook.
// Note: no leading backslash in the class; double backslashes escape the backslash characters in the string.
add_filter(
‘stellarpay_disable_hook-wp:StellarPay\Integrations\WooCommerce\Stripe\Controllers\DeletePaymentMethod@__invoke’,
‘__return_true’
);// Optional: re‑implement the delete-payment-method logic without sending no‑cache headers
add_action(‘wp’, function () {
// Only handle actual delete‑payment‑method requests
if (!isset($GLOBALS[‘wp’]->query_vars[‘delete-payment-method’])) {
return;
}// Uncomment the next line only if you still want to bypass caching on the delete page: // wc_nocache_headers(); $token_id = (int) get_query_var('delete-payment-method'); $nonce = isset($_REQUEST['_wpnonce']) ? sanitize_text_field(wp_unslash($_REQUEST['_wpnonce'])) : ''; $token = WC_Payment_Tokens::get($token_id); if ( empty($nonce) || !$token || '\\StellarPay\\Integrations\\WooCommerce\\Stripe\\Constants'::GATEWAY_ID !== $token->get_gateway_id('edit') || !wp_verify_nonce($nonce, 'delete-payment-method-' . $token_id) || get_current_user_id() !== $token->get_user_id() ) { return; } try { $service = '\\StellarPay\\PaymentGateways\\Stripe\\Services\\PaymentMethodService'; if (function_exists('StellarPay\\Core\\container')) { $service_instance = StellarPay\Core\container($service); } else { $service_instance = new $service(); } $service_instance->detachPaymentMethod($token->get_token()); } catch (\Exception $e) { wc_add_notice( esc_html__('We are sorry, but we could not delete your payment method at this time. Please try again shortly.', 'stellarpay'), 'error' ); wp_safe_redirect(wc_get_account_endpoint_url('payment-methods')); exit; }}, 9);