getCategories(); } $attributes = $link->getAttributes($prof['miravia_category']); // var_dump($prof['config']); try { $default_attributes = $prof['config'] ? json_decode($prof['config'], true) : []; }catch(Exception $e) { $default_attributes = []; } // MiraviaCore::debug($default_attributes); $attributes_woocommerce = wp_list_pluck( wc_get_attribute_taxonomies(), 'attribute_label', 'attribute_name' ); if(isset($_POST['action']) and sanitize_text_field($_POST['action']) == 'save_miravia_attr_default') { $default_attributes = sanitize_text_field($_POST['attr']); $args = array('config' => json_encode(array('attr' => sanitize_text_field($_POST['attr'])))); LOG::add($args); if(MiraviaCore::update_profile($args, array('id' => $id))) { echo esc_html('Attributes profile saved'); } } //Save data if(isset($_POST['action']) and sanitize_text_field($_POST['action']) == 'update_profile') { if($_POST['description'] == '') { echo "

Profile need description

"; }elseif ($_POST['tax_input']['product_cat'] == null) { echo "

Profile need categories

"; }else{ $categories_recibed = implode(",", array_map('sanitize_text_field', $_POST['tax_input']['product_cat'])); $acounts_recibed = implode(",", array_map('sanitize_text_field', $_POST['profile'])); // die(var_dump($categories_recibed)); $saveProfile = MiraviaCore::update_profile(array( 'name' => sanitize_text_field($_POST['description']), 'accounts_id' => $acounts_recibed, 'categories' => $categories_recibed, 'miravia_category' => sanitize_text_field($_POST['miravia_category']) ), array('id' => $id)); if($saveProfile) { wp_safe_redirect('?page=miravia_settings&subpage=profiles'); } } } //Rules $miraviaTable = new MiraviaTable([ 'sccren' => 'miravia_rules' ]); $miraviaTable->custom_actions = array( 'edit' => sprintf('Editar', sanitize_text_field($_REQUEST['page']), 'edit_rule', 'edit', ), 'delete' => sprintf('Eliminar', sanitize_text_field($_REQUEST['page']), sanitize_text_field($_REQUEST['subpage']), 'delete'), ); $miraviaTable->columns = [ 'id' => "ID", 'name' => "Name", 'created' => 'Created', 'updated' => 'Updated' ]; $miraviaTable->default_column_name = 'name_rule'; $rules = MiraviaCore::get_rules(false, "profile_id = {$id} or profile_id = '0'"); $miraviaTable->data_table = $rules; $miraviaTable->total_elements = count($rules); $miraviaTable->prepare_items(); ?>

Edit Profile


Categories Select the categories with this profile
    'product_cat', 'selected_cats' => explode(",", $prof['categories']) ));?>
Miravia Category
Seller Accounts {$profile['name']}

"; } ?>
$attr) { $options = ''; if (!empty ($attributes ) ) { foreach ( $attributes as $key => $v ) { if($v['is_sale_prop'] == 0) { continue; } $selected = ''; if($default_attributes != '' and isset($default_attributes[$slug]) and $v['name'] == $default_attributes[$slug]) { $selected = 'selected="selected"'; } $options .= ""; } } echo ""; } } ?>
{$attr}
display(); ?>