• Payment Plugins Poll

    We need your feedback on the need for updated payment plugins. Please go here and give us your feedback.

  • Joomla 5.1

    For running J!5.1 you must install Fabrik 4.1
    See also Announcements

  • Subscription and download (Fabrik 4.1 for J!4.2+ and J!5.1) are working now

    See Announcement
    Please post subscription questions and issues here

    We have resolved the issue with the J! updater and this will be fixed in the next release.

sum of values of an element of a repeating group

enrb

Member
I'm trying to do the sum of values of an element of a repeating group,
I first want to multiply two values of two elements of a repeating group and then add the result, to do this I wrote this code in a calc element:


$products = array_map(function($a, $b) {

if (strpos($b, '1') !== false) {
$b = 1;
} else {
$b = 0;
}

return $a * $b;
}, $data['mylist___numberqty_raw'], $data['mylist___flagyes_raw']);


$sum = array_sum($products);

return $sum;



I activated the ajax calculation, but when I insert a number in the mylist___numberqty_raw element, the calculation continues to run and returns nothing.

Am I doing something wrong in my code?
 
Nothing, sorry, I solved it...
Here is the correct code I use:

$products = array_map(function($a, $b) {

if (strpos($b, '1') !== false) {
$b = 1;
} else {
$b = 0;
}

return $a * $b;
}, $data['mylist___numberqty_raw'], $data['mylist___flagyes']);


$sum = array_sum($products);

return $sum;
 

Members online

No members online now.
Back
Top