Active
Project:
Views PHP
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
3 Jul 2014 at 09:06 UTC
Updated:
1 Apr 2017 at 10:03 UTC
Jump to comment: Most recent
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 commentedHallo I'm also interested in passing variable from php field to php filter.
Have you found a solution redhatusr?
Thanks
Comment #2
redhatusr commentedno i haven't found anything yet
Comment #3
UksusoFF commentedAny suggestions now?