• Resolved Millvi

    (@millvi)


    Hi,

    I wonder if it′s possible to set a WooCommerce product as featured with xpath on import if the sale price is lower than the regular price?

    My problem is that the product file i′m importing has the columns OriginalPrice and Price with the same amount if the product is sold at regular price and if the product is on sale Price is lower than OriginalPrice.

    Best regards
    Melker

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hi @millvi

    You can use a PHP function in the “Set with XPath” option for the Featured field to do this: https://www.wpallimport.com/documentation/developers/execute-php/.

    Here’s an example function:

    function my_set_featured( $price, $original ) {
        if ( $price == $original ) {
            return "no";
        } elseif ( $price < $original ) {
            return "yes";
        } else {
            return "no";
        }
    }

    You’d need to pass both price elements to the function like so: [my_set_featured({Price[1]},{OriginalPrice[1]})]

    Thread Starter Millvi

    (@millvi)

    Thank you for the solution but I have a questions.

    I′m not following you when you write “You’d need to pass both price elements to the function like so: [my_set_featured({Price[1]},{OriginalPrice[1]})]”
    I′m not sure where to pass this.

    Plugin Author WP All Import

    (@wpallimport)

    Hi @millvi

    You’d need to put the function in the Advanced -> Featured -> Set with XPath field: https://d.pr/dHrukD.

    Thread Starter Millvi

    (@millvi)

    Yes I figured that out just a few minutes ago ??

    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Featured product with xpath’ is closed to new replies.