Bug image advanced with woocommerce featured image
- This topic has 9 replies, 2 voices, and was last updated 3 years, 11 months ago by
Long Nguyen.
-
AuthorPosts
-
May 4, 2021 at 7:53 PM #27903
Felipe Pereira
ParticipantHi guys, how are you?
I need help with a bug I found.
I created some image galleries with advanced image on the woocommerce product pages. However, I found that if I add an image to these galleries, I will no longer be able to change the highlighted image of the product.
I have already rewritten the code, I have redid the advanced images and the bug continues, it is only possible to change the product images if there is no photo in the gallery created with advanced images from the metabox.I hope you can help me.
ThanksMay 4, 2021 at 10:04 PM #27905Long Nguyen
ModeratorHi Felipe,
That was not a bug. The field type image_advanced has the setting
'multiple' => true
which means the value is saved in the database as a serialized array, not only one attachment ID as featured image. You can use the field type single_image instead of and refer to this topic to replace the default featured image box with a custom field.
https://support.metabox.io/topic/single-image-field-with-the-id-_thumbnail_id-is-not-showing-after-latest-updates/May 19, 2021 at 6:20 AM #28282Felipe Pereira
ParticipantHi Long Nguyen.
Thanks for your feedback, but I'm not really trying to replace the product's featured image on woocommerce. I added a gallery with multiple images with the metabox, they are complementary images to the product, and when adding an image to this gallery there is an error that I can no longer change the featured image of the product (official of woocommerce). It is only possible to change the product image when I remove 100% of the images from the gallery created with the metabox.May 19, 2021 at 12:58 PM #28286Long Nguyen
ModeratorHi Filipe,
Can you please share the code that creates meta box and custom fields for the post-type Product? I will check it on my end.
May 20, 2021 at 1:26 AM #28309Felipe Pereira
ParticipantHi, Long Nguyen, of course I can.
It is a long code because we have several fields, from attachments to fields with texts and complementary information.Thanks,
https://pastebin.com/dcJv5LnyMay 20, 2021 at 9:13 PM #28322Long Nguyen
ModeratorHi Filipe,
Use your code to create custom fields on the product editing page, I do not see any issue. Screen record https://share.getcloudapp.com/12uAGeAW.
Please follow the Debugging Information step here https://support.metabox.io/topic/how-to-create-a-new-topic/ to troubleshoot this issue. Let me know how it goes.
May 21, 2021 at 3:04 AM #28333Felipe Pereira
ParticipantHi Long Nguyen,
After saving or updating the product, did you try to remove or change the featured image of the product?
First test with a product with several images added in the galleries created with metabox:
https://share.getcloudapp.com/nOuoAoG5Second test removing advanced image images created with metabox:
https://share.getcloudapp.com/xQubG7YoThe problem occurs after we save the product with the images added to the gallery created by the metabox.
May 21, 2021 at 1:25 PM #28348Long Nguyen
ModeratorHi,
Yes, it still works when I remove/change the featured image of the product. Screen record https://share.getcloudapp.com/E0uYDeb6
It is possible that there is a conflict between plugins. You can try to follow the Debugging Information on the reply above to troubleshoot this issue.
May 26, 2021 at 10:09 PM #28436Felipe Pereira
ParticipantHi,
I discovered the conflict, I was using ACF to create personalized fields for users, photographers and products in the attachments and that was what was causing conflict.
Thanks for your help was lost before, for anyone who has the same problem follows solution used with metabox to replace the ACF plugins.
<?php add_filter( 'rwmb_meta_boxes', 'metabox_attachment_photographer_register_meta_boxes' ); function metabox_attachment_photographer_register_meta_boxes( $meta_boxes ) { $meta_boxes[] = [ 'title' => esc_html__( 'Fotográfo', 'decostore' ), 'id' => 'attachment_photographer', 'context' => 'normal', 'post_types' => 'attachment', 'media_modal' => true, 'fields' => [ [ 'type' => 'user', 'name' => esc_html__( 'Fotográfo', 'decostore' ), 'id' => 'attachment_photographer', 'field_type' => 'select', 'query_args' => [ 'role' => 'photographer', 'order' => 'ASC', 'orderby' => 'title', ], ], ], ]; return $meta_boxes; }
May 26, 2021 at 11:01 PM #28440Long Nguyen
ModeratorLet me know if you have any questions 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.