Closed stefanfriedrich closed 1 year ago
correct purchasableId shows up in "_purchasableIds" from the sale.
@stefanfriedrich can you confirm the product is marked as 'promotable' on the product edit page?
@stefanfriedrich can you confirm the product is marked as 'promotable' on the product edit page?
@lukeholder Yes
@lukeholder Hope that helps.
Product:
I also can't add the sale to product itself on the product-site. (Maybe because there are variants, but that's not the main-problem now.)
Variant:
Sale:
Template:
(removed the biggest part of the other products that are related to that sale, that's why it shows up as 0, 1, 24 in the screenshot)
@lukeholder problem seems to be here: src/services/Sales.php
// Category match if (!$sale->allCategories) { $relatedTo = [$sale->categoryRelationshipType => $purchasable->getPromotionRelationSource()]; $saleCategories = $sale->getCategoryIds(); $relatedCategories = Category::find()->id($saleCategories)->relatedTo($relatedTo)->ids();
if (empty($relatedCategories)) {
return false;
}
}
returns false also if no categories exist. quickfix right now is to set all categories active.
The problem is that you are not selecting any categories in the matching items setting. You should turn on the All categories
lightswitch input if you are not selecting a category.
Let us know if that works. @stefanfriedrich
@pdaleramirez => returns false also if no categories exist. not sure if this should be the case. works as written before.
@stefanfriedrich, if no categories exist, the value of the $sale->allCategories
attribute returns to true
, making all purchasable on sale. Turning on the All categories
light switch should resolve the issue.
@pdaleramirez @lukeholder turning it on resolves the issue, but not the problem: if no categories exist it also should return true, not false.
This definitely need some work. Confusing. If I have selected a purchasable why do I need to select a category? That would lead me to believe that it now applies to all purchasable in that category.
What happened?
Description
I want to add a sale to certain variants, not to all. This doesn't work. There are no other discounts/sales active. All products are promotable. If I chose "all purchasables" and "all categories" - and only then - it works as expected. I have no categories so far. If I chose all purchasables by hand - also doesn't work.
Steps to reproduce
Expected behavior
variant.onSale should be true
Actual behavior
variant.onSale should is false
Craft CMS version
4.3.10
Craft Commerce version
4.2.5.1
PHP version
No response
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions