I’m working on a WooCommerce site and I’m looking to automate a specific process. After each product import via a CSV file, I want to automatically link each product to a custom post type (CPT) using a shared metadata (‘Agency ID’).
Here’s what I’m aiming to achieve:
Automated Linking: Each product imported via CSV should be automatically connected to a ‘Agencies’ CPT post based on the shared Agency ID.
Metadata Updating: After import, the system should check if the Agency ID from the product matches any of the ‘Agencies’ posts and link the product to this post by saving the post’s ID in the product’s metadata.
My questions are:
Is there a WooCommerce hook or function I can use to intercept the data right after it’s imported via CSV?
How can I write a script or use a plugin to create this automatic connection between products and agency posts based on the Agency ID?
Has anyone implemented a similar feature and could share some code snippets or advice?
Any help or guidance on how to proceed would be greatly appreciated. I am open to solutions involving existing plugins or custom development.
Thank you in advance for your time and assistance.
Jérémy PHETSOMPHOU is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.