Home Forums Themes Support How to add any content to Single Product or Archive Product in HaruTheme

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #12726

    Hi all Customer,

    If you are using our theme use New Framework build with Elementor like Pricom, TeeSpace, PrintSpace, TeeCheap,… you can add content to Archive Product (Shop, Tags, Categories…) by following this tutorial:

    Firs of all you need to manage files of your site via FTP or File Manager of your server or use this plugin:

    Step 1: go to wp-content/themes/teespace/framework/includes/ then open file theme-options.php

    You can change teespace to other theme you are using.

    Go after section id haru_archive_product_title_breadcrumbs and add this code:

    // Extra
    array(
    ‘id’ => ‘haru-section-archive-product-content-start’,
    ‘type’ => ‘section’,
    ‘title’ => esc_html__( ‘Extra Content’, ‘teecheap’ ),
    ‘indent’ => true
    ),
    array(
    ‘id’ => ‘haru_archive_product_extra’,
    ‘type’ => ‘switch’,
    ‘title’ => esc_html__( ‘Extra Content’, ‘teecheap’ ),
    ‘subtitle’ => esc_html__( ‘Add Content for Shop & Product Category, Tags,…’, ‘teecheap’),
    ‘desc’ => esc_html__( ‘This option can be override by in each Product Category.’, ‘teecheap’ ),
    ‘default’ => false
    ),
    array(
    ‘id’ => ‘haru_archive_product_extra_content’,
    ‘type’ => ‘content’,
    ‘title’ => esc_html__( ‘Extra Content Builder’, ‘teecheap’ ),
    ‘subtitle’ => esc_html__( ‘Please go to Content Builders to create Content.’, ‘teecheap’),
    ‘desc’ => esc_html__( ‘This option can be override by in each Product Category.’, ‘teecheap’ ),
    ‘required’ => array( ‘haru_archive_product_extra’, ‘=’, array( ‘1’ ) ),
    ),
    array(
    ‘id’ => ‘haru_archive_product_extra_all’,
    ‘type’ => ‘switch’,
    ‘title’ => esc_html__( ‘Add All Product Terms’, ‘teecheap’ ),
    ‘subtitle’ => esc_html__( ‘Add Content for all Product Category, Tags,…’, ‘teecheap’ ),
    ‘desc’ => esc_html__( ‘This option can be override by in each Product Category.’, ‘teecheap’ ),
    ‘default’ => false,
    ‘required’ => array( ‘haru_archive_product_extra’, ‘=’, array( ‘1’ ) ),
    ),
    array(
    ‘id’ => ‘haru_archive_product_extra_position’,
    ‘type’ => ‘select’,
    ‘title’ => esc_html__( ‘Extra Content Position’, ‘teecheap’ ),
    ‘subtitle’ => esc_html__( ‘Set position to display Extra Content.’, ‘teecheap’ ),
    ‘desc’ => esc_html__( ‘This option can be override by in each Product Category.’, ‘teecheap’ ),
    ‘options’ => array(
    ‘before_main_content’ => esc_html__( ‘Before Main Content’, ‘teecheap’ ),
    ‘after_main_content’ => esc_html__( ‘After Main Content’, ‘teecheap’ ),
    ),
    ‘default’ => ‘before_main_content’,
    ‘required’ => array( ‘haru_archive_product_extra’, ‘=’, array( ‘1’ ) ),
    ),
    array(
    ‘id’ => ‘haru-section-archive-product-conent-end’,
    ‘type’ => ‘section’,
    ‘indent’ => false
    ),

    It will become:

    Step 2: go to wp-content/plugins/haru-teespace/core/libraries/ then open file theme-metabox.php (You can change haru-teespace to other name of theme you are using)

    Go after function haru_teecheap_get_footer_list_options() and add this code:

    // Get Content List
    if ( ! function_exists( 'haru_teecheap_get_content_list_options' ) ) {
      function haru_teecheap_get_content_list_options() {
    
        if ( !is_admin() ) {
          return array();
        }
    
        $query_args  = array(
          'post_type'         => 'haru_content',
          'post_status'       => 'publish',
          'posts_per_page'    => -1,
        );
    
        $content_query = new WP_Query( $query_args );
    
        $content_list = array();
    
        if ( $content_query->have_posts() ) {
          while($content_query->have_posts()) : $content_query->the_post();
            $key = get_the_ID();
            $content_list[$key] = get_the_title();
          endwhile;
        }
    
        return $content_list;
      }
    }

    It will becomes like this:

    Go after section id title_bg_image and add this code:

    // Product Terms
    $cmb_product_term = new_cmb2_box( array(
    ‘id’ => $prefix . ‘metabox_product_term’,
    ‘title’ => esc_html__( ‘Product Term Metabox’, ‘haru-teecheap’ ),
    ‘object_types’ => array( ‘term’ ), // Tells CMB2 to use term_meta vs post_meta
    ‘taxonomies’ => array( ‘product_cat’, ‘product_tag’ ),
    ) );
    
    $cmb_product_term->add_field( array(
    ‘name’ => esc_html__( ‘Product Term Metabox’, ‘haru-teecheap’ ),
    ‘desc’ => esc_html__( ‘Product Term Metabox using to add Content Builder to some position at Product Category, Product Tags,… page’, ‘haru-teecheap’ ),
    ‘type’ => ‘title’,
    ‘id’ => $prefix . ‘metabox_product_term_title’,
    ) );
    
    $cmb_product_term->add_field( array(
    ‘name’ => esc_html__( ‘Extra Content’, ‘haru-teecheap’ ),
    ‘desc’ => esc_html__( ‘This option will override settings in Theme Options -> WooCommerce -> Archive Product (Shop) -> Extra Content.’, ‘haru-teecheap’ ),
    ‘id’ => $prefix . ‘product_term_extra’,
    ‘type’ => ‘radio_inline’,
    ‘options’ => array(
    ‘default’ => esc_html__( ‘Default’, ‘haru-teecheap’ ),
    ‘1’ => esc_html__( ‘On’, ‘haru-teecheap’ ),
    ‘0’ => esc_html__( ‘Off’, ‘haru-teecheap’ )
    ),
    ‘default’ => ‘default’,
    ) );
    
    $cmb_product_term->add_field( array(
    ‘name’ => esc_html__( ‘Extra Content Builder’, ‘haru-teecheap’ ),
    ‘desc’ => esc_html__( ‘This option will override settings in Theme Options -> WooCommerce -> Archive Product (Shop) -> Extra Content.’, ‘haru-teecheap’ ),
    ‘id’ => $prefix . ‘product_term_extra_content’,
    ‘type’ => ‘pw_select’,
    ‘options_cb’ => ‘haru_teecheap_get_content_list_options’,
    ‘attributes’ => array(
    ‘required’ => false, // Will be required only if visible.
    ‘data-conditional-id’ => $prefix . ‘product_term_extra’,
    ‘data-conditional-value’ => wp_json_encode( array( ‘default’, ‘1’ ) ),
    ),
    ) );
    
    $cmb_product_term->add_field( array(
    ‘name’ => esc_html__( ‘Extra Content Position’, ‘haru-teecheap’ ),
    ‘desc’ => esc_html__( ‘This option will override settings in Theme Options -> WooCommerce -> Archive Product (Shop) -> Extra Content.’, ‘haru-teecheap’ ),
    ‘id’ => $prefix . ‘product_term_extra_position’,
    ‘type’ => ‘pw_select’,
    ‘options’ => array(
    ‘default’ => esc_html__( ‘Default’, ‘haru-teecheap’ ),
    ‘before_main_content’ => esc_html__( ‘Before Main Content’, ‘haru-teecheap’ ),
    ‘after_main_content’ => esc_html__( ‘After Main Content’, ‘haru-teecheap’ ),
    ),
    ‘default’ => ‘default’,
    ‘attributes’ => array(
    ‘required’ => false, // Will be required only if visible.
    ‘data-conditional-id’ => $prefix . ‘product_term_extra’,
    ‘data-conditional-value’ => wp_json_encode( array( ‘default’, ‘1’ ) ),
    ),
    ) );

    It will becomes like this:

    Step 3: Go to wp-content/themes/teespace/framework/includes/ then open file theme-functions.php (You can change teespace to other name of theme you are using)

    After this function haru_render_footer_layout you can add this code:

    if ( ! function_exists( ‘haru_render_content_layout’ ) ) {
    function haru_render_content_layout( $content_id ) {
    if ( ! $content_id ) return;
    
    $args = array(
    ‘orderby’ => ‘post__in’,
    ‘post__in’ => explode( ‘,’, $content_id ),
    ‘post_type’ => ‘haru_content’,
    ‘post_status’ => ‘publish’
    );
    
    $posts = get_posts( $args );
    $post = $posts[0];
    
    echo apply_filters( ‘haru_render_post_builder’, do_shortcode( $post->post_content ), $post);
    }
    }

    It will becomes like this:

    Step 4: Download folder content from here:

    https://drive.google.com/drive/folders/1xKbIMnjrsMSLOgKwiTlIBxd8eHKljHMB?usp=sharing

    then upload to this: wp-content/haru-teespace/core/redux-extensions/extensions/

    (You can change haru-teespace to other name of theme you are using)

    It will becomes like this:

    Step 5: Go to wp-content/themes/teespace/woocommerce/ then open file archive-product.php

    (You can change teespace to other name of theme you are using)

    Add this code after line 55

    // Extra Content
    $archive_product_extra_all = haru_get_option( 'haru_archive_product_extra_all', '0' );
    
    if ( ! is_shop() ) {
    $archive_product_extra = get_term_meta( get_queried_object_id(), 'haru_product_term_extra', true );
    $archive_product_extra_content = get_term_meta( get_queried_object_id(), 'haru_product_term_extra_content', true );
    $archive_product_extra_position = get_term_meta( get_queried_object_id(), 'haru_product_term_extra_position', true );
    
    if ( ( $archive_product_extra == '' ) || ( $archive_product_extra == 'default' ) ) {
    // Process All
    if ( $archive_product_extra_all == '1' ) {
    $archive_product_extra = haru_get_option( 'haru_archive_product_extra', '0' );
    }
    }
    
    if ( ( $archive_product_extra_content == '' ) || ( $archive_product_extra_content == 'default' ) ) {
    $archive_product_extra_content = haru_get_option( 'haru_archive_product_extra_content', '' );
    }
    
    if ( ( $archive_product_extra_position == '' ) || ( $archive_product_extra_position == 'default' ) ) {
    $archive_product_extra_position = haru_get_option( 'haru_archive_product_extra_position', 'before_main_content' );
    }
    } else {
    $archive_product_extra = haru_get_option( 'haru_archive_product_extra', '0' );
    $archive_product_extra_content = haru_get_option( 'haru_archive_product_extra_content', '' );
    $archive_product_extra_position = haru_get_option( 'haru_archive_product_extra_position', 'before_main_content' );
    }

    and it will becomes like this:

    Add this code after like 125:

    <?php if ( $archive_product_extra == ‘1’ && $archive_product_extra_position == ‘before_main_content’ ) : ?>
    <div class=”haru-archive-product-extra”>
    <?php haru_render_content_layout( $archive_product_extra_content ); ?>
    </div>
    <?php endif; ?>

    it will becomes like this:

    Similar after line 352:

    Step 6: Go to Content Builders then add anything you want:

    Step 7: Go to Theme Options -> WooCommerce -> Archive Product -> Extra Content then select Content you have just created to display on Shop page or All Categories

    Step 8: Edit Category then set content you want to display for each category:

    And the result:

    Thanks for your time and reading.

    ****
    Best Regards,

    HaruTheme

    • This topic was modified 2 months, 2 weeks ago by admin.
    • This topic was modified 2 months, 1 week ago by admin.
    • This topic was modified 2 months, 1 week ago by admin.
    • This topic was modified 2 months, 1 week ago by admin.
    • This topic was modified 2 months, 1 week ago by admin.
    • This topic was modified 2 months, 1 week ago by admin.
    • This topic was modified 2 months, 1 week ago by admin.
    • This topic was modified 1 month, 2 weeks ago by admin.
    #12787
    Woof
    Supported

    Hi! Interesting update! I have followed the steps but when it comes to selecting the content on the category configuration page it does not allow me to add what I have previously created in the “content builders” section, the search bar is displayed incorrectly and does not show any results. Any idea what may be going wrong?
    Attachment screenshot.
    Thanks!

    Attachments:
    You must be logged in to view attached files.
    #12793

    Hi,
    Can you select value from Dropdown box?
    By default it will have empty value.
    Also CSS of some plugins can effect display of this field.
    If you can select it will works fine.

    ****
    Regards,
    HaruTheme

    #12800
    Woof
    Supported

    Hi! I can’t select anything in the drop-down menu, and typing in the bar that appears doesn’t give me any results either. I have removed all the extra css and disabled all the unnecessary plugins but it still doesn’t work. Attachment screenshot.

    Attachments:
    You must be logged in to view attached files.
    #12806

    Hi,
    Please add this function haru_teecheap_get_footer_list_options() in step 2 and check again.
    Hope this helps!

    ****
    Regards,
    HaruTheme

    #12807
    Woof
    Supported

    Hi! The drop-down menu was corrected and now allows me to select what was previously created in the “content builders” tab, however, it does not work correctly, I do not see the design in the category. I don’t know what could be wrong. Any suggestions? Regards.

    #12808

    Hi,
    About the display please check step 5.
    If it still doesn’t work please send us your site URL & a WordPress admin account via email harutheme@gmail.com or create a new topic.
    We’ll check it for you.

    ****
    Regards,
    HaruTheme

    #12869
    Woof
    Supported
    This reply has been marked as private.
    #12871

    Hi,
    We see you are using and active child theme.
    And you already override archive-product.php in the child theme.
    So you need add the new code to archive-product.php in the child theme to make it works.
    https://prnt.sc/k_1zSTYawnM-
    Hope this helps!

    ****
    Regards,
    HaruTheme

    #12875
    Woof
    Supported
    This reply has been marked as private.
    #12877

    Hi,
    We can’t continue login to check the issue.
    However please go to line 83 of archive-product.php then add this code to check:

    var_dump($archive_product_extra_position);

    Also please note to check condition:
    Top is: before_main_content
    Bottom is: after_main_content
    Hope this helps!

    ****
    Regards,
    HaruTheme

    #12880
    Woof
    Supported

    Brilliant! Everything works wonderfully. Thank you very much for your help!

    #12882

    Thanks for your feedback!

    ****
    Regards,
    HaruTheme

Viewing 13 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.