• Resolved dkutcher

    (@dkutcher)


    I deal with a lot of one-off products, or products that are duplicates but need to be treated as individual SKUs. When I go to add products in Mailchimp to a newsletter, it keeps ALL of those out of stock items in the system. Is there a way to remove out of stock items from the sync, or on the front end, limit to in-stock items only?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Jordan Rich

    (@builtbyjordan)

    @dkutcher Hey there, By design product statuses that do sync to Mailchimp include Backorder,?Out of Stock,?Draft, &?Published

    Product statuses that?do not?sync to Mailchimp:?Trashed?&?Pending Review

    We understand that there are cases where a more custom solution is necessary. This is why we provide a filter for ignoring products or orders as needed see our documentation on this in Github.

    There currently isn’t a way to provide a global policy for limiting to in-stock items only. However, I’ve brought this up with our internal team for perhaps an even more specific filter but here in support we can’t make in guarantee if or when that would be available.

    Thanks for reaching out.

    Thread Starter dkutcher

    (@dkutcher)

    Thank you @builtbyjordan , I hope that future dev on the plugin allows for these options.

    My attempt at using the filter seems to be failing… attempting to verify against an array of product IDs that are no longer in stock. What am I doing wrong? The plugin just hangs on sync.

    function maybe_exclude_product_from_syncing( $product_id ): bool {
    $outofstock = array(2562,2721,2055,2726,2454,2406,2095,2602,2120,2900,2901,2487,2488,2401,2528,2032,2784,2793,2850,2188,2043,2905,2486,2512);
    if(in_array($product_id, $outofstock)){
    return false;
    }
    }
    add_filter( ‘mailchimp_should_push_product’, ‘maybe_exclude_product_from_syncing’, 10, 1 );

    Plugin Support Jordan Rich

    (@builtbyjordan)

    Hey @dkutcher

    Looks like the bool will need to be removed.

    function maybe_exclude_product_from_syncing( $product_id ) {
    $outofstock = array(2562,2721,2055,2726,2454,2406,2095,2602,2120,2900,2901,2487,2488,2401,2528,2032,2784,2793,2850,2188,2043,2905,2486,2512);
    
    if ( in_array( $product_id, $outofstock ) ) {
    return false;
    }
    
    return true;
    }

    or this option

    function maybe_exclude_product_from_syncing( $product_id ) {
    $product = wc_get_product( $product_id );
    
    if ( $product->get_stock_status() === 'outofstock' ) {
    return false;
    }
    
    return true;
    }
    add_filter( 'mailchimp_should_push_product', 'maybe_exclude_product_from_syncing', 10, 1 );

    Also please keep in mind this filter will not remove the products already in Mailchimp. It will simply filter the products from getting to Mailchimp.

    Plugin Support khungate

    (@khungate)

    Hi @dkutcher, we just wanted to check back with you to see if you were able to get this resolved. Please let us know when you get a moment, we’ll be happy to help troubleshoot further if necessary.

    Thread Starter dkutcher

    (@dkutcher)

    No, this isn’t resolved, but doesn’t seem like it’s possible to be resolved. There’s no way to “clear the store” and then only sync in-stock items, so it just leaves them there which doesn’t accomplish anything unfortunately.

    Plugin Support khungate

    (@khungate)

    Hi @dkutcher,

    Thank you for getting back to us. After reviewing the issue, our suggestion is to try uninstalling the plugin and then reinstalling it while keeping your custom filter in place. This should allow the filter to function properly and exclude out-of-stock products from the sync.

    As an alternative, you might consider a custom-coded solution. A sample code that can be integrated into your site is available here: https://codeshare.io/OdMpjr, which will remove products from Mailchimp and resync with the desired filters. It can be executed with a URL structured like this: https://yoursite.com?remove-all-products.

    While we are considering adding a feature to handle this issue in a future update of our plugin, we typically do not issue custom code and cannot guarantee if or when such a feature will be implemented. For any specialized customization, we recommend working with a third-party developer.

    Should you need any further assistance, don’t hesitate to reach out. Thank you for using our plugin.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Remove out of stock or other products from sync?’ is closed to new replies.