impress-org / givewp

GiveWP - The #1 Donation Plugin for WordPress. Easily accept donations and fundraise using your WordPress website.
https://givewp.com/
GNU General Public License v3.0
340 stars 191 forks source link

Fatal error: Uncaught BadMethodCallException: Method getEmailTag::Give\Framework\FieldsAPI\Checkbox does not exist #6828

Closed flack closed 1 year ago

flack commented 1 year ago

User Story

I recently updated from 2.27.2 to 2.29, and the following code

add_action( 'give_fields_after_donation_amount', function ( $group ) {
    $group->append(
        give_field( 'checkbox', 'make_CO2_certificate' )
            ->showInReceipt()
            ->label( __( 'Generate CO2 certificate'))
    );
});

now throws the following error in all frontend and backend pages:

BadMethodCallException: Method getEmailTag::Give\Framework\FieldsAPI\Checkbox does not exist in give/src/Framework/FieldsAPI/Concerns/Macroable.php on line 63
--

Give\Framework\Exceptions\UncaughtExceptionLogger->handleException( $exception = class BadMethodCallException { protected $message = 'Method getEmailTag::Give\\Framework\\FieldsAPI\\Checkbox does not exist'; private ${Exception}string = ''; protected $code = 0; protected $file = 'give/src/Framework/FieldsAPI/Concerns/Macroable.php'; protected $line = 63; private ${Exception}trace = [0 => [...], 1 => [...], 2 => [...], 3 => [...], 4 => [...], 5 => [...], 6 => [...], 7 => [...], 8 => [...], 9 => [...], 10 => [...], 11 => [...], 12 => [...], 13 => [...], 14 => [...], 15 => [...], 16 => [...], 17 => [...]]; private ${Exception}previous = NULL; public $xdebug_message = '<tr><th align=\'left\' bgcolor=\'#f57900\' colspan="5"><span style=\'background-color: #cc0000; color: #fce94f; font-size: x-large;\'>( ! )</span> BadMethodCallException: Method getEmailTag::Give\\Framework\\FieldsAPI\\Checkbox does not exist in give/src/Framework/FieldsAPI/Concerns/Macroable.php on line <i>63</i></th></tr>\n<tr><th align=\'left\' bgcolor=\'#e9b96e\' colspan=\'5\'>Call Stack</th></tr>\n<tr><th align=\'center\' bgcolor=\'#eeeeec\'>#</th><th align=\'left\' bgcolor=\'#eeeeec\'>Ti'... } ) | .../UncaughtExceptionLogger.php:0

Details

see above

Expected Behavior

It should not throw an error

Steps to Reproduce

see code above

jonwaldstein commented 1 year ago

@flack thanks for reporting this, looks like we have a backwards compatibility conflict.

We'll work on getting a fix for this, but in the meantime you can resolve the issue by replacing your code with this:

add_action( 'give_fields_after_donation_amount', function ( $group ) {
    $group->append(
        \Give\Framework\FieldsAPI\LegacyNodes\CheckboxGroup::make( 'make_CO2_certificate' )
            ->showInReceipt()
            ->label( __( 'Generate CO2 certificate'))
    );
});
akolahi commented 1 year ago

Running into the same issue. Looking to add an opt-in checkbox to subscribe to a newsletter along with the donation. The above (https://github.com/impress-org/givewp/issues/6828#issuecomment-1595139504) fix is not working for me.

JasonTheAdams commented 1 year ago

Hi @akolahi!

Can you please provide us with more information? What error and/or behavior are you seeing when you try the solution provided by @jonwaldstein?

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 14 additional days. Note, if this Issue is reporting a bug, please reach out to our support at https://givewp.com/support. If this is a feature request, please see our feedback board at feedback.givewp.com — that’s the best place to make feature requests, unless you’re providing a PR.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for an additional 14 days with no activity.