The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group
How to add images to the Woocommerce Gallery
The process is simple. Create a file/image upload field that allows multiple images, get the field ID and form ID, add this to your theme functions and modify the field ID and form ID in the code to match yours.
// Adds images to Woocommerce Gallery
add_action('frm_after_create_entry', 'add_gallery_images', 42, 2);
function add_gallery_images($entry_id, $form_id){
if ( $form_id == 9 ) { // change to match your form ID
global $frm_entry;
$entry = $frm_entry->getOne($entry_id);
$post_id = $entry->post_id;
$images = $_POST['item_meta'][104]; // change 104 to the field ID of your image upload field
$image = implode($images,',');
update_post_meta( $post_id, '_product_image_gallery', ltrim( $image, ',') );
}
August 1, 2017 at 2:22 pm
Thanks for posting the tip, kingtut!
Discussion closed.