• Resolved piotrczapla2jb

    (@piotrczapla2jb)


    First of all thank you, for making the plugin. The code is very nice, the best so far (few other plugins including wpdesk-omnibus).

    The issue describe here is present in other plugins as well. But I decided to report it here as I like your code.

    The Omnibus directive ask for the last lowest price before, current price drop in period of 30+ days before the price drop. Which is not the lowest price in 30 days. The difference is apparent when the current price is as well the lowest price.

    Let me give you an example: If a regular price of product is 100 eur, and it was increased to 200eur a week before BF, then lowered to 99 eur. The plugin should show the previous lowest price of 100 eur not 99 eur. So a customer can see that the discount of 50% is false, and the actual discount is 1%.

    The idea was to kill the practice of going up with prices directly before events like Black Friday to make the discounts appear larger than they are.

    With current implementation of showing last price we work against the directive, as the last price information is going to look like reinforcement that this is the best offer since 30 days. While the intention was to show the real discount value.

    Here is how this directive was implemented in Poland:

    W ka?dym przypadku informowania o obni?eniu ceny towaru lub us?ugi obok informacji o obni?onej cenie uwidacznia si? równie? informacj? o najni?szej cenie tego towaru lub tej us?ugi, która obowi?zywa?a w okresie 30 dni przed wprowadzeniem obni?ki.


    https://isap.sejm.gov.pl/isap.nsf/download.xsp/WDU20220002581/T/D20222581L.pdf

    I can see how the way this plugin currently implements the directive might be alluring to some merchants as it allows them to appear Omnibus compliant while being able to still artificially increase the discounts. But It is going to bite them in the long run.

    Would you consider adding an option to be compliant with the directive and showing the actual price before the current discount?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Perfectly Project

    (@perfectlyproject)

    Hi,

    First of all I would like to say thank you for appreciating the work!

    Yes, That feature is on board and waiting for implementation.

    I will give people two options:
    – Show the lowest price in last 30 days when product has been marked as on sale. (This option will be set as default)
    or
    – Show the lowest price in last 30 days

    Thread Starter piotrczapla2jb

    (@piotrczapla2jb)

    Thank you for considering adding this feature.

    I was thinking abit about this and I will go live with a small tweak to the sql used in findLowestHistoryPriceIn30Days

    From this:

    'SELECT * FROM ' . HistoryPrice::getPrefixedTable() . ' WHERE product_id = %s && date >= %s ORDER BY price ASC LIMIT 1

    To something like

    WITH SELECT * FROM HIST_TBL WHERE product_id=%s date >= %s AS range
    SELECT * FROM range WHERE date < (SELECT max(date) FROM range ) ORDER BY price LIMIT 1

    Once I have tested the code above I will post it here.

    Update: If i’m not mistaken the current code and my version above have flaw that assumes that date field is storing the end date of the price period while it is storing the start date. So if you have low price set for 100 days and then push it up a day before Black friday, both selects will fail to pick it up as the lowest price.

    Thread Starter piotrczapla2jb

    (@piotrczapla2jb)

    In case it will be useful for someone here is how to add all historical prices to the history table

    INSERT INTO wp_pwp_wco_history_prices (product_id, price, date) 
    WITH last_price AS (
    	SELECT DISTINCT
    		FIRST_VALUE(id) OVER w AS id,
    		FIRST_VALUE(product_id) OVER w AS product_id,
    		FIRST_VALUE(price) OVER W AS price,
    		FIRST_VALUE(date) OVER w AS xdate
    	FROM
    	wp_pwp_wco_history_prices WINDOW w AS (PARTITION BY product_id ORDER BY date DESC)
    ),
    is_variant AS (
    	SELECT
    		post_parent as ID
    	FROM
    		wp_posts
    	WHERE
    		post_type = 'product_variation'
    	GROUP BY
    		post_parent
    )
    SELECT
    	P.ID AS product_id,
    	CAST(M.meta_value as DOUBLE) AS price,
    	P.post_modified AS date
    FROM
    	wp_posts AS P
    	INNER JOIN wp_postmeta AS M ON (P.ID = M.post_id
    		AND M.meta_key = '_price')
    	LEFT OUTER JOIN last_price AS L ON (P.ID = L.product_id)
    WHERE 1=1
    	AND (M.meta_value != L.price OR L.price IS NULL)
    	AND P.ID NOT IN (select * from is_variant) -- for some reason this does not work as LEFT OUTER JOIN
    	AND post_type = 'product'
    	AND post_status in('publish', 'draft')
    ORDER BY
    	post_date;
    
    
    Thread Starter piotrczapla2jb

    (@piotrczapla2jb)

    Since the bug fix is already in repo I will mark this as resolved. Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Incorrect price shown when current discount is the lowest.’ is closed to new replies.