Hello,
I have some issues with CRED product edit form. Here is my setup:
[credform class='cred-form cred-keep-original']
[cred_field field='form_messages' value='']
<div class="cred-field cred-field-post_title">
<label class="cred-label">
Product Name
</label>
[cred_field field='post_title' post='product' value='' urlparam='']
</div>
<div class="cred-field cred-field-post_content">
<label class="cred-label">
Product Description
</label>
[cred_field field='post_content' post='product' value='' urlparam='']
</div>
Price
[cred_field field='_regular_price' post='product' value='' urlparam='']
Condition
[cred_field field='pa_condition' display='checkbox']
Product Category
[cred_field field='product_cat' display='checkbox']
Featured Image
[cred_field field='_featured_image' value='' urlparam='']
Media Gallery
[cred_field field='my_product_image_gallery' post='product' value='' urlparam='']
[cred_field field='form_submit' value='Submit' urlparam='']
[/credform]
I have created a custom post to upload more images alongside with featured image. The issue is that when I upload a new image for "my_product_image_gallery" it will delete the featured image. Also I have added CRED_save_data hook to copy images to product image gallery using help of https://toolset.com/forums/topic/edit-form-problem-displaying-product-pictures/
add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==285)
{
$iamge_url_arr = get_post_meta($post_id, 'wpcf-my_product_image_gallery');
$iamge_id_arr = array();
foreach($iamge_url_arr as $img){
$iamge_id_arr[] = prefix_get_img_ids($img);
}
$value = implode(',', $iamge_id_arr);
update_post_meta($post_id, '_product_image_gallery', $value);
}
}
function prefix_get_img_ids($img='') {
$id= '';
global $wpdb;
$query = "SELECT ID FROM {$wpdb->posts} WHERE guid='$img'";
$id = $wpdb->get_var($query);
return $id;
}
This is working fine but if I edit/add images to my_product_image_gallery then the featured image is removed and the image I added is not updated to product gallery. Please see the attachment. Why it is showing all this text and two images in the cred form?
There are also issues with price: Price There is a problem with _regular_price field. Please check CRED form. I have made _regular_price available from hidden custom posts in the toolset settings but it is not appearing anywhere in the CRED wizard.
BR
Pagel