Hello,
I think it’s because of this line :
$selected_category = (int) $rule['My Product Category Name'];
It’s not an integer and it should be ‘value’ instead of ‘My Product Category Name’ I think, so :
$selected_category = (string) $rule['value'];
Works for me.
Regards,
Deodat