Update pods fields by code
-
Hi,
I have the woocommerce products post type extended with a pod (pod name = product).
The fields are showing fine on the edit product pages. I am able to update and save them. The values are copied to the translations accordingly. Great.Now I’m trying to fill the pod fields by code. That’s where I’m struggling with. I tried to create a function like this:
function update_product_meta_fields(){ $post_id = get_the_ID(); $product = wc_get_product( $post_id ); if (get_the_id() == $product) { $dimensions = "heel groot"; $data = array( 'dimensions' => $dimensions, ); $pod = pods('product'); $pod->save($data); } } add_action( 'woocommerce_process_product_meta' , 'update_product_meta_fields', 1000, 2);
The code is partially from an example on the pods.io site.
The array would be filled with more values. The code example is just to try it out.
The value “Heel groot” in the field “dimensions” is not showing. Clearly I’m missing something. It looks like I’m not able to select and work with the right product ID.I hope I made myself clear as English is not my native…..
Please advice.
- The topic ‘Update pods fields by code’ is closed to new replies.