K
K
KVS172013-12-17 07:54:53
JavaScript
KVS17, 2013-12-17 07:54:53

How to send what is in the cart with the order form?

Good afternoon!
There is such a task
%D0%9A%D0%BE%D1%80%D0%B7%D0%B8%D0%BD%D0%B0.jpg-%D0%B8-%D0%9A%D0%BE%D1%80%D0 %B7%D0%B8%D0%BD%D0%B02.jpg.png
The store is made on wordpress using the WooCommerce plugin, a form generated by the Contact Forms 7 plugin is used to send data
.
With my spinal cord, I understand what needs to be done
1. Get the data from the basket: pull it out with javascript from <tr class="cart_table_item">
2. save it to a variable
3. send it along with other data via the contact form
Tell me step by step how to solve this problem.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
N
Nikolai Antal, 2013-12-17
@KVS17

Probably nothing without editing the Contact Forms 7 plugin.
Rip out the product link (although the product ID is better), create a hidden field with this ID, then tweak the plugin so that it sends this field.
The second, more tricky way: I don’t remember if there are hidden fields in the constructor in Contact Forms 7, if so, then create a hidden field with an id, then use the script to rip out the record ID of the product (s), and insert it into the hidden field (with several products insert separated by commas). Next, you need to look for a filter in Contact Forms 7, using which you can replace these record IDs with links. For example, you can try these: "wpcf7_mail_components", "wpcf7_display_message", or even look for a suitable one. In general, you need to find the data processing filter before sending and replace the desired code

N
Nikolai Vasilchuk, 2013-12-17
@Anonym

The cart data is stored in the session or in cookies. You can read them on the server and you do not need to transfer them from the client.

A
Arman, 2013-12-17
@Arik

Unfortunately, I'm not familiar with current plugins, but maybe you can explicitly set the form for the fields?
htmlbook.ru/html/input/form
Then all the data will go with the desired form.

K
KVS17, 2013-12-17
@KVS17

For the first point

<script type="text/javascript">
jQuery(document).ready(function($){   
var getvalue1 = $('td.product-name').text();
var getvalue2 = $('td.product-price').text();
})
</script>

For example, if there are 2 goods in the basket, then in the getvalue1 variable I see two product names separated by commas, respectively, in getvalue2 there are two prices separated by commas.
The question is how to combine the getvalue1 and getvalue2 values ​​before passing them to the form so that they take a conveniently readable format?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question