unable to load Private Key
139633364686736:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:707:Expecting: ANY PRIVATE KEY
add_action('wp_ajax_search_posts', 'search_posts');
function search_posts()
{
$s = $_GET['term']; //получает данные введенного текста для поиска
$args = array(
'post_type' => 'collection', //ваш тип поста
's' => $s, //поисковый запрос
);
$data = [];
$loop = new WP_Query($args);
if ($loop->have_posts()) {
while ($loop->have_posts()) {
$loop->the_post();
$post_id = get_the_id(); //получаем id записи
$post_name = get_the_title(); //получаем title записи
$data[$post_id] = $post_name; // добавляем в массив data
}
}
echo json_encode($data); //кодируем в json и выводим
wp_die(); //иначе 0 в конце всегда лишний в выводе
}
<select id="product_field_type" name="product_field_type[]" class="wc-product-search" multiple="multiple" style="width: 50%;" data-placeholder="<?php esc_attr_e('Поиск по названию коллекции', 'woocommerce'); ?>" data-action="search_posts">
<?php
$product_ids = [];
$product_field_type_ids = get_post_meta(get_the_ID(), '_product_field_type_ids', true); //сменил $post->ID на get_the_ID()
if (!empty($product_field_type_ids)) {
$product_ids = array_map('absint', $product_field_type_ids);
}
if ($product_ids) {
foreach ($product_ids as $product_id) {
//$product = new WP_Query($product_id); больше не нужен
echo sprintf(
'<option value="%s" %s>%s</option>',
esc_attr($product_id),
selected(true, true, false),
esc_html(get_the_title($product_id)) //получаем нужный нам title по id записи
);
}
}
?>
</select>
$val2 = [['HOUR' => '10', 'MINUTE' => '30'], ['HOUR' => '11', 'MINUTE' => '00']];
var_dump(array_map(function ($a) { return $a['HOUR'].':'.$a['MINUTE']; }, $val2));
<script>
(function($) {
$(document).ready(function(){
if( $('#wpforms-form-446').length ) {
$('#wpforms-submit-446').prop('disabled', true);
$('#wpforms-446-field_21, #wpforms-446-field_3').change(function(){
check();
});
$('#wpforms-form-446 .wpforms-field-container').append('<div id="errs"></div>');
$('#wpforms-submit-446').click(function(event){
if( $('#wpforms-submit-446').prop('disabled') )
return;
let email = $('#wpforms-446-field_3').val();
let phone = $('#wpforms-446-field_21').val();
let password = $('#wpforms-446-field_4').val();
let name = $('#wpforms-446-field_1').val();
if( email.length == 0 || phone.length == 0 )
return;
$.ajax({
method: "POST",
dataType : 'json',
url: "/api.php?create-user",
data: { email: email, phone: phone, password: password, name: name }
})
.success(function( msg ) {
$('#errs').html('');
console.log(msg)
});
});
function check() {
let email = $('#wpforms-446-field_3').val();
let phone = $('#wpforms-446-field_21').val();
if( email.length == 0 || phone.length == 0 )
return;
$.ajax({
method: "POST",
dataType : 'json',
url: "/api.php?has-user",
data: { email: email, phone: phone }
})
.success(function( msg ) {
$('#errs').html('');
let b_error = false;
if( msg.error !== undefined ) {
let error = msg.error;
for (var variable in error) {
b_error = true;
$('#errs').append('<label class="wpforms-error">'+error[variable]+'</label>');
}
}
else {
if( msg.result !== undefined && msg.result == true ) {
b_error = true;
$('#errs').append('<label class="wpforms-error">Пользователь существует. <a href="https://a-n-h.space/rm_login/">Войти</a></label>');
}
}
if( b_error == false ) {
$('#wpforms-submit-446').prop('disabled', false);
}
});
}
}
});
})( jQuery );
</script>
$json_array = json_decode($response, true);
(именно с включением второго параметра в true. В итоге получается обычный ассоциативный массив. Ну и дальше через foreach в таком виде foreach ($json_array as $table => $rows) {
foreach ($rows as $time => $half_time) {
foreach ($half_time as $info => $value) {
foreach ($value as $value2 => $value3) {
echo $value3;
}
}
}
}
$args = array(
'post_type' => 'product_variation',
'post_status' => array( 'private', 'publish' ),
'numberposts' => -1,
'orderby' => 'menu_order',
'order' => 'ASC',
'post_parent' => get_the_ID() // get parent post-ID
);
$variations = get_posts( $args );
foreach ( $variations as $variation ) {
// get variation ID
$variation_ID = $variation->ID;
// get variations meta
$product_variation = new WC_Product_Variation( $variation_ID );
// get variation featured image
$variation_image = $product_variation->get_image();
// get variation price
$variation_price = $product_variation->get_price_html();
//get variation name
$variation_name = $product_variation->get_variation_attributes();
echo "<p class='product_price' >";
if ( $variation_name [ 'attribute_pa_СЛАГ_АТРИБУТА' ] ) {
$fasovka = [ 'attribute_pa_СЛАГ_АТРИБУТА' => $variation_name [ 'attribute_pa_СЛАГ_АТРИБУТА'] ];
echo wc_get_formatted_variation ( $fasovka );
}
echo ($variation_price);
echo "</p>";
}