- This topic has 1 reply, 2 voices, and was last updated 3 years, 2 months ago by .
-
Topic
-
Hi
I want to use metabox plugin for adding woocommerce products…
I need to add woo product image gallery with metabox image fields.
WooCommerce uses _product_image_gallery custom field to store the image gallery. It stores those images/attachments IDs separated by comma. Ex: 32,34,3874 in that single custom field.
So i need to save the image IDs to the WooCommerce’s _product_image_gallery meta key when i publish/update product. Also i need to do this with front-end form submission extension.
I can do this with another plugin with a snippet. Here i share the code for that:
/** * Update the custom field when the form submits * * @param type $post_id */ function wpuf_woo_product_gallery( $post_id ) { if ( isset( $_POST['wpuf_files']['_product_image'] ) ) { $images = get_post_meta($post_id, '_product_image' ); update_post_meta( $post_id, '_product_image_gallery', implode(',', $images) ); } } add_action( 'wpuf_add_post_after_insert', 'wpuf_woo_product_gallery' ); add_action( 'wpuf_edit_post_after_update', 'wpuf_woo_product_gallery' );
Can do this with metabox ? Can you share a snippet for doing this with metabox if possible ? Sorry that i am not a developer.
Thanks
- You must be logged in to reply to this topic.