commerce icon indicating copy to clipboard operation
commerce copied to clipboard

[3.x]: hasSales attribute not filtering out items that are not promotable

Open mcclaskiem opened this issue 1 year ago • 5 comments

What happened?

Description

I have a weird issue where items that are not promotable are showing up when I use the hasSales attribute set to true on a variant query:

{% paginate craft.products({
    relatedTo: params,
    limit: 15,
    order: 'sku asc',
    with: [['frontImage', {withTransforms: ['viewAll']}]],
    hasVariant: variantQuery
}) as pageInfo, products %}


 {% set variantQuery = {
    hasStock: true,
    hasSales: saleItems ? true : false
} %}

I have a query parameter that is being passed from the frontend to determine if the user is looking for on sale items or not

Steps to reproduce

Expected behavior

Expect that returned results will all have active sales when user requests "sales items"

Actual behavior

Showing all items related to their filtered query

Craft CMS version

3.9.5

Craft Commerce version

3.4.23

PHP version

7.4

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

mcclaskiem avatar Jun 22 '24 16:06 mcclaskiem

I was ~able~ unable to reproduce this issue:

{% paginate craft.products.hasVariant({hasSales: true}).limit(100) as pageInfo, pageProducts %}

this showed items on sale, and passing false showed items not on sale.

Should the variantQuery variable be set before you pass it into the pagination query?

lukeholder avatar Jun 25 '24 05:06 lukeholder

The variantQuery variable is set before being passed I just pasted both code snippets in no particular order.

To add some more context:

I have a sale that is applied to certain category of products, basically a specific designer. We don’t want all of the products from that designer to be on sale so I have some set with “promotable” disabled however those products still show up on the sale page.

On Tue, Jun 25, 2024 at 01:15 Luke Holder @.***> wrote:

I was able to reproduce this issue:

{% paginate craft.products.hasVariant({hasSales: true}).limit(100) as pageInfo, pageProducts %}

this showed items on sale, and passing false showed items not on sale.

Should the variantQuery variable be set before you pass it into the pagination query?

— Reply to this email directly, view it on GitHub https://github.com/craftcms/commerce/issues/3553#issuecomment-2187995611, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABVFXLZTQNRK4RUQGXBXJF3ZJD4HDAVCNFSM6AAAAABJXRV67CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBXHE4TKNRRGE . You are receiving this because you authored the thread.Message ID: @.***>

mcclaskiem avatar Jun 25 '24 05:06 mcclaskiem

I made a typo on my last response. I was UNable to reproduce. Could you send you database backup, composer.json and composer.lock to [email protected] so we can take a look. Please reference this issue when you submit the support ticket. Thanks.

lukeholder avatar Jun 26 '24 01:06 lukeholder

@lukeholder Just sent it over via email. Thanks for taking a look!

mcclaskiem avatar Jun 26 '24 01:06 mcclaskiem

Hi @mcclaskiem

We have just released Commerce 3.4.24 which has a fix for this included.

Please update to this version and let us know if you have any further issues.

Thanks!

nfourtythree avatar Jul 03 '24 14:07 nfourtythree

I have two craft commerce 3 websites and there is an updated 3.4.24 I have tried to run this on both sites using composer update

The composer requirement looks like this; "craftcms/commerce": "^3.4.23",

But it keeps telling me there is an update 3.4.24 in the backend. But it looks like it is installed to 3.4.24

Any ideas?

Thanks.

terryupton avatar Jul 10 '24 12:07 terryupton

Hi @terryupton

Apologies for this, looks like there was a mismatch of version number in the composer.json.

We have pushed version 3.4.25 which should fix this issue.

Thanks!

nfourtythree avatar Jul 10 '24 13:07 nfourtythree