Search code examples
woocommercewpallimport

Woocommerce WP allimport


I'm using WPallimport to import some products into WooCommerce with xml. What i want to do is look at the "RetailPrice" of xml and if is smaller than e.g 20€ and "Availability=0" then "Allow Backorders?" is "No" else "Yes"

[IF({RetailPrice[1][.>"20,00"]AND{Availability[1][.="0"])][THEN][ΝΟ][ELSE][ΥΕΣ][ENDIF]

Thanks in advance


Solution

  • You can write a custom PHP function that returns the appropriate value for the backorder field and call it from the backorder text field in the import wizard, something like this:

    [figure_out_backorder_status({RetailPrice[1]}, Availability[1])]
    

    You would add something like this to the Function Editor on the Edit Import page:

    function figure_out_backorder_status( $price, $availability ) {
      // your logic:
      return 'Yes';
    }
    

    Documentation:

    https://www.wpallimport.com/documentation/developers/custom-code/inline-php/