craftcms / commerce

Fully integrated ecommerce for Craft CMS.
https://craftcms.com/commerce
Other
215 stars 169 forks source link

[5.x]: Catalog Pricing Rules not linkable to entry/category? #3544

Open bartrylant opened 2 weeks ago

bartrylant commented 2 weeks ago

What happened?

Description

In Commerce 4, sales (now called catalog pricing rules) could be linked to products related to a certain category. This was super easy for shop editors. They could relate certain products to a "super mega sale" category, or select certain brands (every product had a brand category relationship) to give a discount on just these brands. For Commerce 5, this doesn't seem to be the case anymore.

When I select Store Management > Pricing Rules > Match Purchasable > Related to > Category and select a category, the promotion is not applied to the products related to that category. Does Commerce just look at direct variant relationships instead of product relationships? More so: I entrified all categories, but if I do Store Management > Pricing Rules > Match Purchasable > Related to > Entry I can only select one entry at a time (instead of selecting multiple). I now have to add every related entry as a new condition.

Expected behavior

Show promotional price for all products related to a certain category or entry.

Actual behavior

Promotional price doesn't get shown when adding conditionals. It looks like conditions don't work.

What I need

Be able to select a category/product that relates to products. Show the promotional price on products related to the category/entry, like it was in Commerce 4. Be able to select multiple entries when relating to an entry.

Scherm­afbeelding 150

This works

Scherm­afbeelding 149

This does not work

Craft CMS version

Craft Pro 5.2.0

Craft Commerce version

5.0.10.1

PHP version

8.3.3

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

-

linear[bot] commented 2 weeks ago

PT-1839 [5.x]: Catalog Pricing Rules not linkable to entry/category?

nfourtythree commented 2 weeks ago

Hi @bartrylant

Thank you for your message and feedback.

We are currently working on extra features that will solve this in the upcoming Commerce 5.1 release.

If you are in need of this functionality right now you do have an option, although I understand the solution below is not absolutely ideal.

If you add your relationship field to both the product layout and the variant layout. You can then in the Product::EVENT_AFTER_SAVE get all the variants for that product and update their relationship field with the same data and save them with Craft::$app->getElements()->saveElement($variant, false). This will save the same data and also trigger the update of catalog pricing.

This way you the relationship will also live on the variant and you can use the "Related to" rule as you mentioned about.

Again, I realise this isn't the smoothest way but is a solution for now why the functionality is being worked on.

I will keep this issue open and reference it when progress is being made with the 5.1 feature.

Thanks!

WHITE-developer commented 2 weeks ago

Hi @nfourtythree, Is there any ETA about when 5.1 would be released?

lukeholder commented 2 weeks ago

@WHITE-developer no exact time sorry but in the next few weeks.