Подключаю во вкладку Woocommerce
add_action('woocommerce_account_requisites_endpoint', 'requisites_content', 35);
function requisites_content()
{
$user_id = get_current_user_id();
$counter = get_user_meta($user_id, 'form_corporate_id', true);
echo ' <form id="save_user_data" data-id="0" class="user-data__save" method="post">
<p><input type="text" name="legal_status" value="' . get_user_meta($user_id, 'legal_status_0', true) . '" placeholder="Первый вопрос" ></p>
<p><input type="text" name="tax_code" value="' . get_user_meta($user_id, 'tax_code_0', true) . '" placeholder="Второй вопрос" ></p>
<p><input type="text" name="cpp_code" value="' . get_user_meta($user_id, 'cpp_code_0', true) . '" placeholder="Третий впорос"></p>
<p><input type="text" name="name_surname" value="' . get_user_meta($user_id, 'name_surname_0', true) . '" size="210" class="user-data__name-surname" placeholder="Ваше имя"></p>
<p><input type="text" name="delivery_address" value="' . get_user_meta($user_id, 'delivery_address_0', true) . '" class="user-data__delivery-address" placeholder="Ваш адрес"></p>
<p><input id="submit" type="submit" value="Сохранить" name="" class=""></p>
</form>';
if ($counter !== '') {
for ($i = 1; $i <= $counter; $i++) {
$content = '
<form id="save_user_data' . $counter . '" data-id="' . $i . '" class="user-data__save" method="post">
<p><input type="text" name="legal_status" value="' . get_user_meta($user_id, 'legal_status_' . $i , true) . '" placeholder="Первый вопрос" ></p>
<p><input type="text" name="tax_code" value="' . get_user_meta($user_id, 'tax_code_' . $i , true) . '" placeholder="Второй вопрос"></p>
<p><input type="text" name="cpp_code" value="' . get_user_meta($user_id, 'cpp_code_' . $i , true) . '" placeholder="Третий впорос"></p>
<p><input type="text" name="name_surname" value="' . get_user_meta($user_id, 'name_surname_' . $i , true) . '" size="210" class="user-data__name-surname" placeholder="Ваше имя"></p>
<p><input type="text" name="delivery_address" value="' . get_user_meta($user_id, 'delivery_address_' . $i, true) . '" class="user-data__delivery-address" placeholder="Ваш адрес"></p>
<p><input type="submit" value="Сохранить" name="save_user_data" class=""></p>
</form>
';
echo $content;
}
}
$add_form_btn = '<input id="add_form" type="button" value="Добавить" name="add_form" class="add-form">';
echo $add_form_btn;
}
let $ = jQuery;
let saveUserData = $("#save_user_data")
let addForm = document.getElementById('add_form');
$('form.user-data__save').bind('submit', function(e){
e.preventDefault();
console.log($(this).serialize());
let formData = $(this).serialize();
let formID = $(this).data('id');
console.log('id of my form' + formID);
$.ajax({
url: my_ajax_object.ajax_url,
dataType: "text",
type: "POST",
data: "&action=details&" + formData +"&id=" + formID,
success: function(data){
/*let value = JSON.parse(data);
if( value === 'reload'){
location.reload();
}*/
console.log(data);
}});
});
addForm.addEventListener("click", function (e) {
e.preventDefault();
$.ajax({
url: my_ajax_object.ajax_url,
dataType: "text",
type: "POST",
data: "&action=addform",
success: function(data){
let value = JSON.parse(data);
if( value === 'reload'){
location.reload();
}
}});
});
<?php
$args = array(
'taxonomy' => 'product_cat',
'hide_empty' => false,
'parent' => 0, );
$product_categories = get_terms( $args );
$count = count($product_categories);
echo '<div id="new-vid-category" data-open_parent="1">';
if ( $count > 0 ){
foreach ( $product_categories as $product_category ) {
$thumbnail_id = get_woocommerce_term_meta( $product_category->term_id, 'thumbnail_id', true );
echo '<article class="new-vid-catalog" data-open="1">';
echo '<a href="' . get_term_link( $product_category ) . '" title=""><h2>' . $product_category->name . '</h2></a>';
echo '<div class="btn"><img src="'. wp_get_attachment_url( $thumbnail_id ) .'" style="border:0;"></div>';
echo '<nav id="menu-item-cat" class="new-vid-razdel" data-open_child="1">';
echo '<a href="' . get_term_link( $product_category ) . '" title="" class="new-vid-title-m"><h2>' . $product_category->name . '</h2></a>';
echo '<div class="image-cat-item"><img src="'. wp_get_attachment_url( $thumbnail_id ) .'" style="border:0;"></div>';
echo '<ul class="new-parent-title-overlay">';
$args = array(
'taxonomy' => 'product_cat',
'hide_empty' => false,
'parent' => $product_category->term_id,);
$product_categories = get_terms( $args );
$count = count($product_categories);
if ( $count > 0 ){
foreach ( $product_categories as $product_category ) {
$thumbnail_id = get_woocommerce_term_meta( $product_category->term_id, 'thumbnail_id', true );
echo '<li class="new-parent-desc">';
echo '<a href="' . get_term_link( $product_category ) . '" title="">';
echo '<img src="'. wp_get_attachment_url( $thumbnail_id ) .'" style="width: 150px; height: 150px; border:0;">';
echo '<h4>' . $product_category->name . '</h4></a>';
echo '</li>';}}
echo '</ul>';
echo '</nav>';
echo '</article>';} }
echo '</div>';
?>
/*Каталог Новый START*****************************************************************************************/
@media screen and (max-width: 1440px) {
.new-vid-catalog h2 {
font-size: 16px;
}
.new-vid-razdel ul {
margin: 10px 50px 15px 310px;;
}
}
@media screen and (max-width: 1024px) {
.new-vid-razdel ul {
margin: 10px 10px 15px 310px;;
}
}
body {
margin:0;
/*min-height:100vw;*/
}
#new-vid-category {
position: relative;
display: flex;
flex-wrap: wrap;
justify-content: space-around;
vertical-align: top;
text-align: center;
}
.new-vid-catalog {
vertical-align: top;
flex-grow:0;
flex-shrink:0;
width:33.33333%;
}
.new-vid-catalog a {
margin-bottom: 10px;
text-decoration: none;
}
.new-vid-catalog a:hover {
text-decoration: underline;
}
.new-vid-catalog h2 {
font-size: 22px;
}
.new-vid-catalog h2:hover {
color: #09612c;
}
.btn {
cursor: pointer;
margin-top: 10px;
margin-bottom: 10px;
}
.btn img:hover {
border-radius: 10px;
background: rgba(23, 140, 52, 0.75);
box-shadow: 0 0 10px #444;
-webkit-transition: all .5s;
-o-transition: all .5s;
transition: all .5s;
}
/*.btn:active {
background: rgba(23, 140, 52, 0.75);
}*/
#menu-item-cat {
border: solid 1px #09612c;
background-image: url(https://alligator.myfounder.online/wp-content/uploads/2020/01/romby.svg);
background-repeat: no-repeat;
background-position-x: right;
background-position-y: top;
background-size: 20%;
text-align: left;
}
.image-cat-item {
height: 100%;
vertical-align: middle!important;
text-align: center;
}
.new-vid-razdel {
width:300%;
box-sizing:border-box;
display:none;
background:#FFF;
position:relative;
}
.new-vid-catalog:nth-child(3n+2) .new-vid-razdel {
margin-left:-100%;
}
.new-vid-catalog:nth-child(3n+3) .new-vid-razdel {
margin-left:-200%;
}
.new-vid-catalog.active .new-vid-razdel {
z-index:2;
}
#menu-item-cat .new-vid-title-m {
display: block;
margin-bottom: 10px;
text-align: center;
}
.new-vid-title-m h2 {
font-size: 22px;
}
.new-vid-razdel h2:hover {
color: #09612c;
}
.image-cat-item img {
height: 200px;
margin-top: 20%;
}
#menu-item-cat .image-cat-item {
display: flex;
float: left;
height: auto;
margin: 10px;
}
.new-vid-razdel ul {
display: block;
list-style: none;
margin: 10px 100px 15px 310px;
padding: 0;
}
li.new-parent-desc {
display: inline-block;
width: 200px;
text-align: center;
vertical-align: top;
}
.new-vid-razdel a {
text-decoration: none;
}
.new-vid-razdel a:hover {
text-decoration: underline;
}
.new-vid-razdel h4:hover {
color: #09612c;
}
/*Каталог Новый ******************************************************************************************END*/
<?php
$args = array(
'taxonomy' => 'product_cat',
'hide_empty' => false,
'parent' => 0,
);
$product_categories = get_terms( $args );
$count = count($product_categories);
echo '<div id="new-vid-category">';
if ( $count > 0 ){
foreach ( $product_categories as $product_category ) {
$thumbnail_id = get_woocommerce_term_meta( $product_category->term_id, 'thumbnail_id', true );
echo '<article class="new-vid-catalog">';
echo '<div class="new-vid_title">';
echo '<a href="' . get_term_link( $product_category ) . '" title=""><h2>' . $product_category->name . '</h2></a>';
echo '</div>';
echo '<div class="new-vid__image">';
echo '<i><img src="'. wp_get_attachment_url( $thumbnail_id ) .'" style="border:0;"/></i>';
echo '</div>';
echo '<div class="new-vid_razdel">';
echo '<div class="wrapper">';
echo '<div class="content">';
echo '<ul class="new-parent-title__overlay">';
$args = array(
'taxonomy' => 'product_cat',
'hide_empty' => false,
'parent' => $product_category->term_id,
);
$product_categories = get_terms( $args );
$count = count($product_categories);
if ( $count > 0 ){
foreach ( $product_categories as $product_category ) {
$thumbnail_id = get_woocommerce_term_meta( $product_category->term_id, 'thumbnail_id', true );
echo '<li class="new-parent-desc">';
echo '<div class="new-vid-razdel__image">';
echo '<i><img src="'. wp_get_attachment_url( $thumbnail_id ) .'" style="width: 150px; height: 100px;"/></i>';
echo '</div>';
echo '<a href="' . get_term_link( $product_category ) . '" title=""><h4>' . $product_category->name . '</h4></a>';
echo '</li>';
}}
echo '</ul>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</article>';
}
}
echo '</div>';
?>