Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When adding multiple SKUs for a product discount at: /admin/commerce/store/discounts
the rule never fires due to the fact that the condition only evaluates to TRUE for a single product. To make it work it needs something like this:
/**
* Build callback for commerce_product_contains_products.
*
* @param EntityDrupalWrapper $wrapper
* Wrapped entity type given by the rule.
* @param array $sku
* Product sku returned by rule condition.
*
* @return bool
* True if condition is valid. false otherwise.
*/
function commerce_product_contains_products_build(EntityDrupalWrapper $wrapper, $sku) {
if ($wrapper->getBundle() == 'product') {
return (in_array($wrapper->commerce_product->sku->value(), array_map('trim', explode(',', $sku))));
}
return FALSE;
}
Comment | File | Size | Author |
---|---|---|---|
#1 | inline_conditions-product_discount_multiple_products-2037137-2.patch | 965 bytes | perusio |
Comments
Comment #1
perusio CreditAttribution: perusio commentedHere's a patch.
Comment #2
jkuma CreditAttribution: jkuma commentedThanks perusio for your contribution. The patch is working well.
Comment #3
jkuma CreditAttribution: jkuma commentedCommitted in 7.x-1.x-dev branch.
Comment #5
MD3 CreditAttribution: MD3 commentedI believe this needs to be re-opened give the following:
[2420341]