Title: API to resync
Last modified: January 23, 2024

---

# API to resync

 *  Resolved [Marco1970](https://wordpress.org/support/users/marco1970/)
 * (@marco1970)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/api-to-resync/)
 * Hi all,
 * thanks for great work!
 * Q: is there an function / API method that I can use to programmatically trigger
   a products re-sync from within my plugin code? something like:
 * mailchimp_product_resync();
 * TY in advance for kind help
 * M

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Support [khungate](https://wordpress.org/support/users/khungate/)
 * (@khungate)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/api-to-resync/#post-17388798)
 * Hi there, that’s a great question! To implement the resync functionality, you
   would indeed need to add the provided code to your plugin. This code should be
   placed in a custom function within your plugin’s files, not in the `functions.
   php` file of your WordPress theme. This ensures that the functionality is tied
   to your plugin and remains intact regardless of theme changes.
 * Here’s a step-by-step guide:
    1. **Create a Custom Function:** Open your plugin’s main PHP file. Create a new
       function that includes the provided code snippet. For example:
 *     ```wp-block-code
          function custom_mailchimp_resync() {
              $service = new MailChimp_Service();
              $service->removePointers();
              MailChimp_WooCommerce_Admin::instance()->startSync();
              $service->setData('sync.config.resync', true);
          }
       ```
   
    2. **Hook the Function:** To execute this function, hook it to a specific WordPress
       action or a custom trigger within your plugin. For example, if you want this
       to run on a specific admin action, you might use:
 *     ```wp-block-code
          add_action('admin_init', 'custom_mailchimp_resync');
       ```
   
 * Replace `'admin_init'` with the appropriate action hook that suits when and where
   you want the resync to occur.
    3. **Test the Functionality:** Before deploying this on a live site, test it on
       a staging environment to ensure it works as expected without causing any issues.
    4. **Handle Execution Context:** Ensure that this function is only called in appropriate
       contexts to avoid unintended syncs. For instance, you might want to include 
       conditionals that check whether it’s the right time or situation to initiate
       a resync.
 * Remember, directly editing plugin files can lead to issues if not done correctly.
   If you’re not comfortable making these changes, it’s always a good idea to consult
   with a developer or the plugin support team.
 * Let me know if you need further assistance!
 *  Thread Starter [Marco1970](https://wordpress.org/support/users/marco1970/)
 * (@marco1970)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/api-to-resync/#post-17435523)
 * Hi,
 * sorry for late reply, and thank you so much for the reply, super helpful! one
   Q if I may:
 * is the re-sync always whole? or MC uses internal product IDs and order IDs to
   start from where it left last time?
 * TY
 * M
 *  Plugin Support [khungate](https://wordpress.org/support/users/khungate/)
 * (@khungate)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/api-to-resync/#post-17437497)
 * Hi [@marco1970](https://wordpress.org/support/users/marco1970/), at this time
   the re-sync is started from the beginning. If you have a larger store, we encourage
   folks to use the [WPI CLI](https://github.com/mailchimp/mc-woocommerce/wiki/Advanced-Queue-Setup-In-CLI-mode)
   for faster syncing capabilities.
 * Please let us know if you need anything else.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘API to resync’ is closed to new replies.

 * ![](https://ps.w.org/mailchimp-for-woocommerce/assets/icon-256x256.png?rev=1509501)
 * [Mailchimp for WooCommerce](https://wordpress.org/plugins/mailchimp-for-woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/mailchimp-for-woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/mailchimp-for-woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/mailchimp-for-woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/mailchimp-for-woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/mailchimp-for-woocommerce/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [khungate](https://wordpress.org/support/users/khungate/)
 * Last activity: [2 years, 3 months ago](https://wordpress.org/support/topic/api-to-resync/#post-17437497)
 * Status: resolved