Almost there with this, last piece of the puzzle is setting the category to private, I have the checkbox but it's not updating the database.
This is my code -
Code: Select all
public function listen_infoBox($parameters) {
if(isset($_GET['action']) && $_GET['action'] == 'edit_category'){
$parameters['contents'][] = ['text' => 'Private Category'];
$parameters['contents'][] = ['class' => '',
'text' => '<div class="custom-control custom-switch">' . (new Tickable('private', ['value' => $GLOBALS['cInfo']->private, 'class' => 'custom-control-input', 'id' => 'private'], 'checkbox'))->tick($GLOBALS['cInfo']->private) . '<label for="private" class="custom-control-label text-muted"></label></div>'];
}
}
public function listen_productActionSave() {
$private = $_POST['private'];
$sql_data = [
'private' => (int)$private,
'last_modified' => NOW(),
];
$GLOBALS['db']->perform('categories', $sql_data, 'update', "categories_id = " . (int)$_GET['cID']);
}
I am 99% certain it's the way I'm dealing with the $_POST however my brain just can't comprehend what I'm doing wrong. Updating the last_modified column does go through.