• Resolved Marco1970

    (@marco1970)


    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

    (@khungate)

    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:
       function custom_mailchimp_resync() {
           $service = new MailChimp_Service();
           $service->removePointers();
           MailChimp_WooCommerce_Admin::instance()->startSync();
           $service->setData('sync.config.resync', true);
       }
    1. 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:
       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.

    1. 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.
    2. 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

    (@marco1970)

    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

    (@khungate)

    Hi @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 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.