• Resolved hollowaysteve88

    (@hollowaysteve88)


    As of version 1.2.12 of the FREE version of the plugin, you have a bug in wployalty/App/Controllers/Site/Blocks/Blocks.php

    The code references Birthday class from the PREMIUM version of the plugin (see line 18). If the premium version is not available, this causes a fatal PHP error. There are two instances within the file where a Birthday object is instantiated; both should be behind some if_premium_installed() check.

Viewing 7 replies - 1 through 7 (of 7 total)
  • I dont know if this is related but free version causing bug stopping multiple core wordpress functions. When this plugin is activated, it interrupted wp json api causing 500 internal server error. This affects multiple functions such as Jetpack, Customers table and Coupons from WooCommerce, and many more.

    Thread Starter hollowaysteve88

    (@hollowaysteve88)

    @sigmakicks almost certainly the same issue since I was getting similar errors. If this is critical for your site and you know a bit of PHP, you can use the plugin file editor from the dashboard to comment out the Birthday-related snippets from the above file. But I’m guessing this will be fixed very soon.

    here is my edited version of Blocks.php which I also found was causing the issue. Everything works now after the following commenting out. Hopefully the developer can rectify and push a new update out.

    <?php
    /**

    namespace Wlr\App\Controllers\Site\Blocks;

    use Automattic\WooCommerce\StoreApi\Exceptions\RouteException;
    use Automattic\WooCommerce\StoreApi\Schemas\V1\CartSchema;
    use Automattic\WooCommerce\StoreApi\Schemas\V1\CheckoutSchema;
    use Wlr\App\Controllers\Base;
    use Wlr\App\Controllers\Site\Blocks\Integration\Message;
    use Wlr\App\Controllers\Site\Main;
    use Wlr\App\Helpers\CompatibleCheck;
    use Wlr\App\Helpers\Woocommerce;
    /* Comment out the line below */

    /*

    use Wlr\App\Premium\Controllers\Site\Birthday;

    */

    defined( ‘ABSPATH’ ) or die;

    class Blocks extends Base {
    /* Block */
    function initBlocks() {
    if ( ! ( function_exists( ‘woocommerce_store_api_register_endpoint_data’ ) && class_exists( ‘\Automattic\WooCommerce\StoreApi\Schemas\V1\CartSchema’ ) ) ) {
    return;
    }
    $woocommerce = Woocommerce::getInstance();
    if ( ! Woocommerce::isBlockEnabled() || $woocommerce->isBannedUser() ) {
    return;
    }

        $message = new Message();
    if ( Woocommerce::isCartBlock() ) {
    if ( function_exists( 'WC' ) && WC()->is_rest_api_request() ) {
    woocommerce_store_api_register_endpoint_data(
    [
    'endpoint' => CartSchema::IDENTIFIER,
    'namespace' => str_replace( '-', '_', WLR_TEXT_DOMAIN . '-message' ),
    'data_callback' => [ $message, 'extendData' ],
    'schema_callback' => [ $message, 'extendDataSchema' ],
    'schema_type' => ARRAY_A,
    ]
    );
    /* COMMENT OUT BIRTHDAY CODE HERE. IT IS A PREMIUM FUNCTION AND SHOULD NOT BE HERE */

    /* $birthday = new Birthday();
    woocommerce_store_api_register_endpoint_data(
    [
    'endpoint' => CheckoutSchema::IDENTIFIER,
    'namespace' => 'wlr_checkout_block',
    'schema_callback' => [ $birthday, 'getBirthdayDateSchema' ],
    'schema_type' => ARRAY_A,
    ]
    );
    */
    }
    add_action(
    'woocommerce_blocks_cart_block_registration',
    function ( $integration_registry ) {
    $integration_registry->register( new Message() );
    }
    );
    }
    if ( Woocommerce::isCheckoutBlock() ) {
    if ( function_exists( 'WC' ) && WC()->is_rest_api_request() ) {
    woocommerce_store_api_register_endpoint_data(
    [
    'endpoint' => CartSchema::IDENTIFIER,
    'namespace' => str_replace( '-', '_', WLR_TEXT_DOMAIN . '-message' ),
    'data_callback' => [ $message, 'extendData' ],
    'schema_callback' => [ $message, 'extendDataSchema' ],
    'schema_type' => ARRAY_A,
    ]
    );

    /* AND ALSO COMMENT OUT HERE */

    /* $birthday = new Birthday();
    woocommerce_store_api_register_endpoint_data(
    [
    ‘endpoint’ => CheckoutSchema::IDENTIFIER,
    ‘namespace’ => ‘wlr_checkout_block’,
    ‘schema_callback’ => [ $birthday, ‘getBirthdayDateSchema’ ],
    ‘schema_type’ => ARRAY_A,
    ]
    );
    */
    }
    add_action(
    ‘woocommerce_blocks_checkout_block_registration’,
    function ( $integration_registry ) {
    $integration_registry->register( new Message() );
    }
    );
    }

        add_action( 'woocommerce_store_api_checkout_update_order_from_request', function ( $order, $request ) {
            $woocommerce = Woocommerce::getInstance();
            $coupons     = $woocommerce->isMethodExists( $order, 'get_items' ) ? $order->get_items( 'coupon' ) : [];
            if ( empty( $coupons ) ) {
                return;
            }
            $reward_helper  = \Wlr\App\Helpers\Rewards::getInstance();
            $payment_method = $woocommerce->isMethodExists( $order, 'get_payment_method' ) ? $order->get_payment_method() : '';
            if ( empty( $payment_method ) ) {
                return;
            }
            $user = $woocommerce->isMethodExists( $order, 'get_user' ) ? $order->get_user() : '';
            foreach ( $coupons as $coupon_item ) {
                $coupon_code = $woocommerce->isMethodExists( $coupon_item, 'get_code' ) ? $coupon_item->get_code() : '';
                if ( ! empty( $coupon_code ) && $reward_helper->is_loyalty_coupon( $coupon_code ) ) {
                    $user_reward = $reward_helper->getUserRewardByCoupon( $coupon_code );
                    // 4. validate WPLoyalty coupon conditions
                    $extra = [
                        'user_email'         => $user->user_email,
                        'order'              => $order,
                        'is_calculate_based' => 'order',
                        'allowed_condition'  => [ 'payment_method' ]
                    ];
                    if ( ! $reward_helper->processRewardConditions( $user_reward, $extra, false ) ) {
                        throw new RouteException(
                            'woocommerce_rest_cart_coupon_errors',
                            sprintf( __( 'Sorry.. %s coupon code invalid for %s payment.', 'wp-loyalty-rules' ), $coupon_code, $payment_method ),
                            409
                        );
                    }
                }
            }
        }, 10, 2 );
    }
    
    function updateCartFreeProduct() {
        if ( ! Woocommerce::isBlockEnabled() ) {
            return;
        }
        $main_controller = new Main();
        $main_controller->updateFreeProduct();
    }

    }

    Plugin Support haripradeepa

    (@haripradeepa)

    Hi there,

    Thank you for bringing this matter to our attention. We truly value your feedback.

    We apologize for any inconvenience this issue may have caused. Please rest assured that our team of skilled developers is diligently working to resolve it.

    Your notification has been immensely helpful and we are grateful for your understanding as we work towards a solution.

    Thank you for your patience and support.

    Best regards,

    WPLoyalty Team

    Plugin Support haripradeepa

    (@haripradeepa)

    Hello there,

    I wanted to touch base with you.

    I’m happy to let you know that our developers have successfully fixed the bug you reported. The latest version, 1.2.13 of the WPLoyalty free version, has been released.

    Would you mind updating the plugin and checking if the bug has been resolved on your end? We would greatly appreciate your feedback.

    Please review and inform us accordingly.

    Thanks

    WPLoyalty Team

    Thread Starter hollowaysteve88

    (@hollowaysteve88)

    Yes, the issue seems to be resolved.

    Plugin Support haripradeepa

    (@haripradeepa)

    Hello there,

    Happy that the issue have been resolved.

    For other questions, please submit a support ticket using this link:?https://wployalty.net/support/.

    We’ll be glad to assist you in this matter.

    Thanks
    Team WPLoyalty

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