Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- foreach ( $posts as $post ) {
- do_action( 'woocommerce/cart_loop/start', $post );
- if ( class_exists( 'Woocommerce' ) && ( 'product' === $post->post_type || 'product_variation' === $post->post_type ) ) {
- $product = wc_get_product( $post );
- $product_image = wp_get_attachment_image_src( get_post_thumbnail_id( $product->get_id() ) );
- if ( $product->is_visible() ) {
- $result[] = array(
- 'type' => 'Product',
- 'id' => $product->get_id(),
- 'value' => $product->get_title(),
- 'url' => esc_url( $product->get_permalink() ),
- 'img' => esc_url( $product_image[0] ),
- 'price' => $product->get_price_html(),
- );
- }
- } else {
- $result[] = array(
- 'type' => get_post_type( $post->ID ),
- 'id' => $post->ID,
- 'value' => get_the_title( $post->ID ),
- 'url' => esc_url( get_the_permalink( $post->ID ) ),
- 'img' => esc_url( get_the_post_thumbnail_url( $post->ID, 'thumbnail' ) ),
- 'price' => '',
- );
- }
- do_action( 'woocommerce/cart_loop/end', $post );
- }
Advertisement
Comments
-
- \wp-content\themes\porto\inc\lib\live-search\live-search.php
- at public function ajax_search()
Add Comment
Please, Sign In to add comment
Advertisement