• Resolved thewks

    (@thewks)


    Hello, how can I set in import, if is product on sale? I have only these values <WITH_DISCOUNT> 1 </WITH_DISCOUNT> or <WITH_DISCOUNT> 0 </WITH_DISCOUNT> in xml feed. Is there some solution? Thank you.

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

    (@wpallimport)

    Hi @thewks

    As far as I know the only way to mark a product as “on sale” is to set a sale price that’s lower than the regular price. Does your feed have a sale price? If not, what exactly are you wanting to do with the price when “WITH_DISCOUNT” is set to 1?

    Thread Starter thewks

    (@thewks)

    Hello, thank you for fast reply. My feed does not have sale price.

    I need, if is value WITH_DISCOUNT for example set to 1 – show sale badge. Is it possible?

    Plugin Author WP All Import

    (@wpallimport)

    Hi @thewks

    I need, if is value WITH_DISCOUNT for example set to 1 – show sale badge. Is it possible?

    You can only show the sale badge if you have a sale price lower than the regular price, so you’d have to use a custom PHP function for this: http://www.wpallimport.com/documentation/advanced/execute-php/.

    The idea would be to use a custom function like this:

    function my_return_price( $price, $with_discount, $field ) {
        if ( $with_discount == 1 ) {
            return ( $field == 'regular_price' ) ? number_format( $price * 1.1, 2 ) : $price;
        } elseif ( $with_discount == 0 ) {
            return ( $field == 'regular_price' ) ? number_format( $price, 2 ) : null;
        } else {
            return $price;
        }
    }

    This is only an example, so you may need to adjust it, but the idea is to mark up the regular price by 10% in the case that “with discount” is 1. This function would be used in each price field like this:

    [my_return_price( {price[1]}, {with_discount[1]}, "regular_price" )]
    [my_return_price( {price[1]}, {with_discount[1]}, "sale_price" )]

    Just make sure to change {price[1]} and {with_discount[1]} to the correct elements from your file.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Product on sale’ is closed to new replies.