As previously announced via banners and our newsletters, support is no longer available through this platform.

For easier navigation, you can still click on "Submit a Ticket" here, choose the appropriate category, and you'll be redirected to the correct support channel for your plugin.

You can still access your previous tickets and browse public tickets, but please note that responding to tickets is no longer possible.

Paid customers: Please log in to your store account for support.

Pre-purchase questions: Use the support widget in the bottom-right corner of our websites:
https://wpamelia.com
https://wpdatatables.com
https://wpreportbuilder.com

Okay
  Public Ticket #3979767
Bug Report
Open

Comments

  • Make Freedom started the conversation

    The below code is buggy. We were forced to comment out lines 108 to 174 to allow our users to add items to cart. The implementation of this code with no error handling is problematic and could cost site owners a lot of money until they realize the issue is happening. (Like us for example.)

    This only happens when a gravity form is filled out and you try to add the item to cart. It will not add to cart. It throws an error and you are stuck on the page unable to purchase the product. VERY FRUSTERATING is what we were told by users repeatedly. Please fix your code and also implement proper error handling to avoid these issues in the future! (PS. You should also add an on off button for extended functionality like this in the settings!!! Come on guys you can do better, we believe in you.)

    Throws error:

    wdt.woo-commerce.js?ver=7.2:112 Uncaught TypeError: Cannot read properties of undefined (reading 'id')
        at HTMLButtonElement.<anonymous> (wdt.woo-commerce.js?ver=7.2:112:99)
        at HTMLBodyElement.dispatch (jquery.min.js?ver=3.7.1:2:40035)
        at v.handle (jquery.min.js?ver=3.7.1:2:38006)

    ----------------------------------------------------------------------------------------------------------
    CODE from file wpdatatables>integrations>pro>woo-commerce>assets>wdt.woo-commerce.js Line 108 to 174
    ----------------------------------------------------------------------------------------------------------


            // Listen to add to cart events in the add_to_cart_button column

             $('body').on('click', '.single_add_to_cart_button', function (e) {
                e.preventDefault();

                let tableId = Number(this.dataset.value);
                let tableSelector = $('table.wpDataTable[data-wpdatatable_id=' + tableId + ']').get(0).id;
                let button = $(this);
                let productId = parseInt(button.data('product_id').toString().replace(/[^d]/g, ''), 10);
                let quantity = button.closest('.wdt-woo-product').find('input[name="quantity"]').val();
                let variations = {};

                // Get selected variations
                button.closest('.wdt-woo-variable-product').find('.wdt-woo-variation-selector').each(function () {
                    let attributeName = 'attribute_' + $(this).data('attribute-name');
                    let attributeValue = $(this).val();
                    variations[attributeName] = attributeValue;
                });

                let rowId = button.closest('tr')[0]._DT_RowIndex;

                $.ajax({
                    url: wdt_ajax_object.ajaxurl,
                    type: 'POST',
                    data: {
                        action: 'wpdatatables_add_single_product_to_cart',
                        product_id: productId,
                        quantity: quantity,
                        variations: variations,
                    },
                    success: function (data) {
                        if (data.success) {
                            if (data.data.notAdded) {
                                wdtNotify(
                                    wpdatatables_frontend_strings.error_wpdatatables,
                                    wpdatatables_frontend_strings.could_not_add_to_cart_wpdatatables,
                                    'danger'
                                )
                                return;
                            }
                            updateCartInfo();

                            // Update the specific row with a mini cart and product quantity
                            let cartHtml = `
                                <div class="wdt-woo-mini-cart" name="wdt-woo-mini-cart">
                                    <a href="${data.data.cart_url}" class="wdt-woo-mini-cart-icon">
                                        <i class="wpdt-icon-cart"></i>
                                        <span class="wdt-woo-cart-quantity">${data.data.product_quantities}</span>
                                    </a>
                                </div>
                            `;
                            let table = wpDataTables[tableSelector].DataTable();
                            let columnIndex = getColumnIndexByHeader('add_to_cart_button', tableSelector)
                            let currentContent = table.cell(rowId, columnIndex).node();
                            if (!currentContent.children.namedItem('wdt-woo-mini-cart')) {
                                $(currentContent).append(cartHtml);
                            } else {
                                $(currentContent).find('.wdt-woo-mini-cart').find('span.wdt-woo-cart-quantity').text(data.data.product_quantities)
                            }
                        } else {
                            wdtNotify(
                                wpdatatables_frontend_strings.error_wpdatatables,
                                wpdatatables_frontend_strings.error_adding_to_cart_wpdatatables,
                                'danger'
                            )
                        }
                    }
                });
            });