shopware icon indicating copy to clipboard operation
shopware copied to clipboard

Missing bool casting in CustomerCustomFieldRule.php

Open michnhokn opened this issue 1 year ago • 2 comments

PHP Version

8.0

Shopware Version

6.4.11.1

Expected behaviour

In the rule builder it should be possible to set a bool value for comparison with a customer custom field.

Actual behaviour

This is not working. Because of the missing cast the real value and the expected value are always compared wrong: true === 'true'

How to reproduce

  1. Create a custom field for a customer with switch or bool type
  2. create a rule for a payment method or something else which only should appear if the customer has the corresponding custom field set.
  3. It will not appear even if the custom field is set. image

michnhokn avatar Jul 27 '22 13:07 michnhokn

This is the line where the (bool) cast should be applied: https://github.com/shopware/platform/blob/dea144715a735c2b6f53098b9c92f9eeebc16c21/src/Core/Checkout/Customer/Rule/CustomerCustomFieldRule.php#L164

michnhokn avatar Jul 27 '22 13:07 michnhokn

Could please provide a PR with your proposed fix? And if possible also with an unit test, that fails without that fix.

keulinho avatar Jul 28 '22 06:07 keulinho

There is already a PR, i will close this

shyim avatar Aug 18 '22 13:08 shyim