CRITICAL Cannot declare class QRcode

Forums EAN and Barcodes for WooCommerce CRITICAL Cannot declare class QRcode

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #162576
    tana
    Participant

    Hi.

    We have a problem after installing the pro version.

    It seems that EAN Barcode Generator and WooCommerce Ultimate Gift Card are conflicting about the QRcode class :

    2025-03-28T14:05:44+00:00 CRITICAL Cannot declare class QRcode, because the name is already in use CONTEXT: {"error":{"type":64,"file":"/var/www/xxxxxx/xxxxxx/wp-content/plugins/ean-for-woocommerce-pro/includes/pro/assets/tcpdf/include/barcodes/qrcode.php","line":265},"remote-logging":true,"backtrace":[{"file":"/var/www/xxxxxx/xxxxxx/wp-content/plugins/woocommerce/includes/class-woocommerce.php","line":413,"function":"critical","class":"WC_Logger","type":"->"},{"function":"log_errors","class":"WooCommerce","type":"->"}]}

    Could you, please, solve the problem ?

    Kind regards.

    • This topic was modified 3 weeks, 4 days ago by tana.
    • This topic was modified 3 weeks, 4 days ago by tana.
    #163254
    Tom Anbinder
    Moderator
    Plugin Support

    Hi,

    Sorry for not getting back to you sooner.

    I believe this should be fixed in the “WooCommerce Ultimate Gift Card” plugin. They should check if the TCPDF2DBarcode class already exists (as we do in our plugin), something like this:

    if ( ! class_exists( 'TCPDF2DBarcode' ) ) {
        require_once 'path/to/tcpdf_barcodes_2d.php';
    }

    I wanted to find the exact line in the “WooCommerce Ultimate Gift Card” plugin code, but as I understand, the QRcode is a premium feature there, right?

    #163277
    tana
    Participant

    Hello Tom,

    The problem is with the class “QRcode” because the two plugins use the same project. (PHP QR Code encoder”

    It should have a “if not declared” with the class, it can’t be declared twice

    Thank you !

    #163668
    Tom Anbinder
    Moderator
    Plugin Support

    Hi,

    In our plugin, we use the TCPDF library; there, the TCPDF2DBarcode class includes the QRcode class. So we are doing the class_exists( 'TCPDF2DBarcode' ) check to ensure that no other plugin has included this class already. If the “WooCommerce Ultimate Gift Card” plugin would do the same, then there should be no issues. Also, there is a possibility that they use the QRcode class directly, i.e., not as a part of the TCPDF library – to be sure, I would need to check their plugin code. Could you please send me their plugin (my email is [email protected])?

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.