• Hello! Recently, we`ve encountered a really strange bug in the latest version of Woocommerce 9.1.2. We have a lot of reused images in our products. The same attachments are attached to many different products in the same category, mostly in their galleries. So, when we delete such an image, we expect Wooommerce to detach that image from all related products, but currently that doesn’t happen, though I remember that working before. When I try to delete or even manually detach an image from the “Media” WordPress tab, the product gallery still contains the same attachment IDs. You can check the https://devtest.insulationwholesale.co.uk/kingspan-kooltherm-k15-rainscreen-cladding-insulation-100mm/ page, where you can see that the second image takes up space and displays as a separate product image but doesn’t have any url as the attachment was already deleted. The Woocommerce product still has the attachment’s ID in the product gallery array, and when it tries to display the image, an empty string is returned. You can open the inspect tab in your browser and search the “Product attachment ids are” string, and you will see my var dumps that display the product gallery ID list and main product image ID. Also note that I already cleared all transients, and it doesn’t work. Also, please note that I checked it on the store front theme and with the disabled plugins, and the problem still remains the same. So the solution for that problem should be to clear attachments’s IDs from everywhere in Woocommerce products and categories automatically.

    Best regards,

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 22 total)
  • Thread Starter danyloliptuha

    (@danyloliptuha)

    Also, please note that the problem persists until we enter the product edit page. As WooCommerce checks and removes empty attachments while displaying product gallery meta-boxes. But if we do not enter the single product edit page, the problem remains.

    Hi @danyloliptuha

    Thank you for reaching out — we’re happy to help!

    I went ahead with testing, with a test site of mine. When a freshly uploaded image, added to the product gallery of two products, is permanently deleted (from the site’s media library screen), the result is for it to not appear on any of the product pages (or edit product screens) afterward.

    I hope this is helpful! Please let us know if you have any further questions about this matter, or if we misinterpret your concern in any way. We will be happy to help you further.

    Thread Starter danyloliptuha

    (@danyloliptuha)

    If you enter the edit product screens like you said, then you will fire the code inside the wp-content/plugins/woocommerce/includes/admin/meta-boxes/class-wc-meta-box-product-images.php file. It will loop through all images, check if the attachment returns an empty result, and clear those attachments. But if we only delete the image and do not enter any other pages, the attachment ID still remains inside the product gallery on $product->get_gallery_image_ids(). And I didn’t find any other places in the source code where Woocommerce clears empty attachments from the product gallery. Maybe you could share the exact file path where WooCommerce attaches some callback to the media deletion action and clears its ID from all its fields.

    Hi @danyloliptuha ??

    I went ahead with testing again, just to be sure.

    Once the image is permanently deleted in my test site’s media library, it no more shows up on product galleries on the front end.

    Went ahead with refreshing the front-end product pages only, without entering the edit product screen(s).

    I hope this helps, and provides clarity.

    Thread Starter danyloliptuha

    (@danyloliptuha)

    Well, I can reproduce it everytime I delete the image attached to product on the 9.1.2 version. Please provide the exact file path where WooCommerce implements the sync of product images values and media library. Cause the only place I found with such a logic is in meta-box display function inside wp-content/plugins/woocommerce/includes/admin/meta-boxes/class-wc-meta-box-product-images.php

    Hey, @danyloliptuha!

    I understand you are able to replicate this consistently, let’s investigate to figure out what is causing this to happen ??

    • To confirm, this is happening with different image files, correct?
    • Are they all in the same format? Which one?
    • When you added the image, did you add it on the library and then attached it to several products, or did you add it from a product edit page and then added it to other products?

    Can you please run a conflict test to see if something external is interfering with this?

    To test, you’ll first want to change the theme on your site to Storefront, then check to see if the issue is still present. If that resolves the issue, you’ll want to get in touch with your theme’s developer and see if they have an update or fix for you.

    If changing the theme doesn’t help, you’ll want to deactivate all plugins except for WooCommerce and take a look. If that fixes the problem, re-enable the other plugins one by one (gradually), checking after each, to see where the issue is coming from.

    — Be sure you have a good backup in place of your full site and database. You can ask your host for backup functionality or you can consider using a service like Jetpack. If something goes wrong, you will be able to restore it.

    — Also, you can consider using a plugin like Health Check & Troubleshooting. This is a plugin developed by the WordPress community and it is helpful to disable plugins without affecting your current site visitors.

    — It is important to consider as well a staging functionality in case you would not like to touch your production site (you can ask your host if they offer this service), or you can use WP Staging for quickly spinning up a new test site.

    You can find more about this in this guide.

    Please let us know about your findings.

    Have a wonderful day!

    Thread Starter danyloliptuha

    (@danyloliptuha)

    Hello!

    To confirm, this is happening with different image files, correct?

    Yes

    Are they all in the same format? Which one?

    jpeg or png files

    When you added the image, did you add it on the library and then attached it to several products, or did you add it from a product edit page and then added it to other products

    I added it on the media library page.

    Please note that I’ve already tested it on the Storefront theme and with all plugins disabled, and I could still reproduce the problem.

    Best regards

    Hey, @danyloliptuha!

    Thank you for confirming.

    I added it on the media library page.

    I tried doing this and I was still not able to replicate the issue.

    Can you please share the System Status Report which you can find via WooCommerce > Status > Get system report > Copy for support so we can check your settings and see if there’s anything on it we can try to change on our site to replicate the issue?

    Also, have you tried deleting the image and checking on a different browser to see if it is a caching issue?

    Looking forward to your reply.

    Have a wonderful day!

    Thread Starter danyloliptuha

    (@danyloliptuha)

    WordPress Environment<br><br>WordPress address (URL): https://wordpress<br>Site address (URL): https://wordpress<br>WC Version: 9.1.2<br>Legacy REST API Package Version: The Legacy REST API plugin is not installed on this site.<br>Action Scheduler Version: ? 3.7.4<br>Log Directory Writable: ?<br>WP Version: 6.6<br>WP Multisite: –<br>WP Memory Limit: 2 GB<br>WP Debug Mode: –<br>WP Cron: ?<br>Language: en_US<br>External object cache: – Server Environment<br><br>Server Info: Apache<br>PHP Version: 7.4.27<br>PHP Post Max Size: 1 GB<br>PHP Time Limit: 60<br>PHP Max Input Vars: 1000<br>cURL Version: 7.70.0<br>OpenSSL/1.1.1m<br><br>SUHOSIN Installed: –<br>MySQL Version: 5.5.5-10.5.11-MariaDB-log<br>Max Upload Size: 1 GB<br>Default Timezone is UTC: ?<br>fsockopen/cURL: ?<br>SoapClient: ?<br>DOMDocument: ?<br>GZip: ?<br>Multibyte String: ?<br>Remote Post: ?<br>Remote Get: ? Database<br><br>WC Database Version: 9.1.2<br>WC Database Prefix: wp_<br>Total Database Size: 12.88MB<br>Database Data Size: 8.37MB<br>Database Index Size: 4.51MB<br>wp_woocommerce_sessions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wp_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wp_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wp_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB<br>wp_woocommerce_order_items: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wp_woocommerce_order_itemmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wp_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB<br>wp_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wp_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wp_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wp_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wp_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wp_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wp_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wp_actionscheduler_actions: Data: 0.17MB + Index: 0.20MB + Engine InnoDB<br>wp_actionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wp_actionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wp_actionscheduler_logs: Data: 0.14MB + Index: 0.13MB + Engine InnoDB<br>wp_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wp_comments: Data: 0.02MB + Index: 0.09MB + Engine InnoDB<br>wp_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wp_options: Data: 5.47MB + Index: 0.06MB + Engine InnoDB<br>wp_postmeta: Data: 1.25MB + Index: 2.63MB + Engine InnoDB<br>wp_posts: Data: 0.11MB + Index: 0.06MB + Engine InnoDB<br>wp_termmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wp_terms: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wp_term_relationships: Data: 0.05MB + Index: 0.02MB + Engine InnoDB<br>wp_term_taxonomy: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wp_usermeta: Data: 0.22MB + Index: 0.03MB + Engine InnoDB<br>wp_users: Data: 0.02MB + Index: 0.05MB + Engine InnoDB<br>wp_wc_admin_notes: Data: 0.06MB + Index: 0.00MB + Engine InnoDB<br>wp_wc_admin_note_actions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wp_wc_category_lookup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wp_wc_customer_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wp_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wp_wc_orders: Data: 0.02MB + Index: 0.11MB + Engine InnoDB<br>wp_wc_orders_meta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wp_wc_order_addresses: Data: 0.02MB + Index: 0.06MB + Engine InnoDB<br>wp_wc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wp_wc_order_operational_data: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wp_wc_order_product_lookup: Data: 0.02MB + Index: 0.06MB + Engine InnoDB<br>wp_wc_order_stats: Data: 0.02MB + Index: 0.05MB + Engine InnoDB<br>wp_wc_order_tax_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wp_wc_product_attributes_lookup: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wp_wc_product_download_directories: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wp_wc_product_meta_lookup: Data: 0.08MB + Index: 0.11MB + Engine InnoDB<br>wp_wc_rate_limits: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wp_wc_reserved_stock: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wp_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wp_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB Post Type Counts<br><br>attachment: 4<br>page: 7<br>post: 2<br>product: 103<br>revision: 1<br>wp_font_face: 33<br>wp_font_family: 12<br>wp_global_styles: 1<br>wp_navigation: 1 Security<br><br>Secure connection (HTTPS): ?<br>Your store is not using HTTPS. Learn more about HTTPS and SSL Certificates.<br>Hide errors from visitors: ? Active Plugins (2)<br><br>WooCommerce Shipping & Tax: by WooCommerce – 2.6.2<br>WooCommerce: by Automattic – 9.1.2 Inactive Plugins (2)<br><br>Akismet Anti-spam: Spam Protection: by Automattic - Anti-spam Team – 5.3.3<br>Hello Dolly: by Matt Mullenweg – 1.7.2 Settings<br><br>API Enabled: –<br>Force SSL: –<br>Currency: GBP (£)<br>Currency Position: left<br>Thousand Separator: ,<br>Decimal Separator: .<br>Number of Decimals: 2<br>Taxonomies: Product Types: external (external)<br>grouped (grouped)<br>simple (simple)<br>variable (variable)<br><br>Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)<br>exclude-from-search (exclude-from-search)<br>featured (featured)<br>outofstock (outofstock)<br>rated-1 (rated-1)<br>rated-2 (rated-2)<br>rated-3 (rated-3)<br>rated-4 (rated-4)<br>rated-5 (rated-5)<br><br>Connected to WooCommerce.com: –<br>Enforce Approved Product Download Directories: ?<br>HPOS feature enabled: ?<br>Order datastore: Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStore<br>HPOS data sync enabled: – Logging<br><br>Enabled: ?<br>Handler: Automattic\WooCommerce\Internal\Admin\Logging\LogHandlerFileV2<br>Retention period: 30 days<br>Level threshold: –<br>Log directory size: 13 B WC Pages<br><br>Shop base: #7 - /shop/<br>Cart: #8 - /cart/ - Contains the woocommerce/cart block<br>Checkout: #9 - /checkout/ - Contains the woocommerce/checkout block<br>My account: #10 - /my-account/<br>Terms and conditions: ? Page not set Theme<br><br>Name: Twenty Twenty-Four<br>Version: 1.2<br>Author URL: https://www.remarpro.com<br>Child Theme: ? – If you are modifying WooCommerce on a parent theme that you did not build personally we recommend using a child theme. See: How to create a child theme<br>WooCommerce Support: ? Not declared Templates<br><br>Overrides: – Admin<br><br>Enabled Features: activity-panels<br>analytics<br>product-block-editor<br>coupons<br>core-profiler<br>customize-store<br>customer-effort-score-tracks<br>import-products-task<br>experimental-fashion-sample-products<br>shipping-smart-defaults<br>shipping-setting-tour<br>homescreen<br>marketing<br>mobile-app-banner<br>navigation<br>onboarding<br>onboarding-tasks<br>product-custom-fields<br>remote-inbox-notifications<br>remote-free-extensions<br>payment-gateway-suggestions<br>shipping-label-banner<br>subscriptions<br>store-alerts<br>transient-notices<br>woo-mobile-welcome<br>wc-pay-promotion<br>wc-pay-welcome-page<br>launch-your-store<br><br>Disabled Features: experimental-blocks<br>minified-js<br>pattern-toolkit-full-composability<br>product-pre-publish-modal<br>printful<br>settings<br>async-product-editor-category-field<br>product-editor-template-system<br><br>Daily Cron: ? Next scheduled: 2024-07-20 08:35:55 +00:00<br>Options: ?<br>Notes: 58<br>Onboarding: completed Action Scheduler<br><br>Complete: 492<br>Oldest: 2024-07-19 08:37:16 +0000<br>Newest: 2024-07-19 08:58:00 +0000<br><br>Failed: 2<br>Oldest: 2024-07-19 08:47:13 +0000<br>Newest: 2024-07-19 08:49:32 +0000<br><br>Pending: 1<br>Oldest: 2024-07-20 08:37:16 +0000<br>Newest: 2024-07-20 08:37:16 +0000 Status report information<br><br>Generated at: 2024-07-19 09:01:08 +00:00<br>

    I’ve come even further and installed totally clean WordPress, installed WooCommerce and added couple of products. I uploaded new images in media library and then attached it to a few products. Then I deleted image and I can still see the extra image on the product page inside FlexSlider and in the thumbnails. Please see the screenshot below.

    View post on imgur.com

    Standard WordPress and Woocommerce themes just do not display these empty <img/> and <a> because they will not have any width and height in CSS, but if you open the Inspect tab you will clearly see the empty <a> tag inside flex slider and empty <img> tag inside product thumbs. The only difference that my theme has some css styles that applies some width and height to those elements. But it`s clearly the bug of WooCommerce.

    anastas10s

    (@anastas10s)

    Howdy @danyloliptuha ??

    From what I gather, the issue reported here is theme-related.

    Therefore, feel free to reach out to its support channel, as they would be in a better position to assist you.

    In case you are developing the theme, instead, below are some resources to assist you further:

    I trust that points you in the right direction, but if you have more questions, let us know.

    We’re happy to help.

    Thread Starter danyloliptuha

    (@danyloliptuha)

    The problem is absolutely not theme-related. It`s a global bug in WooCommerce. I installed the absolutely new, clean version of WordPress and the absolutely new, clean Woocommerce, created a few products, and could still replicate the issue. Have you seen the screenshot I attached? Could you tell me exactly where WooCommerce clears deleted attachments from the product gallery? If you create a product on the standard WP Twenty-Twenty-four theme, delete it, and look in the inspect tab. You will clearly see empty tags as WooCommerce tries to render attachments by ID and fails to retrieve them as they were deleted. So it just displays the empty string inside the a and img tags. Still, the ids of deleted attachments remain inside the product gallery; they’re present in the database. WooCommerce tries to render those attachments and creates separate tags and blocks for them. That block just has zero width and height only because of CSS styles in those themes, so that bug is just hard to notice visually. But you can still look inside the source code, like I showed in my screenshot. You can still var_dump the actual product gallery attachment IDs using $product->get_gallery_image_ids() to find out that the product gallery contains attachment IDs that do not exist anymore. You can even place some CSS code to add some width and height explicitly to the product thumbnail, and you will see that there are some empty image tags in there. WooCommerce does not clear the deleted attachment IDs from products or category galleries. Please let me know when you will fix this issue that can be replicated even on a standard WP theme with clean WooCommerce installed.

    Thread Starter danyloliptuha

    (@danyloliptuha)

    Please see the screenshot attached in my previous message and read again my instructions. I do not have any plugins installed on my site except WooCommerce, I have the standard WordPress theme and I can replicate that issue any time in any environment. Please admit that it`s a bug in WooCommerce and please let me know when this will be fixed.

    Kind regards,

    Thread Starter danyloliptuha

    (@danyloliptuha)

    Please let me know when the described issue will be fixed. Thanks in advance!

    Kind regards, Danylo

    Hey, @danyloliptuha!

    Thank you for bringing this to our attention!

    To ensure that we can assist you further, could you please create a new ticket on our support page and include the forum thread link? This will allow our team to review your specific issue and provide you with the best possible solution. You can do this by going to WooCommerce.com > MY profile > Support

    Have a wonderful day!

    Thread Starter danyloliptuha

    (@danyloliptuha)

    Hey, @carolm29 @anastas10s.

    I’ve already contacted WooCommerce support using this forum. Please let me know when this issue will be fixed as its global issue that can be replicated by anyone, not just me. I don`t want to create a new ticket where I must describe the exact same things I already said here. Could you please help me here on the support forum?

Viewing 15 replies - 1 through 15 (of 22 total)
  • You must be logged in to reply to this topic.