Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter leandrodecolas

    (@leandrodecolas)

    Hi @pinalshah !

    Thank you very much for the comment, I’ll try changing the hook or check out WooCommerce.
    I’ll come back with updates.

    Thread Starter leandrodecolas

    (@leandrodecolas)

    I’m having trouble with this function in the code.

    function approve_quotes_automatically($order_id) {

        $security_nonce = wp_create_nonce('qwc-update-status-security');

        $security_nonce_send = wp_create_nonce('qwc-send-quote-security');

        ?>

        <script>

            jQuery(document).ready(function ($) {

                var order_id = '<?php echo esc_js($order_id); ?>';

                var security_nonce = '<?php echo esc_js($security_nonce); ?>';

                var security_nonce_send = '<?php echo esc_js($security_nonce_send); ?>';

                $.ajax({

                    type: 'POST',

                    url: ajaxurl,

                    data: {

                        'order_id': order_id,

                        'status': 'quote-complete',

                        'action': 'qwc_update_status',

                        'security_nonce': security_nonce

                    },

                    success: function (response) {

                        $.ajax({

                            type: 'POST',

                            url: ajaxurl,

                            data: {

                                'order_id': order_id,

                                'action': 'qwc_send_quote',

                                'security_nonce': security_nonce_send

                            }

                        });

                    }

                });

            });

        </script>

        <?php

    }

    add_action('woocommerce_thankyou', 'approve_quotes_automatically', 10, 1);
Viewing 2 replies - 1 through 2 (of 2 total)