kilbot / WooCommerce-POS

:bangbang: All development now at https://github.com/wcpos.
http://wcpos.com
GNU General Public License v3.0
353 stars 125 forks source link

Add filter to thumbnail image #155

Closed nickrouty closed 7 years ago

nickrouty commented 7 years ago

We store an external image in post meta for our products. We weren't able to hook into the prior calls to perform what we were needing to accomplish due to the post ID / product ID not being available globally. Due to this, the easiest thing would be to be able to view what was about to be returned via the get_thumbnail function, along with the product ID. We then take the ID, check if a product image exists in our post meta, and if so, update the return value.

kilbot commented 7 years ago

Hi. Thanks for the contribution. There is already a filter for this which is part of WooCommerce core. Please use the woocommerce_placeholder_img_src filter.

kilbot commented 7 years ago

Sorry, just re-read your requirement and see that you need a product_id ... this is probably available in the global $post object ... but having a pos filter would also make sense. Can you make the filter woocommerce_pos_product_thumbnail and move it to this line and then I will merge this pull request.

nickrouty commented 7 years ago

I've created a new request, I'm not the greatest at github, sorry if I was able to simply modify this one. #156

I wasn't able to access the value via the global $post, I had initially tried to accomplish the task by utilizing existing filters without success. Not sure if the post wasn't being set in the loop for wc-pos or what was going on.