Support Forum ยป User Profile

Forum Replies Created

Viewing 5 posts - 16 through 20 (of 20 total)
  • Author
    Posts
  • in reply to: Invalid argument supplied for foreach: Warning #32648
    AishwaryaAishwarya
    Participant

    Hi,

    Thanks for checking it out. But you have commented on the fields array shopily_custom_fields and prevented it from displaying. Check it by enabling the field in the code but without adding data from the browser by clicking "Add field".

    Hope you understand!

    in reply to: Invalid argument supplied for foreach: Warning #32567
    AishwaryaAishwarya
    Participant

    Hi,

    Sure

    //Add Metabox settings page under Products menu
    add_filter( 'mb_settings_pages', function ( $settings_pages ) {
    
        $settings_pages[] = array(
            'id'          => 'shopily-extra-fields',
            'option_name' => 'shopily_product_fields',
            'menu_title'  => esc_html__( 'Extra details', 'shopily' ),
            'icon_url'    => 'dashicons-edit',
            'style'       => 'no-boxes',
            'columns'     => 1,
            'parent'      => 'edit.php?post_type=product',
        );
    
        return $settings_pages;
    
    } );
    // Register meta boxes and fields for settings page
    add_filter( 'rwmb_meta_boxes', function ( $meta_boxes ) {
        $meta_boxes[] = array(
            'id'             => 'shopily-custom-fields',
            'title'          => esc_html__( 'Product specification details', 'shopily' ),
            'settings_pages' => 'shopily-extra-fields',
            'customizer'  => false,
            'fields' => array(
              array (
                    'id' => 'shopily_custom_fields',
                    'type' => 'text',
                'name'        => esc_html__( 'Add field', 'shopily' ),
                'label_description' => 'Label description',
                    'desc' => esc_html__( 'To add your own specification, just type in the label by not selecting the select option.', 'shopily' ),
                'clone' => true,
                'placeholder' => esc_html__( 'Enter field label', 'shopily' ),
                'size'        => 30,
                'datalist'    => array(
                    'id'      => 'shopily_default_fields',
                    // List of predefined options
                    'options' => array(
                        esc_html__( 'Material', 'shopily' ),
                        esc_html__( 'Type', 'shopily' ),
                        esc_html__( 'Added date', 'shopily' ),
      
                    ),
                ),
                ),
            ),
        );
    
        return $meta_boxes;
    
    } );

    This is the code. When I add a field from the settings page, the error goes away because the foreach has some value to iterate.

    AishwaryaAishwarya
    Participant

    Hi Anh,

    Thank you so much for adding the feature. Really appreciated and love your great work.

    Best Regards,
    Aishwarya

    AishwaryaAishwarya
    Participant

    Hi Anh,
    Any updates on addition of unique class name to the settings page?

    Best Regards,
    Aishwarya

    AishwaryaAishwarya
    Participant

    Hi Ann,

    Thank you for taking my request.

    Do you mean like <div class="wrap my-theme-settings"> this?

    Ah, yes it can work but if you can add a inner div, it will be more convenient to style it more better. like <div class="wrap"><div id="my-theme-settings">

    But both methods are ok for me, whichever you think possible to add.

    Best Regards,
    Aishwarya

Viewing 5 posts - 16 through 20 (of 20 total)