• femke98

    (@femke98)


    I wish a loop could be made for items on sale.

    Its now only new products, call to action and product category.

    Can you make this for me (us)?

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @femke98,

    I am sorry for the delay in response.

    Copy this function to your child theme’s functions.php file.

    function theshop_section_products() {
      if ( ! theshop_woocommerce_active() || ! get_theme_mod( 'products_activate', 1 ) ) {
        return;
      }
    
      $title  = get_theme_mod( 'products_title', 'Latest products' );
      $number = get_theme_mod( 'products_number', '4' );
      ?>
    
    <section class="home-section products-loop">
      <div class="container">
        <?php if ( $title ) : ?>
        <h2 class="section-title"><span><?php echo esc_html( $title ); ?></span></h2>
        <?php endif; ?>
        <div class="inner-section">
        <?php echo do_shortcode( '[recent_products per_page="' . intval( $number ) . '" columns="3"]' ); ?>
        </div>
      </div>
    </section>
    
      <?php
    }

    and replace this line:

    <?php echo do_shortcode( '[recent_products per_page="' . intval( $number ) . '" columns="3"]' ); ?>

    with:

    <?php echo do_shortcode( '[sale_products per_page="' . intval( $number ) . '" columns="3"]' ); ?>

    Hope that helps.

    Regards,
    Kharis

    Thread Starter femke98

    (@femke98)

    Hello,
    It doesn’t matter, I’m patient.

    My question is whether, in addition to the new products, there will also be something for products on offer.

    So, first new products, and below products on sale.

    I think you do not fully understand my question and that you think that instead of new products, I want products on sale. Or am I wrong?

    I’d love to hear from you and then I’ll create and try out the child theme.

    Hi @femke98,

    Thank you for getting back.

    Sorry for didn’t get you correctly.

    Seems likely you wouldn’t need to replace anything. However, you could add another line where put the shortcode for on sale products

    So the function would look like this:

    function theshop_section_products() {
      if ( ! theshop_woocommerce_active() || ! get_theme_mod( 'products_activate', 1 ) ) {
        return;
      }
    
      $title  = get_theme_mod( 'products_title', 'Latest products' );
      $number = get_theme_mod( 'products_number', '4' );
      ?>
    
      <section class="home-section products-loop">
        <div class="container">
          <?php if ( $title ) : ?>
          <h2 class="section-title"><span><?php echo esc_html( $title ); ?></span></h2>
          <?php endif; ?>
          <div class="inner-section">
          <?php echo do_shortcode( '[recent_products per_page="' . intval( $number ) . '" columns="3"]' ); ?>
          </div>
        </div>
      </section>
    
      <section class="home-section products-loop">
        <div class="container">
          <?php if ( $title ) : ?>
          <h2 class="section-title"><span>Sale</span></h2>
          <?php endif; ?>
          <div class="inner-section">
          <?php echo do_shortcode( '[sale_products per_page="10" columns="3"]' ); ?>
          </div>
        </div>
      </section>
    
      <?php
    }

    Let me know how it goes.

    Regards,
    Kharis

    Thread Starter femke98

    (@femke98)

    Thanx, i will try tomorrow!
    You hear from me!!

    Thread Starter femke98

    (@femke98)

    Kharis Sulistiyono

    (@kharisblank)

    I didn’t work so i have the homepage different. Al off the product is seeing on the homepage now.
    That’s just the way it is.

    Have i nice Happy Holidays!!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Homepage on sale’ is closed to new replies.