• Resolved Markldxb

    (@maraphones)


    Hi,

    I’m facing a 500 Server error involving admin-ajax.php — https://tppr.me/uz4LN Basically I get this error on Chrome console when I change the quantity on the checkout page.

    Any advise to resolve this?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Markldxb

    (@maraphones)

    To further describe the issue, I have attached here the exact server error log: https://tppr.me/CCnth

    Have error 500 if in cart have more products if have one is okay.
    Fix IT with this!

    <script type="text/javascript">
    
                  
                        $("form.checkout").on("change", "input.qty", function () {
    
                            $.ajax({
                                url: '\/wp-admin\/admin-ajax.php',
                                data: {
                                    action: 'cqoc_update_order_review',
                                    security: wc_checkout_params.update_order_review_nonce,
                                    post_data: $('form.checkout').serialize()
                                },
                                type: 'post',
                                success: function (response) {
                                    console.log(response);
                                    $('body').trigger('update_checkout');
                                }
                            });
    
                        });
                    </script>
    function cqoc_update_order_review() {
    
                $values = array();
                parse_str($_POST['post_data'], $values);
                $cart = $values['cart'];
                print_r($cart);
                $cart_updated = false;
                foreach ($cart as $cart_item_key => $cart_value) {
                    $passed_validation = apply_filters('woocommerce_update_cart_validation', true, $cart_item_key, $values, $quantity);
                    if ($passed_validation) {
                        WC()->cart->set_quantity($cart_item_key, $cart_value['qty'], false);
                        $cart_updated = true;
                    }
    
                    //  woocommerce_cart_totals();
                }
                // Trigger action - let 3rd parties update the cart if they need to and update the $cart_updated variable.
                $cart_updated = apply_filters('woocommerce_update_cart_action_cart_updated', $cart_updated);
    
                if ($cart_updated) {
                    WC()->cart->calculate_totals();
                }
                exit;
            }
    Plugin Author bhavik.kiri

    (@bhavikkiri)

    I’m glad to know that you are able to fix the issue & sharing the solution.

    I have many users who have multiple products in the cart and it works without any issues.

    I have also checked with multiple products in the cart and it works.

    Of course , may be i have many Plugins or many change in function,just this is my solution for my problem.
    Best regards!

    Plugin Author bhavik.kiri

    (@bhavikkiri)

    The issue is solved hence marking it as resolved.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Plugin causing issue on admin-ajax.php’ is closed to new replies.