We need your feedback on the need for updated payment plugins. Please go here and give us your feedback.
For running J!5.1 you must install Fabrik 4.1 See also Announcements
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.
console.log(ids); //outputs an array of the selected row ids
console.log(rows); // outputs a object key'ed on the selected row ids, each value is an object containing the row data.
jQuery.each(rows, function(rowid, row) {
// echo the value of yourtable___yourelement to the console
fconsole(row.yourtable___yourelement);
})
$app = Joomla\CMS\Factory::getApplication();
$ids = $app->getInput()->get('ids', array(), 'array');
$item = $model->getTable();
echo "<pre>";print_r($item);exit;
foreach ($ids AS $myid)
{
$row = $model->getRow($myid);
$element = $row->your-full-elementname;
$element_raw = $row->your-full-elementname_raw;
//echo "<pre>";print_r($row);
}
//exit;
$app = Joomla\CMS\Factory::getApplication();
$ids = $app->getInput()->get('ids', array(), 'array');
foreach($ids as $id)
{
$couponcode = "hello";
$model->updateRow($id, "courses.teachername", $couponcode);
}
//this code update Teachername column of your Courses table with checked row in fabrik list. you must use your own table and column instead of "courses.teachername" and also change $couponcode with your own variable
$coupon= substr(base_convert(sha1(uniqid(mt_rand())), 16, 36), 0, 10);
//in my case you must installed hikaserial but it seems you can edit this line for hikashop only installed
require_once(JPATH_ADMINISTRATOR.'/components/com_hikaserial/helpers/helper.php');
$discountClass = hikaserial::get('shop.class.discount');
$data= new stdClass();
$data->discount_code = $coupon;
//$data->discount_flat_amount = 250;
$data->discount_published = 1;//use your own value
$data->discount_used_times = 1;//use your own value
//$data->discount_flat_amount= 1000;
$data->discount_percent_amount= 10;//use your own value
$data->discount_currency_id = 183;//use your own value
$data->discount_type = "coupon";
$date = new DateTime(null, new DateTimeZone('Asia/Tehran'));//use your own value
$dateTimeZone = new DateTimeZone("Asia/Tehran");//use your own value
$dateTime = new DateTime("now", $dateTimeZone);//use your own value
$timeOffset = $dateTimeZone->getOffset($dateTime);
$newTime = time() + $timeOffset;
$data->discount_start = $newTime;
$data->discount_coupon_nodoubling=2;//use your own value
$data->discount_quota = 1;//use your own value
$result = $discountClass->save($data);
dump($result, 'result');
// dump(get_defined_vars(), 'vars');
$app = Joomla\CMS\Factory::getApplication();
$ids = $app->getInput()->get('ids', array(), 'array');
foreach($ids as $id)
{
//$row = $model->getRow($id);
// dump($row, 'row');
$db = Joomla\CMS\Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select($db->quoteName('discount_code'));
$query->from($db->quoteName('#__hikashop_discount'));
$query->where($db->quoteName('discount_id') . ' = ' . $db->quote($result));
$db->setQuery($query);
$couponcode = $db->loadResult();
// dump($query->__toString(), 'query');
// dump($couponcode, 'couponcode');
$model->updateRow($id, "courses.teachername", $couponcode);//use your own variable and column and etc
}
<?php
$item = $model->getTable();
$app = Joomla\CMS\Factory::getApplication();
// getting array of current Fabrik list's main table pk values and imploding them to comma separated list:
$ids = $app->getInput()->get('ids', array(), 'array');
$id = implode(',', $ids);
// connecting to the default database:
$mydb = FabrikWorker::getDbo();
// getting current list's main db table name
$curtab = $mydb->quoteName($item->db_table_name);
// Defining needed fields. $mydb->quoteName ensures that the field names would be surrounded by appropriate quotes ``:
$c_id = $mydb->quoteName('id');
$c_parent = $mydb->quoteName('parent_id');
$c_orig = $mydb->quoteName('orig_text');
$c_sugg = $mydb->quoteName('suggested');
// Let's query
$query = "SELECT $c_parent, $c_orig, $c_sugg FROM $curtab WHERE $c_id IN($id)";
$mydb->setQuery($query);
// As this query is set to return multiple rows of data from multiple fields:
$rows = $mydb->loadObjectList();
/*
* We got needed data.
* Now let's connect to the other database where WP blog data resides (Fabrik connection to this db should be set! In this case its id = 2):
*/
$db2 = FabrikWorker::getDbo(false, 2);
// Defining table and needed fields, again using $mydb->quoteName
$other = $mydb->quoteName('wp_posts');
$o_id = $mydb->quoteName('ID');
$o_post = $mydb->quoteName('post_content');
// Using results of the previous query, generating own UPDATE query for each selected row:
foreach ($rows as $row)
{
$q = $db2->getQuery(true);
/*
* Setting new value for `post_content` field data = replace in `post_content` field data the string $row->orig_text with the string $row->suggested:
* IMPORTANT: $db2->quote is here the only possible way to ensure that the string values would be surrounded by right quotes in query.
See i.e thread https://fabrikar.com/forums/index.php?threads/list-php-plugin-query-execution-fails.37517
*/
$fields = array(
$o_post . ' = REPLACE(' . $o_post . ', '. $db2->quote($row->orig_text) . ', ' . $db2->quote($row->suggested) . ')'
);
$conditions = array(
$o_id . ' = ' . $row->parent_id
);
// Generating the UPDATE query
$q->update($other)->set($fields)->where($conditions);
$db2->setQuery($q);
// processing query/queries
$db2->execute();
}
?>
$app = Joomla\CMS\Factory::getApplication();
$ids = $app->getInput()->get('ids', array(), 'array');