Advertisement
nshelper

WPGlobaCart - Porto live search

Sep 26th, 2024
49
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1.  
  2.  
  3.             foreach ( $posts as $post ) {
  4.                 do_action( 'woocommerce/cart_loop/start', $post );
  5.                 if ( class_exists( 'Woocommerce' ) && ( 'product' === $post->post_type || 'product_variation' === $post->post_type ) ) {
  6.                     $product       = wc_get_product( $post );
  7.                     $product_image = wp_get_attachment_image_src( get_post_thumbnail_id( $product->get_id() ) );
  8.                     if ( $product->is_visible() ) {
  9.                         $result[] = array(
  10.                             'type'  => 'Product',
  11.                             'id'    => $product->get_id(),
  12.                             'value' => $product->get_title(),
  13.                             'url'   => esc_url( $product->get_permalink() ),
  14.                             'img'   => esc_url( $product_image[0] ),
  15.                             'price' => $product->get_price_html(),
  16.                         );
  17.                     }
  18.                 } else {
  19.                     $result[] = array(
  20.                         'type'  => get_post_type( $post->ID ),
  21.                         'id'    => $post->ID,
  22.                         'value' => get_the_title( $post->ID ),
  23.                         'url'   => esc_url( get_the_permalink( $post->ID ) ),
  24.                         'img'   => esc_url( get_the_post_thumbnail_url( $post->ID, 'thumbnail' ) ),
  25.                         'price' => '',
  26.                     );
  27.                 }
  28.                 do_action( 'woocommerce/cart_loop/end', $post );
  29.             }
Advertisement
Comments
  • nshelper
    19 days
    # text 0.09 KB | 0 0
    1. \wp-content\themes\porto\inc\lib\live-search\live-search.php
    2. at public function ajax_search()
Add Comment
Please, Sign In to add comment
Advertisement