• Resolved vendidero

    (@vendidero)


    Hi there,

    we are the developers of Germanized for WooCommerce and (together with one of our users) found an issue with the amelia booking WooCommerce integration. The issue seems to only affect your paid solutions but I’ve found no (easy) way to report bugs there, that’s why I’m using this channel.

    The issue is related to your filter added to woocommerce_checkout_get_value in ameliabooking/src/Infrastructure/WP/Integrations/WooCommerce/WooCommerceService.php. Seems like under certain conditions the logic (which by itself calls WooCommerceService::processCart()) eventually triggers a cart recalculation via:

    $wooCommerceCart->calculate_totals();

    The issue is that any other extension (in our case, Germanized) which attaches it’s logic to a hook fired by the cart calculation, e.g. woocommerce_before_calculate_totals AND uses WC()->checkout()->get_value() to retrieve a certain value directly from the checkout object will lead to an infinite loop in conjunction with the amelia logic which will (again) trigger the cart recalculation as soon as the woocommerce_checkout_get_value is fired by calling WC()->checkout()->get_value().

    To reproduce, try adding the following snippet to your current theme’s functions.php:

    add_action( 'woocommerce_before_calculate_totals', function() {
        $checkout = WC()->checkout();
        $checkout->get_value( 'test_yo' );
    } );

    When trying to book a course/appointment now, the infinite loop will fire as soon as the admin-ajax.php?action=wpamelia_api&call=/payment/wc call is made. Could you please look into that?

    A possible fix would be to add a check to the $wooCommerceCart->calculate_totals(); to prevent this method from being called in case the hook is fired while already recalculating totals, e.g.:

    if ( ! doing_action( 'woocommerce_before_calculate_totals' ) ) {
        $wooCommerceCart->calculate_totals();
    }

    Cheers,
    Dennis

Viewing 1 replies (of 1 total)
  • Plugin Author ameliabooking

    (@ameliabooking)

    Hello Dennis, thank you very much for bringing this to our attention.

    Our support agents have passed this onto our developers to investigate this and change the code according to your instructions.

    We would like to thank you once again and if we need more assistance on this, we will let you know.

    If you do have any questions about the Amelia plugin, please let us know and we will gladly assist you with it.

Viewing 1 replies (of 1 total)
  • The topic ‘Infinite loop caused by amelia WooCommerce cart integration’ is closed to new replies.