I
I
Ivan Gordienko2019-10-12 14:25:33
JavaScript
Ivan Gordienko, 2019-10-12 14:25:33

Sending data from custom cart to Telegram?

Good day to all, guys!
There is a page with a basket, I used it to create a basket - this .

It is necessary to make sure that when ordering without payment, the data flew to the bot in telegrams.
I did sending forms to telegrams through - this . Everything works great, but now the question is with the basket, how to send? Pull data from cart div, put it in inputs and submit as form? Thanks for the advice, in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Gordienko, 2019-10-18
@zordq

An interesting decision was made. Further " Caution crutch! ".

function displayCart() {
    var cartArray = shoppingCart.listCart();
    var output = "" + "<div ><input class='input-send' name='phone' value='' placeholder='Номер телефона' requaired>" + "<input class='input-send' name='name' value='' placeholder='Ваша почта' requaired>"  + "<button class='sendspan' type='submit'>Отправить заказ</button></div>";
    for (var i in cartArray) {
        output += "<div class='form-group'>"
            + "<img src=" + cartArray[i].name + ">"
            + "<div class='input-group'><button class='minus-item input-group-addon' data-name=" + cartArray[i].name + ">-</button>"
            + "<input name='mutch' type='number' class='item-count form-control' data-name='" + cartArray[i].name + "' value='" + cartArray[i].count + "' requaired>"
            + "<button class='plus-item btn input-group-addon' data-name=" + cartArray[i].name + ">+</button></div>"
            + "<div name='price' requaired>" + cartArray[i].total + "</div>"
            + "<button class='delete-item btn btn-danger' data-name=" + cartArray[i].name + ">×</button>"
            + "<p class='form-message'></p>"
            + "<div id='message'></div>"
            + "</div>"
            + "<input class='offer' name='offer[]' value='Артикул: " + cartArray[i].name + " | Количество: " + cartArray[i].count + " | Сумма: " + cartArray[i].total + "' requaired>"
            + "</div>";
    }

    $('.show-cart').html(output);
    $('.total-cart').html(shoppingCart.totalCart());
    $('.total-count').html(shoppingCart.totalCount());
}

Data from the divs of the variables we need was passed to this line. One input was formed, which happily flew to telegrams.
+ "<input class='offer' name='offer[]' value='Артикул: " + cartArray[i].name + " | Количество: " + cartArray[i].count + " | Сумма: " + cartArray[i].total + "' requaired>"

W
WP Panda, 2019-10-12
@wppanda5

Why pull it from somewhere.
what you use stores data in sessionStorage, respectively, take it directly from there and send it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question