• Resolved amjulash

    (@amjulash)


    Hi, I am trying to update woocommerce products stock from an external source using schedule import, the external source is also an e-commerce website but different CMS. So what I am doing is generating a CSV file of products stock on the external website server and updating stocks using scheduled wp import all.

    Now I am trying to figure out how to skip stock update which already sold or has same level of stock on my wp website.

    For example if ‘ProductA’ had 1 stock and it got sold on my wp website, then in woo-commerce that product stocks become 0. So I need to skip stock updates for my wp e-commerce product which has 0 items in stock and has the same level stock as the stocks of external source.

    Otherwise from external website when a product which has 0 stock get updated with external source’s 1 stock, the customer will be able to purchase sold item again.

    I tried PHP if else condition like this below:

    [IF({ $_stock [.=[MATH({product_in_stock[1]},”-“,{product_ordered[1]})]]})][ELSE][MATH({product_in_stock[1]},”-“,{product_ordered[1]})][ENDIF]

    With $_stock I am trying to get the existing stock value of the wp website (don’t know how to get existing value, looked around documentation but could not find anything). ‘[MATH({product_in_stock[1]},”-“,{product_ordered[1]})]‘ is to calculate total and sold stock from external source.

    Can anyone please check if there any problem with the above method and guide me.

    Best Regards
    Julash

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Skip import if match existing value with imported value’ is closed to new replies.