Support

Account

Forum Replies Created

  • Great, thank you John. It did solved the issue.

  • @hube2 @jarvis Forget about my last message. I was able to solve my issue without using ajax.

    Since I have around 1200 products on my site, I just added ‘meta_key’ => ‘pdf_upload’, in the array to filter. It reduced the loading time, now the page load fast!

    Thanks for your help

    Revised code:

    
    <section class="post-content">
                    <ul>
    
                    <?php
                    $args = array(
                      'posts_per_page' => -1,
                      'post_type' => 'product',
                      'orderby' => 'date',
                      'order' => 'DESC',
                      'paged' => $paged,
                      
                      'meta_key'    => 'pdf_upload',  
                    );
                    $wp_query = new WP_Query($args);
                    if ($wp_query->have_posts()) :
                      while ($wp_query->have_posts()) : $wp_query->the_post();
    
                        $pdf_upload = get_field('pdf_upload');
                        if( $pdf_upload ): ?>
                          <li><a href="<?php echo $pdf_upload['url']; ?>"><?php echo $product->post->post_title; ?> </a></li>
                          <?php echo '<span class="date_published">Published on: ' .get_the_date('Y', $product->get_id()) . '</span>'; ?>
    
                        <?php endif;
    
                      endwhile;
                    endif;
                    ?>
    
                    </ul>
                  </section>
  • It dosen’t seems to be working. It now show 3 links in <li>

    There is also a list of products name listed at the bottom of the page

    Just to let you know I did match the value in settings – reading- blog which is 12 for me 🙂

  • @jarvis I had to replace $ with jQuery, to solve this error: ‘Uncaught TypeError: $ is not a function ‘

    Now, I am getting this error: Uncaught ReferenceError: ajax_posts is not defined

    It makes me think that I haven’t proprely enqued the script maybe?

    Also do I need to keep the theme twentytwentyone installed ?

  • @jarvis It work well, here is the modified code below…

    <?php
    $args = array(
      'posts_per_page'  => -1,
      'post_type'     => 'product',
      'orderby'       => 'date',
      'order'         => 'DESC',  
      'paged'       => $paged,
      'fields'      => 'ids'      
    );
    $wp_query = new WP_Query($args);
    if ($wp_query->have_posts()) :
      while ($wp_query->have_posts()) : $wp_query->the_post();
    
      $pdf_upload = get_field('pdf_upload');
      if( $pdf_upload ): ?>
           <li> <a href="<?php echo $pdf_upload['url']; ?>"><? echo $product->post->post_title; ?></a></li>
           <?php echo '<span class="date_published">Published on: ' . get_the_date('Y', $product->get_id()) . '</span>'; ?>
    
        <?php endif; 
    
      endwhile;
    endif;
    
    ?>


    @hube2
    The page is indeed pretty slow, I will work on the Ajax now, I will keep this thread updated with the code.

    Thanks

  • Hi,

    I am trying to update a custom field ( in the woocommerce order page). Once the field is saved, I then change the status email to complete and send the number into the order completion email. using this code:

    // define the woocommerce_email_before_order_table callback 
    function action_woocommerce_email_before_order_table( $order, $sent_to_admin, $plain_text, $email ) { 
        
        
        if (get_field('ACFFIELDNAME', $order->get_id())) { // Only show if field is filled
     
    ?>
            <h3>Your number: <?php the_field('ACFFIELDNAME', $order->get_id()); ?></h3>
                  
            <?php 
            
        }
    
    }; 
             
    
    // add the action 
    add_action('woocommerce_email_before_order_table', 'action_woocommerce_email_before_order_table', 10, 4 );
    
    
  • Hi zaehlpixel,

    I use the same code than you for my woocommerce store.

    The problem is that I have to add the DHL tracking code, hit save, then mark the order as complete and save again.

    If I just change the status to order complete, add the tracking number, hit save, it won’t include the tracking number in the order completion email.

    Have you experienced the same issue?

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