Plugin Directory

Changeset 2671408


Ignore:
Timestamp:
02/02/2022 03:17:46 PM (4 years ago)
Author:
socialproofy
Message:

products some bug fixed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • socialproofy/trunk/socialproofy.php

    r2671404 r2671408  
    6666    }
    6767
    68     $args = array(
     68    $products_query = get_posts(array(
    6969        'post_type' => 'product',
    70         'posts_per_page' => $product_count,
    71         'offset' => $offset,
    72     );
    73     $loop = new WP_Query($args);
    74     if ($loop->have_posts()) {
    75         while ($loop->have_posts()) {
    76             $loop->the_post();
    77             $items = socialproofy_prepare_product_array(get_the_ID());
    78             foreach ($items as $item) {
    79                 $products[] = $item;
    80             }
    81         }
     70        'numberposts' => $product_count,
     71        'offset' => $offset
     72    ));
     73
     74    foreach ($products_query as $item) {
     75        $products[] = socialproofy_prepare_product_array($item->ID);
    8276    }
    8377
     
    297291
    298292    $product = wc_get_product($product_id);
    299 
    300     $images_arr = wp_get_attachment_image_src($product->get_image_id(), array('72', '72'), false);
    301293    $image = null;
     294    $permalink = null;
     295
     296    if ($product) {
     297        $permalink = $product->get_permalink();
     298        $images_arr = wp_get_attachment_image_src($product->get_image_id(), array('72', '72'), false);
     299        $price = $product->get_price();
     300    }
     301
    302302    if ($images_arr !== null && $images_arr[0] !== null) {
    303303        $image = $images_arr[0];
     
    306306        }
    307307    }
    308 
    309     $permalink = $product->get_permalink();
    310     $price = $product->get_price();
    311308
    312309    if ($product->is_type('variable')) {
Note: See TracChangeset for help on using the changeset viewer.