• Resolved cleatsandcode

    (@cleatsandcode)


    Hi,

    I’m having an issue where stock levels are being pushed correctly but the second site needs duplicate skus as some stock is on one area and others in a more private one with different pricing. One is updating fine, but another doesn’t update.

    Is this a known thing and is there perhaps a filter/function I may need to include to update all products with the exact sku?

    Thanks

    • This topic was modified 2 years, 8 months ago by cleatsandcode.
Viewing 1 replies (of 1 total)
  • Plugin Author WP Trio

    (@wooelements)

    Hi,

    I’m afraid duplicate SKUs are not supported by Stock Sync and this assumption has been hard-coded into the plugin in a way that makes it not possible to add native support in future either. WooCommerce also enforces unique SKUs by default (but there is a hook to disable it of course).

    However, this doesn’t mean you couldn’t make it work with a little bit of customization. If you have two products with the same SKU and one is updating correctly, it could be possible to hook into syncing process and trigger stock update for the other as well. You can use this hook which is fired after Stock Sync receives update request from the other site:

    do_action( "woocommerce_rest_insert_{$this->post_type}_object", $object, $request, false );

    Post type in this hook would be product or product_variation if I recall correctly. Simply check if product’s ($object) SKU is present in other products on the site and then update stock of those products.

    Please note that if your code triggers woocommerce_product_set_stock action when you sync stock across same SKUs, that will likely trigger unnecessary syncing. So you might have to update stock via post meta directly if it syncs unnecessarily.

    This obviously will need a bit of coding from your end but I hope this helps even a little. Closing this now but feel free to reopen if you have any questions.

Viewing 1 replies (of 1 total)
  • The topic ‘Duplicate sku issue?’ is closed to new replies.