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.
In the PHP FIELD I can tell if a product has discount or not because I choose to display the discount from the field formatter. (I think you can't get the discount value from FILTER because the discount value is not stored in a field but calculated on the fly by rules and can be shown by field formatter.)
This information created with PHP FIELD I need to pass it to the PHP FILTER to control if a product must needs to be shown or not
PHP FIELD CODE
<?php
// $var1 will take value 0.00E or -94.99E (the last value is an example)
$var1 = strip_tags($data->field_commerce_price[0][rendered]);
// $var2 will take value 0 or -
$var2 = mb_substr($var1, 0, 1, 'utf-8');
// set $static = 0 or 1, if PHP FILTER can see this then can filter discount products
if ($var2=="-") { $static = "1"; echo "DISCOUNT!"; } else {$static = "0"; }
?>
PHP FILTER CODE
// all 4 variables gives output nothing
dpm($row->_field_data['nid']['entity']->field_commerce_price[0][rendered]);
dpm($data->_field_data['nid']['entity']->field_commerce_price[0][rendered]);
dpm($data->field_commerce_price[0][rendered]);
dpm($static);
if ($static=="1") { return FALSE; } else { return TRUE;}
So how PHP field send a string to PHP FILTER???
or
Is there any to create a filter function using the PHP FIELD?
Comments
Comment #1
arzuga CreditAttribution: arzuga commentedHallo I'm also interested in passing variable from php field to php filter.
Have you found a solution redhatusr?
Thanks
Comment #2
redhatusr CreditAttribution: redhatusr commentedno i haven't found anything yet
Comment #3
UksusoFF CreditAttribution: UksusoFF commentedAny suggestions now?