Compatibility issue with WooCommerce Paypal Payments
-
Hello,
I ran into a compatibility issue with “Woocommerce Paypal Payments” where I encountered a fatal error at Checkout.The fatal error in question:
[21-Jun-2024 10:40:14 UTC] PHP Fatal error: Uncaught TypeError: Return value of WooCommerce\PayPalCommerce\WcGateway\Settings\SettingsRenderer::render_multiselect() must be of the type string, null returned in public_html/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-wc-gateway/src/Settings/SettingsRenderer.php:188
Stack trace:
#0 public_html/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-wc-gateway/src/WCGatewayModule.php(626): WooCommerce\PayPalCommerce\WcGateway\Settings\SettingsRenderer->render_multiselect(NULL, 'swph_woo_custom...', Array, 'CGV et Decharg...')
#1 public_html/wp-includes/class-wp-hook.php(324): WooCommerce\PayPalCommerce\WcGateway\WCGatewayModule::WooCommerce\PayPalCommerce\WcGateway\{closure}(NULL, 'swph_woo_custom...', Array, 'CGV et D\xC3\xA9charg...')
#2 public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters(NULL, Array)
#3 public_html/wp-content/plugins/woocommerce/includes/wc in public_html/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-wc-gateway/src/Settings/SettingsRenderer.php on line 188After various tests, it turns out that the Paypal plugin uses an
add_filter
on “woocommerce_form_field
” (woocommerce-paypal-payments/modules/ppcp-wc-gateway/src/WCGateWayModule.php
line 618). However, when this filter is applied to fields added by your plugin,$field
isNULL
, meaning that the “swph_hidden
” field type is not known.To correct this, here’s the modified code in
order-signature-for-woocommerce/includes/class-swph-signature-frontend.php
line 104 :public function enqueue_signature_pad_hooks() {
$signature_data = $this->get_signature_data_for_endpoint();
add_filter('woocommerce_form_field', 'woocommerce_form_field_swph_hidden_function', 20, 4);
function woocommerce_form_field_swph_hidden_function($field, $key, $args, $value = null) {
if ($args['type'] === 'swph_hidden') {
$field = '<input type="hidden" class="' . esc_attr(implode(' ', $args['class'])) . '" name="' . esc_attr($key) . '" id="' . esc_attr($key) . '" value="' . esc_attr($value) . '" />';
}
return $field;
}
//add_filter( 'woocommerce_form_field_swph_hidden', array( $this, 'render_hidden_input' ), 10, 4 );I think the form can be improved (especially by using the
render_hidden_input
function), but this solved the problem.
- The topic ‘Compatibility issue with WooCommerce Paypal Payments’ is closed to new replies.