Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- foreach ( $results as $key => $post ) {
- do_action( 'woocommerce/cart_loop/start', $post );
- if ( in_array( $post->post_type, array( 'product', 'product_variation' ) ) ) {
- if ( isset( $this->request['full_screen'] ) || $custom_post_types_limits ) {
- if ( $post_types_limits['products'] < 1 ) {
- continue;
- }
- $post_types_limits['products'] --;
- }
- $product = wc_get_product( $post );
- $product_image = wp_get_attachment_image_src( $product->get_image_id(), 'woocommerce_thumbnail' );
- // if ($product->get_type() == 'variation'){
- // $product_image = wp_get_attachment_image_src($product->get_image_id(), 'woocommerce_thumbnail');
- // }
- add_filter( 'woocommerce_get_availability_class', 'etheme_wc_get_availability_class', 20, 2 );
- $all_count = '';
- if ( isset( $post_types_counts['product'] ) ) {
- $all_count = $post_types_counts['product'];
- }
- if ( isset( $post_types_counts['products'] ) ) {
- $all_count = $post_types_counts['products'];
- }
- $product_args = array(
- 'type' => 'Product',
- 'id' => $product->get_id(),
- 'value' => $product->get_title(),
- 'url' => $product->get_permalink(),
- 'img' => ( $product_image[0] ) ? $product_image[0] : wc_placeholder_img_src( 'woocommerce_thumbnail' ),
- 'arrow' => $arrow,
- 'price' => $product->get_price_html(),
- 'stock' => wc_get_stock_html( $product ),
- 'in_stock' => $product->is_in_stock(),
- 'all_count' => $all_count,
- 's' => $query
- // 'date' => '',
- );
- if ( $just_catalog && get_theme_mod( 'just_catalog_price', 0 ) ) {
- $login_text = get_theme_mod( 'ltv_price', esc_html__( 'Login to view price', 'xstore-core' ) );
- if ( $login_text == '' ) {
- unset( $product_args['price'] );
- } else {
- $product_args['price'] = $login_text;
- }
- }
- // @deprecated 'etheme_ajax_search_products_sku' since v4.3.4 and used in_array('ajax-search-results', (array)get_theme_mod('product_sku_locations', array('cart', 'popup_added_to_cart', 'mini-cart')))
- // @todo remove 'etheme_ajax_search_products_sku' in v4.6
- if ( ( in_array( 'ajax-search-results', (array) get_theme_mod( 'product_sku_locations', array(
- 'cart',
- 'popup_added_to_cart',
- 'mini-cart'
- ) ) ) || apply_filters( 'etheme_ajax_search_products_sku', false ) || $is_shortcode ) && wc_product_sku_enabled() && ( $product->get_sku() || $product->get_type() == 'variable' ) ) {
- $product_args = array_merge( $product_args,
- array(
- 'sku' => esc_html__( 'SKU:', 'xstore-core' ) . '<span class="sku">' . ( ( $sku = $product->get_sku() ) ? $sku : esc_html__( 'N/A', 'xstore-core' ) ) . '</span>'
- )
- );
- }
- remove_filter( 'woocommerce_get_availability_class', 'etheme_wc_get_availability_class', 20, 2 );
- if ( isset( $this->request['full_screen'] ) ) {
- $product_args['arrow'] = false;
- // unset($product_args['arrow']);
- $product_attr = array(
- 'href = "' . $product->add_to_cart_url() . '"',
- 'quantity="1"',
- 'class = "' . implode(
- ' ',
- array_filter(
- array(
- 'button',
- 'product_type_' . $product->get_type(),
- $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
- $product->supports( 'ajax_add_to_cart' ) && $product->is_purchasable() && $product->is_in_stock() ? 'ajax_add_to_cart' : '',
- )
- )
- ) . '"',
- 'data-product_id = "' . $product->get_id() . '"',
- 'data-product_sku = "' . $product->get_sku() . '"',
- 'aria-label = "' . $product->add_to_cart_description() . '"',
- 'rel="nofollow"',
- );
- $product_args = array_merge( $product_args,
- array(
- 'add_to_cart_text' => $product->add_to_cart_text(),
- 'add_to_cart_args' => implode( ' ', $product_attr )
- ) );
- }
- $suggestions[] = $product_args;
- } // elseif( in_array( $post->post_type, array( 'page', 'post', 'etheme_portfolio' ) ) ) {
- else {
- if ( isset( $this->request['full_screen'] ) || $custom_post_types_limits ) {
- if ( $post_types_limits[ $post->post_type ] < 1 ) {
- continue;
- }
- $post_types_limits[ $post->post_type ] --;
- }
- $args = array(
- 'type' => ucfirst( str_replace( array( 'page', 'post', 'etheme_portfolio' ), array(
- 'Pages',
- 'Post',
- 'Portfolio'
- ), $post->post_type ) ),
- 'id' => $post->ID,
- 'value' => get_the_title( $post->ID ),
- 'url' => get_the_permalink( $post->ID ),
- 'img' => ( isset( $this->request['full_screen'] ) && $post->post_type == 'page' ) ? false : get_the_post_thumbnail_url( $post->ID, 'medium' ),
- 'arrow' => $arrow,
- 'date' => get_the_date( '', $post->ID ),
- 'all_count' => isset($post_types_counts[ $post->post_type ]) ? $post_types_counts[ $post->post_type ] : 0,
- 's' => $query
- );
- if ( isset( $this->request['full_screen'] ) ) {
- if ( $post->post_type == 'post' ) {
- ob_start();
- etheme_byline(
- array(
- 'author' => 0,
- 'time' => 0,
- 'ID' => $post->ID,
- 'views_counter' => true
- )
- );
- $args['meta'] = ob_get_clean();
- // $excerpt_length = etheme_get_option('excerpt_length', 25);
- // ob_start();
- // if ( $excerpt_length > 0 ) {
- // if ( strlen($post->post_excerpt) > 0 ) {
- // $excerpt_length = apply_filters( 'excerpt_length', $excerpt_length );
- // $excerpt_more = apply_filters( 'excerpt_more', ' ' . '[…]' );
- // $excerpt = wp_trim_words( $post->post_excerpt, $excerpt_length, $excerpt_more );
- // echo do_shortcode(apply_filters( 'wp_trim_excerpt', $excerpt, $excerpt ));
- // }
- // else
- // echo do_shortcode($post->post_excerpt);
- // }
- // $args['excerpt'] = ob_get_clean();
- $args['post_class'] = implode( ' ', get_post_class( 'blog-post post-grid byline-on content-grid', $post->ID ) );
- } elseif ( $post->post_type == 'etheme_portfolio' && function_exists('etheme_project_categories') ) {
- $args['post_class'] = implode( ' ', get_post_class( 'portfolio-item port-style-default', $post->ID ) );
- ob_start();
- etheme_project_categories( $post->ID );
- $args['categories'] = ob_get_clean();
- }
- }
- $suggestions[] = $args;
- }
- do_action( 'woocommerce/cart_loop/end', $post );
- }
- $suggestions = $this->parse_suggestions( $products, $suggestions );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement