Skip to content
Advertisement

Find the Function that saves the image of product variation-WooCommerce

I’m trying to update the function that handles the upload of the image to variation product ![image variation] https://i.imgur.com/reNn6x7.png

I thought that the code that handles it is :

JavaScript

inside the class-wc-rest-product-variations-controller.php

but any modification at this function is not changing the way that the file is uploaded.

the idea is to upload the image and apply the same variation image to each variation available, but can’t find the function that saves the image to the product.

@edit after itzmekhokan reply

i created a plugin that add action to woocommerce_save_product_variation

JavaScript

this code apply the same image_id to all variations that has the same color attribute

Advertisement

Answer

Its WC_Meta_Box_Product_Data::save_variations( $post_id, $post ) within file class-wc-meta-box-product-data.php.

And –

JavaScript

image_id basically storing the each variation image id. Check the functionalities first, then I think you can do your modifications using this do_action( 'woocommerce_save_product_variation', $variation_id, $i ); hook.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement