/** * Gte woocommerce data for product * * @param $value * @param $data * * @return string */ function vc_gitem_template_attribute_woocommerce_product($value, $data) { $label = ''; /** * @var null|Wp_Post $post ; * @var string $data ; */ extract(array_merge(array('post' => null, 'data' => ''), $data)); require_once WC()->plugin_path() . '/includes/abstracts/abstract-wc-product.php'; $product = new WC_Product($post); if (preg_match('/_labeled$/', $data)) { $data = preg_replace('/_labeled$/', '', $data); $label = apply_filters('vc_gitem_template_attribute_woocommerce_product_' . $data . '_label', Vc_Vendor_Woocommerce::getProductFieldLabel($data) . ': '); } $price_format = get_woocommerce_price_format(); switch ($data) { case 'id': $value = (int) $product->is_type('variation') ? $product->get_variation_id() : $product->id; break; case 'sku': $value = $product->get_sku(); break; case 'price': $value = sprintf($price_format, wc_format_decimal($product->get_price(), 2), get_woocommerce_currency()); break; case 'regular_price': $value = sprintf($price_format, wc_format_decimal($product->get_regular_price(), 2), get_woocommerce_currency()); break; case 'sale_price': $value = sprintf(get_woocommerce_price_format(), $product->get_sale_price() ? wc_format_decimal($product->get_sale_price(), 2) : '', get_woocommerce_currency()); break; case 'price_html': $value = $product->get_price_html(); break; case 'reviews_count': $value = count(get_comments(array('post_id' => $post->ID, 'approve' => 'approve'))); break; case 'short_description': $value = apply_filters('woocommerce_short_description', $product->get_post_data()->post_excerpt); break; case 'dimensions': $units = get_option('woocommerce_dimension_unit'); $value = $product->length . $units . 'x' . $product->width . $units . 'x' . $product->height . $units; break; case 'raiting_count': $value = $product->get_rating_count(); break; case 'weight': $value = $product->get_weight() ? wc_format_decimal($product->get_weight(), 2) : ''; break; case 'on_sale': $value = $product->is_on_sale() ? 'yes' : 'no'; // @todo change break; default: $value = $product->{$data}; } return strlen($value) > 0 ? $label . apply_filters('vc_gitem_template_attribute_woocommerce_product_' . $data . '_value', $value) : ''; }
/** * Get standard product data that applies to every product type * * @since 2.1 * @param WC_Product $product * @return array */ private function get_product_data($product) { return array('title' => $product->get_name(), 'id' => $product->get_id(), 'created_at' => $this->server->format_datetime($product->get_date_created(), false, true), 'updated_at' => $this->server->format_datetime($product->get_date_modified(), false, true), 'type' => $product->get_type(), 'status' => $product->get_status(), 'downloadable' => $product->is_downloadable(), 'virtual' => $product->is_virtual(), 'permalink' => $product->get_permalink(), 'sku' => $product->get_sku(), 'price' => wc_format_decimal($product->get_price(), 2), 'regular_price' => wc_format_decimal($product->get_regular_price(), 2), 'sale_price' => $product->get_sale_price() ? wc_format_decimal($product->get_sale_price(), 2) : null, 'price_html' => $product->get_price_html(), 'taxable' => $product->is_taxable(), 'tax_status' => $product->get_tax_status(), 'tax_class' => $product->get_tax_class(), 'managing_stock' => $product->managing_stock(), 'stock_quantity' => $product->get_stock_quantity(), 'in_stock' => $product->is_in_stock(), 'backorders_allowed' => $product->backorders_allowed(), 'backordered' => $product->is_on_backorder(), 'sold_individually' => $product->is_sold_individually(), 'purchaseable' => $product->is_purchasable(), 'featured' => $product->is_featured(), 'visible' => $product->is_visible(), 'catalog_visibility' => $product->get_catalog_visibility(), 'on_sale' => $product->is_on_sale(), 'weight' => $product->get_weight() ? wc_format_decimal($product->get_weight(), 2) : null, 'dimensions' => array('length' => $product->get_length(), 'width' => $product->get_width(), 'height' => $product->get_height(), 'unit' => get_option('woocommerce_dimension_unit')), 'shipping_required' => $product->needs_shipping(), 'shipping_taxable' => $product->is_shipping_taxable(), 'shipping_class' => $product->get_shipping_class(), 'shipping_class_id' => 0 !== $product->get_shipping_class_id() ? $product->get_shipping_class_id() : null, 'description' => apply_filters('the_content', $product->get_description()), 'short_description' => apply_filters('woocommerce_short_description', $product->get_short_description()), 'reviews_allowed' => $product->get_reviews_allowed(), 'average_rating' => wc_format_decimal($product->get_average_rating(), 2), 'rating_count' => $product->get_rating_count(), 'related_ids' => array_map('absint', array_values(wc_get_related_products($product->get_id()))), 'upsell_ids' => array_map('absint', $product->get_upsell_ids()), 'cross_sell_ids' => array_map('absint', $product->get_cross_sell_ids()), 'categories' => wc_get_object_terms($product->get_id(), 'product_cat', 'name'), 'tags' => wc_get_object_terms($product->get_id(), 'product_tag', 'name'), 'images' => $this->get_images($product), 'featured_src' => wp_get_attachment_url(get_post_thumbnail_id($product->get_id())), 'attributes' => $this->get_attributes($product), 'downloads' => $this->get_downloads($product), 'download_limit' => $product->get_download_limit(), 'download_expiry' => $product->get_download_expiry(), 'download_type' => 'standard', 'purchase_note' => apply_filters('the_content', $product->get_purchase_note()), 'total_sales' => $product->get_total_sales(), 'variations' => array(), 'parent' => array()); }
function woocs_product($ID, $attr, $currency = true) { if (class_exists('WC_Product')) { $product = new WC_Product($ID); if ($attr == 'price_tax_inc') { $p = round($product->get_price_including_tax(), 2); } elseif ($attr == 'get_price_excluding_tax') { $p = round($product->get_price_excluding_tax(), 2); } elseif ($attr == 'get_price') { $p = round($product->get_price(), 2); } elseif ($attr == 'get_sale_price') { $p = round($product->get_sale_price(), 2); } elseif ($attr == 'get_regular_price') { $p = round($product->get_regular_price(), 2); } elseif ($attr == 'get_price_html') { $p = strip_tags($product->get_price_html()); } elseif ($attr == 'is_in_stock') { $p = $product->is_in_stock(); } } return $p; }
function hocwp_wc_product_price($post_id = null, $show_full = false) { if ($show_full) { if (!hocwp_id_number_valid($post_id)) { $post_id = get_the_ID(); } $product = new WC_Product($post_id); $html = $product->get_price_html(); $html = hocwp_wrap_tag($html, 'p', 'prices price'); echo $html; } else { $price = hocwp_wc_get_product_price($post_id); echo hocwp_wc_format_price($price); } }
/** * @param $atts */ function alfw_slider_render_func($atts) { global $wpdb, $lookbook_slider_effects; if (!in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) { do_action('check_woocommerce'); return; } $upload_dir_info = wp_upload_dir(); $wp_root_path = get_home_path(); $site_url = get_site_url(); $plugin_folder_name = pathinfo(ALTIMA_LOOKBOOK_PLUGIN_DIR); wp_enqueue_script('hotspots'); wp_enqueue_script('actual'); wp_enqueue_script('carousel'); wp_enqueue_script('flip'); wp_enqueue_script('scrolV'); wp_enqueue_script('shuffle'); wp_enqueue_script('tile'); wp_enqueue_script('additionalEffect'); wp_enqueue_script('swipe'); //$wpdb->show_errors(); extract($atts); /** * Get slider options */ $show_desc = get_option("wplb_free_show_desc_in_popup"); $show_addcart = get_option("wplb_free_show_addcart_in_popup"); $path_2_pic = get_option('wplb_free_hspt_icon', $site_url . '/wp-content/plugins/' . $plugin_folder_name['basename'] . '/admin/images/hotspot-icon.png'); if (empty($path_2_pic)) { $path_2_pic = $site_url . '/wp-content/plugins/' . $plugin_folder_name['basename'] . '/admin/images/hotspot-icon.png'; } $hot_point_icon = '<img class="hotspot-icon" src="' . $path_2_pic . '" />'; $only_visible_element = 'AND `status`=1'; if (@$admin) { $only_visible_element = ''; } $slider = $wpdb->get_results($wpdb->prepare("SELECT\n slider.*\n FROM\n `" . $wpdb->prefix . SLIDER_TABLE . "` AS slider\n WHERE\n `slider`.`id` = %d {$only_visible_element}", $slider_id), ARRAY_A); if (!empty($slider)) { $slides = $wpdb->get_results($wpdb->prepare("SELECT\n slide.*\n FROM\n `" . $wpdb->prefix . SLIDES_TABLE . "` AS slide\n WHERE\n slider_id = %d {$only_visible_element}\n ORDER BY\n order_flag", $slider[0]['id']), ARRAY_A); } if (empty($slides)) { echo __('No slides available in this slider!'); } else { $effects = unserialize($slider[0]['slider_effect']); $slider_count = count($slides); //var_dump(json_decode($slides[0]['hotsposts'])); alfw_control_js($slider[0]['id']); /** * Work with sliders effect */ if (!empty($effects)) { $effects_string = ''; if (in_array('all', $effects)) { unset($lookbook_slider_effects['all']); unset($lookbook_slider_effects['none']); $fx_names = array_keys($lookbook_slider_effects); $fx_count = count($fx_names); $sl_count = $slider_count; for ($i = 0; $i < $sl_count; $i++) { $slides[$i]['fx'] = 'data-cycle-fx="' . $fx_names[rand(2, $fx_count)] . '"'; } } elseif (in_array('none', $effects)) { $effects_string = 'data-cycle-fx="none"'; } else { $fx_count = count($effects) - 1; $sl_count = $slider_count; for ($i = 0; $i < $sl_count; $i++) { $slides[$i]['fx'] = 'data-cycle-fx="' . $effects[rand(0, $fx_count)] . '"'; } } } echo '<div class="lb_conteyner">'; /** * Output content before */ if (!empty($slider[0]['content_before'])) { echo '<div class="c_before">' . $slider[0]['content_before'] . '</div>'; } /** * Showing the caption */ $caption_plugin = ''; if ($slider[0]['show_slide_caption']) { $caption_plugin = 'data-cycle-caption-plugin="caption2"'; } /** * Adding thumbneil pager */ $thumb = ''; $simple_pager = ''; if ($slider[0]['show_thumbnails']) { $thumb = 'data-cycle-pager="#no-template-pager" data-cycle-pager-template=""'; } else { $simple_pager = ' data-cycle-pager="#pagernav_' . $slider[0]['id'] . ' .cycle" data-cycle-pager-template="<li><span> {{slideNum}} </span></li>"'; } /** * Output the slider * cycle-slideshow */ echo '<div id="lookbookslider_' . $slider[0]['id'] . '" class="cycle-slideshow" data-cycle-speed="' . $slider[0]['transition_duration'] . '" data-cycle-timeout="' . $slider[0]['pause'] . '" data-cycle-slides="> div.slide" ' . $effects_string . ' ' . $caption_plugin . ' ' . $thumb . ' ' . $simple_pager . ' data-cycle-next="> .slide-next" data-cycle-prev="> .slide-prev" data-cycle-log="false" data-cycle-auto-height="container" data-cycle-swipe=true data-cycle-swipe-fx=scrollHorz >'; /** * Showing the caption */ if ($slider_count > 1) { if ($slider[0]['show_slide_caption']) { echo '<div class="cycle-caption"></div>'; //echo '<div class="cycle-overlay"></div>'; } } /** * Showing nawigation buttons */ if ($slider[0]['show_navigation'] && $slider_count > 1) { $hover = ''; if ($slider[0]['navigation_on_hover_state_only']) { $hover = 'hover'; } echo ' <div class="slide_commands ' . $hover . '"> <div class="slide_play" style="display: none;"></div> <div class="slide_stop" style="display: block;"></div> </div>'; echo '<div class="slide-prev ' . $hover . '"><span></span></div>'; echo '<div class="slide-next ' . $hover . '"><span></span></div>'; } foreach ($slides as &$slide) { /** * Add to hotspot product information */ $hotspots = json_decode($slide['hotsposts']); if (!empty($hotspots)) { foreach ($hotspots as &$point) { /** * $point->sku - it's post id not product sku */ if (!empty($point->sku) && is_numeric($point->sku)) { $post_data = get_post($point->sku, ARRAY_A); $product = new WC_Product($post_data['ID']); $price = $product->get_price_html(); $stock_status = $product->is_in_stock() ? 'In stock' : 'Out of stock'; $product_url = get_permalink($post_data['ID']); $url = wp_get_attachment_image_src(get_post_thumbnail_id($post_data['ID'])); $status_block = ''; $price_block = ''; $text_block = ''; $addcart_block = ''; $img_block = ''; if ($show_desc) { $img_block = !empty($url[0]) ? '<img src="' . $url[0] . '" style="width:50px" />' : ''; } switch ($post_data['post_type']) { case 'post': if ($show_desc) { $text_block = mb_substr(strip_tags($post_data['post_content']), 0, 100); } break; case 'page': if ($show_desc) { $text_block = mb_substr(strip_tags($post_data['post_content']), 0, 100); } break; case 'product': $status_block = '<div class="out-of-stock"><span>' . $stock_status . '</span></div>'; $price_block = '<div class="price">' . $price . '</div>'; if ($show_desc) { $text_block = mb_substr(strip_tags($post_data['post_excerpt']), 0, 100); } if ($show_addcart) { $addcart_block = '<div class="add-to-cart"> <form method="post" action="' . esc_url($product_url) . '"> <input type="hidden" value="' . $post_data['ID'] . '" name="add-to-cart"> <label for="qty">' . __('Qty') . ':</label> <input type="text" class="qty" title="Qty" value="1" maxlength="12" id="qty" name="quantity"> <button class="button btn-cart" title="Add to Cart" type="submit"><span>' . __('Add to Cart') . '</span></button> </form> </div>'; } break; } $point->text = '<div class="product-info"> <div class="pro-detail-div"> <div class="left-detail"> <a href="' . $product_url . '">' . $post_data['post_title'] . '</a> ' . $status_block . ' <div class="desc"> ' . $img_block . ' ' . $text_block . ' </div> ' . $price_block . ' ' . $addcart_block . ' </div> </div> </div>' . $hot_point_icon; } else { $point->text = '<div class="product-info"> <div class="pro-detail-div"> <div> <a href="' . $point->href . '" target="_blank">' . $point->text . '</a> </div> </div> </div>' . $hot_point_icon; } } $slide['hotsposts'] = json_encode($hotspots); } /** * Output slides */ $a_start = $a_end = ''; if (!empty($slide['link'])) { $a_start = '<a href="' . $slide['link'] . '">'; $a_end = '</a>'; } $overley = ''; if ($slider_count > 1) { if ($slider[0]['show_slide_caption']) { $overley = '<div class="cycle-overlay">' . $slide['caption'] . ' </div>'; } } echo '<div class="slide" id="s_img_' . $slide['id'] . '" ' . $slide['fx'] . ' data-cycle-desc="' . $slide['caption'] . '"> ' . $a_start . '<img src="' . $upload_dir_info['baseurl'] . '/' . UPLOAD_FOLDER_NAME . '/' . $slider_id . '/' . $slide['picture'] . '" alt="' . $slide['caption'] . '" />' . $overley . $a_end . ' </div>' . "\n"; } echo '<div id="progress_' . $slider[0]['id'] . '"></div>'; unset($slide); echo '</div>'; alfw_add_hotspots($slides, $slider[0]['id']); /** * Showing thumbneils pages */ if ($slider_count > 1) { if ($slider[0]['show_thumbnails']) { alfw_thumbnails_js($slider[0]['id']); echo '<div id="pagernav_' . $slider[0]['id'] . '" class="pagernav" style="max-width: ' . $slider[0]['width'] . 'px;"> <ul id="thumb_nav" class="cycle-slideshow" data-cycle-slides="> li.thumb" data-cycle-timeout="0" data-cycle-fx="carousel" data-cycle-carousel-visible="' . $slider_count . '" data-cycle-carousel-fluid=true data-allow-wrap="false" data-cycle-log="false" data-cycle-prev="#pagernav_' . $slider[0]['id'] . ' .cycle-prev" data-cycle-next="#pagernav_' . $slider[0]['id'] . ' .cycle-next" >'; foreach ($slides as $slide) { echo '<li class="thumb"> <img src="' . $upload_dir_info['baseurl'] . '/' . UPLOAD_FOLDER_NAME_THUMB . '/' . $slider_id . '/' . $slide['picture'] . '" alt="' . $slide['caption'] . '" /> </li>' . "\n"; } echo '</ul> </div>'; } else { /** * Simple pager */ echo ' <div class="pagernav" id="pagernav_' . $slider[0]['id'] . '"> <ul class="cycle"> </ul> </div>'; } } /** * Output content after */ if (!empty($slider[0]['content_after'])) { echo '<div class="c_after">' . $slider[0]['content_after'] . '</div>'; } echo '</div>'; } }
function sysProductLoop($category_name, $number_posts) { if (empty($number_posts)) { $number_posts = -1; } $args = array('showposts' => $number_posts, 'product_cat' => $category_name, 'post_type' => 'product'); $loop = new WP_Query($args); if ($loop->have_posts()) { ?> <section class="loop__products masonry__grid"> <?php while ($loop->have_posts()) { $loop->the_post(); // gets the loop__product info $product = new WC_Product(get_the_ID()); $product_price = $product->get_price_html(); // gets the group info $groups = new Groups_Post_Access(); $groups_post = $groups->get_read_post_capabilities(get_the_ID()); ?> <div class="loop__product masonry__item"<?php // adds all groups applied to loop__product to the attribute 'data-machines' if (!empty($groups)) { $x = 0; echo 'data-machines="'; foreach ($groups_post as $group) { if ($x > 0) { echo " "; } else { $x++; } $group_sort = strtolower($group); $group_sort = str_replace('|', '', $group_sort); $group_sort = str_replace(' ', '-', $group_sort); $group_sort = str_replace('--', '-', $group_sort); echo $group_sort; } echo '"'; } ?> > <a href="<?php the_permalink(); ?> " class="loop__product__link"> <?php // if loop__product has image if (get_the_post_thumbnail()) { // get loop__product image $url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'medium'); ?> <div class="loop__product__image__container"> <img data-layzr="<?php echo $url[0]; ?> " alt="<?php the_title(); ?> image" class="loop__product__image"> </div> <?php } ?> <div class="loop__product__header"> <h2 class="loop__product__title"><?php echo ucwords(get_the_title()); ?> </h2> <p class="loop__product__price"><?php echo $product_price; ?> </p> </div> <?php if (get_the_excerpt()) { $x = get_the_excerpt(); echo '<p class="loop__product__excerpt">' . $x . '</p>'; } ?> </a> </div> <?php } // END | While $loop->have_posts(); ?> </section> <?php } // END | If $loop->have_posts() // to make sure that any wp_query's after don't use the same $args wp_reset_query(); }
function TS_VCSC_WooCommerce_Grid_Basic_Function($atts, $content = null) { global $VISUAL_COMPOSER_EXTENSIONS; global $product; global $woocommerce; ob_start(); if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == "true") { if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_LoadFrontEndForcable == "false") { wp_enqueue_style('ts-visual-composer-extend-front'); } } else { wp_enqueue_script('ts-extend-hammer'); wp_enqueue_script('ts-extend-nacho'); wp_enqueue_style('ts-extend-nacho'); wp_enqueue_style('ts-extend-dropdown'); wp_enqueue_script('ts-extend-dropdown'); wp_enqueue_style('ts-font-ecommerce'); wp_enqueue_style('ts-extend-animations'); wp_enqueue_style('dashicons'); if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_LoadFrontEndForcable == "false") { wp_enqueue_style('ts-extend-buttons'); wp_enqueue_style('ts-visual-composer-extend-front'); wp_enqueue_script('ts-extend-isotope'); wp_enqueue_script('ts-visual-composer-extend-front'); } add_action('wp_footer', array($this, 'TS_VCSC_WooCommerce_Grid_Function_Isotope'), 9999); } extract(shortcode_atts(array('selection' => 'recent_products', 'category' => '', 'ids' => '', 'orderby' => 'date', 'order' => 'desc', 'products_total' => 12, 'exclude_outofstock' => 'false', 'show_image' => 'true', 'show_link' => 'true', 'link_page' => 'false', 'link_target' => '_parent', 'show_rating' => 'true', 'show_stock' => 'true', 'show_price' => 'true', 'show_cart' => 'true', 'show_info' => 'true', 'show_content' => 'excerpt', 'cutoff_characters' => 400, 'lightbox_group_name' => 'nachogroup', 'lightbox_size' => 'full', 'lightbox_effect' => 'random', 'lightbox_speed' => 5000, 'lightbox_social' => 'true', 'lightbox_backlight_choice' => 'predefined', 'lightbox_backlight_color' => '#0084E2', 'lightbox_backlight_custom' => '#000000', 'image_position' => 'ts-imagefloat-center', 'hover_type' => 'ts-imagehover-style1', 'hover_active' => 'false', 'overlay_trigger' => 'ts-trigger-hover', 'rating_maximum' => 5, 'rating_value' => 0, 'rating_dynamic' => '', 'rating_quarter' => 'true', 'rating_size' => 16, 'rating_auto' => 'false', 'rating_rtl' => 'false', 'rating_symbol' => 'other', 'rating_icon' => 'ts-ecommerce-starfull1', 'color_rated' => '#FFD800', 'color_empty' => '#e3e3e3', 'caption_show' => 'false', 'caption_position' => 'left', 'caption_digits' => '.', 'caption_danger' => '#d9534f', 'caption_warning' => '#f0ad4e', 'caption_info' => '#5bc0de', 'caption_primary' => '#428bca', 'caption_success' => '#5cb85c', 'post_type' => 'product', 'date_format' => 'F j, Y', 'time_format' => 'l, g:i A', 'filter_menu' => 'true', 'layout_menu' => 'true', 'sort_menu' => 'false', 'directions_menu' => 'false', 'filter_by' => 'product_cat', 'layout' => 'masonry', 'column_width' => 285, 'layout_break' => 600, 'show_periods' => 'false', 'sort_by' => 'postName', 'sort_order' => 'asc', 'posts_limit' => 25, 'posts_lazy' => 'false', 'posts_ajax' => 10, 'posts_load' => 'Show More', 'posts_trigger' => 'click', 'margin_top' => 0, 'margin_bottom' => 0, 'el_id' => '', 'el_class' => '', 'css' => ''), $atts)); $postsgrid_random = mt_rand(999999, 9999999); $opening = $closing = $controls = $products = ''; $posts_limit = $products_total; if (!empty($el_id)) { $posts_container_id = $el_id; } else { $posts_container_id = 'ts-vcsc-woocommerce-grid-' . $postsgrid_random; } // Backlight Color if ($lightbox_backlight_choice == "predefined") { $lightbox_backlight_selection = $lightbox_backlight_color; } else { $lightbox_backlight_selection = $lightbox_backlight_custom; } // Check for Front End Editor if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == "true") { $product_style = ''; $frontend_edit = 'true'; $description_style = 'display: none; padding: 15px;'; } else { $product_style = ''; $frontend_edit = 'false'; $description_style = 'display: none; padding: 15px;'; } $meta_query = ''; // Recent Products if ($selection == "recent_products") { $meta_query = WC()->query->get_meta_query(); } // Featured Products if ($selection == "featured_products") { $meta_query = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes')); } // Top Rated Products if ($selection == "top_rated_products") { add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); $meta_query = WC()->query->get_meta_query(); } // Final Query Arguments $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $products_total, 'orderby' => $orderby, 'order' => $order, 'paged' => 1, 'meta_query' => $meta_query); // Products on Sale if ($selection == "sale_products") { $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'] = $meta_query; $args['post__in'] = $product_ids_on_sale; } // Best Selling Products if ($selection == "best_selling_products") { $args['meta_key'] = 'total_sales'; $args['orderby'] = 'meta_value_num'; $args['meta_query'] = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')); } // Products in Single Category if ($selection == "product_category") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($category)), 'field' => 'slug', 'operator' => 'IN')); } // Products in Multiple Categories if ($selection == "product_categories") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => explode(",", $ids), 'field' => 'term_id', 'operator' => 'IN')); } $menu_tax = 'product_cat'; $limit_tax = 'product_cat'; // Start WordPress Query $loop = new WP_Query($args); // Language Settings: Isotope Posts $TS_VCSC_Isotope_Posts_Language = get_option('ts_vcsc_extend_settings_translationsIsotopePosts', ''); if ($TS_VCSC_Isotope_Posts_Language == false || empty($TS_VCSC_Isotope_Posts_Language)) { $TS_VCSC_Isotope_Posts_Language = $VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_Isotope_Posts_Language_Defaults; } if (function_exists('vc_shortcode_custom_css_class')) { $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, ' ' . vc_shortcode_custom_css_class($css, ' '), 'TS_VCSC_WooCommerce_Grid_Basic', $atts); } else { $css_class = ''; } if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == 'false') { $isotope_posts_list_class = 'ts-posts-timeline-view'; } else { $isotope_posts_list_class = 'ts-posts-timeline-edit'; } if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == 'true') { echo '<div id="ts-isotope-posts-grid-frontend-' . $postsgrid_random . '" class="ts-isotope-posts-grid-frontend" style="border: 1px solid #ededed; padding: 10px;">'; echo '<div style="font-weight: bold;">"Basic Products Isotope Grid"</div>'; echo '<div style="margin-bottom: 20px;">The element has been disabled in order to ensure compatiblity with the Visual Composer Front-End Editor.</div>'; echo '<div>' . __("Number of Products", "ts_visual_composer_extend") . ': ' . $posts_limit . '</div>'; $front_edit_reverse = array("excerpt" => __('Excerpt', "ts_visual_composer_extend"), "cutcharacters" => __('Character Limited Content', "ts_visual_composer_extend"), "complete" => __('Full Content', "ts_visual_composer_extend")); foreach ($front_edit_reverse as $key => $value) { if ($key == $show_content) { echo '<div>' . __("Content Length", "ts_visual_composer_extend") . ': ' . $value . '</div>'; } } $front_edit_reverse = array("masonry" => __('Centered Masonry', "ts_visual_composer_extend"), "fitRows" => __('Fit Rows', "ts_visual_composer_extend"), "straightDown" => __('Straight Down', "ts_visual_composer_extend")); foreach ($front_edit_reverse as $key => $value) { if ($key == $layout) { echo '<div>' . __("Content", "ts_visual_composer_extend") . ': ' . $value . '</div>'; } } $front_edit_reverse = array("postName" => __('Product Name', "ts_visual_composer_extend"), "postPrice" => __('Product Price', "ts_visual_composer_extend"), "postRating" => __('Product Rating', "ts_visual_composer_extend"), "postDate" => __('Product Date', "ts_visual_composer_extend"), "postModified" => __('Product Modified', "ts_visual_composer_extend")); foreach ($front_edit_reverse as $key => $value) { if ($key == $sort_by) { echo '<div>' . __("Sort Criterion", "ts_visual_composer_extend") . ': ' . $value . '</div>'; } } $front_edit_reverse = array("asc" => __('Bottom to Top', "ts_visual_composer_extend"), "desc" => __('Top to Bottom', "ts_visual_composer_extend")); foreach ($front_edit_reverse as $key => $value) { if ($key == $sort_order) { echo '<div>' . __("Initial Order", "ts_visual_composer_extend") . ': ' . $value . '</div>'; } } echo '<div>' . __("Show Filter Button", "ts_visual_composer_extend") . ': ' . $filter_menu . '</div>'; echo '<div>' . __("Show Layout Button", "ts_visual_composer_extend") . ': ' . $layout_menu . '</div>'; echo '<div>' . __("Show Sort Criterion Button", "ts_visual_composer_extend") . ': ' . $sort_menu . '</div>'; echo '<div>' . __("Show Directions Buttons", "ts_visual_composer_extend") . ': ' . $directions_menu . '</div>'; echo '</div>'; } else { $opening .= '<div id="' . $posts_container_id . '" class="ts-isotope-posts-grid-parent ' . ($layout == 'spineTimeline' ? 'ts-timeline ' : 'ts-postsgrid ') . 'ts-timeline-' . $sort_order . ' ts-posts-timeline ' . $isotope_posts_list_class . ' ' . $css_class . '" style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . ';" data-lazy="' . $posts_lazy . '" data-count="' . $posts_limit . '" data-ajax="' . $posts_ajax . '" data-trigger="' . $posts_trigger . '" data-column="' . $column_width . '" data-layout="' . $layout . '" data-sort="' . $sort_by . '" data-order="' . $sort_order . '" data-break="' . $layout_break . '" data-type="' . $post_type . '">'; // Create Individual Post Output $postCounter = 0; $postCategories = array(); $categoriesCount = 0; if (post_type_exists($post_type) && $loop->have_posts()) { $products .= '<div class="ts-timeline-content">'; $products .= '<ul id="ts-isotope-posts-grid-' . $postsgrid_random . '" class="ts-isotope-posts-grid ts-timeline-list" data-layout="' . $layout . '" data-key="' . $postsgrid_random . '">'; while ($loop->have_posts()) { $loop->the_post(); $postCounter++; $product_id = get_the_ID(); $product_title = get_the_title($product_id); $post = get_post($product_id); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $price = $product->get_price_html(); $product_sku = $product->get_sku(); $attributes = $product->get_attributes(); $stock = $product->is_in_stock() ? 'true' : 'false'; $onsale = $product->is_on_sale() ? 'true' : 'false'; // Rating Settings $rating_html = $product->get_rating_html(); $rating = $product->get_average_rating(); if ($rating == '') { $rating = 0; } if ($rating_quarter == "true") { $rating_value = floor($rating * 4) / 4; } else { $rating_value = $rating; } $rating_value = number_format($rating_value, 2, $caption_digits, ''); if ($rating_rtl == "false") { $rating_width = $rating_value / $rating_maximum * 100; } else { $rating_width = 100 - $rating_value / $rating_maximum * 100; } if ($rating_symbol == "other") { if ($rating_icon == "ts-ecommerce-starfull1") { $rating_class = 'ts-rating-stars-star1'; } else { if ($rating_icon == "ts-ecommerce-starfull2") { $rating_class = 'ts-rating-stars-star2'; } else { if ($rating_icon == "ts-ecommerce-starfull3") { $rating_class = 'ts-rating-stars-star3'; } else { if ($rating_icon == "ts-ecommerce-starfull4") { $rating_class = 'ts-rating-stars-star4'; } else { if ($rating_icon == "ts-ecommerce-heartfull") { $rating_class = 'ts-rating-stars-heart1'; } else { if ($rating_icon == "ts-ecommerce-heart") { $rating_class = 'ts-rating-stars-heart2'; } else { if ($rating_icon == "ts-ecommerce-thumbsup") { $rating_class = 'ts-rating-stars-thumb'; } else { if ($rating_icon == "ts-ecommerce-ribbon4") { $rating_class = 'ts-rating-stars-ribbon'; } } } } } } } } } else { $rating_class = 'ts-rating-stars-smile'; } if ($rating_value >= 0 && $rating_value <= 1) { $caption_class = 'ts-label-danger'; $caption_background = 'background-color: ' . $caption_danger . ';'; } else { if ($rating_value > 1 && $rating_value <= 2) { $caption_class = 'ts-label-warning'; $caption_background = 'background-color: ' . $caption_warning . ';'; } else { if ($rating_value > 2 && $rating_value <= 3) { $caption_class = 'ts-label-info'; $caption_background = 'background-color: ' . $caption_info . ';'; } else { if ($rating_value > 3 && $rating_value <= 4) { $caption_class = 'ts-label-primary'; $caption_background = 'background-color: ' . $caption_primary . ';'; } else { if ($rating_value > 4 && $rating_value <= 5) { $caption_class = 'ts-label-success'; $caption_background = 'background-color: ' . $caption_success . ';'; } } } } } if (has_post_thumbnail($loop->post->ID)) { $featured = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full'); $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail'); $featured = $featured[0]; $thumbnail = $thumbnail[0]; } else { $featured = woocommerce_placeholder_img_src(); $thumbnail = $featured; } $title = get_the_title(); // Create Output if ($postCounter < $posts_limit + 1) { $postAttributes = 'data-visible="false" data-price="' . TS_VCSC_CleanNumberData($product->price) . '" data-rating="' . TS_VCSC_CleanNumberData($rating) . '" data-full="' . get_post_time($date_format) . '" data-author="' . get_the_author() . '" data-date="' . get_post_time('U') . '" data-modified="' . get_the_modified_time('U') . '" data-title="' . get_the_title() . '" data-comments="' . get_comments_number() . '" data-id="' . get_the_ID() . '"'; if ($exclude_outofstock == "true" && $stock == "true" || $exclude_outofstock == "false") { $product_categories = ''; if ($filter_menu == 'true' && taxonomy_exists($menu_tax)) { foreach (get_the_terms($loop->post->ID, $menu_tax) as $term) { $product_categories .= $term->slug . ' '; $category_check = 0; foreach ($postCategories as $index => $array) { if ($postCategories[$index]['slug'] == $term->slug) { $category_check++; } } if ($category_check == 0) { $categoriesCount++; $categories_array = array('slug' => $term->slug, 'name' => $term->name); $postCategories[] = $categories_array; } } } $product_categories .= 'rating-' . TS_VCSC_CleanNumberData($rating) . ' '; $products .= '<li class="ts-timeline-list-item ts-timeline-date-true ts-isotope-posts-list-item ' . $product_categories . '" ' . $postAttributes . ' style="margin: 10px;">'; $products .= '<div class="ts-woocommerce-product-slide" style="' . $product_style . '" data-hash="' . $product_id . '">'; $products .= '<div id="ts-woocommerce-product-' . $product_id . '" class="ts-image-hover-frame ' . $image_position . ' ts-trigger-hover-adjust" style="width: 100%;">'; $products .= '<div id="ts-woocommerce-product-' . $product_id . '-counter" class="ts-fluid-wrapper " style="width: 100%; height: auto;">'; $products .= '<div id="ts-woocommerce-product-' . $product_id . '-mask" class="ts-imagehover ' . $hover_type . ' ts-trigger-hover" data-trigger="ts-trigger-hover" data-closer="" style="width: 100%; height: auto;">'; // Product Thumbnail $products .= '<div class="ts-woocommerce-product-preview">'; $products .= '<img class="ts-woocommerce-product-image" src="' . $featured . '" alt="" />'; $products .= '</div>'; // Sale Ribbon if ($onsale == "true") { $products .= '<div class="ts-woocommerce-product-ribbon"></div>'; $products .= '<i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-sale ts-ecommerce-tagsale"></i>'; } $products .= '<div class="ts-woocommerce-product-main">'; $products .= '<div class="mask" style="width: 100%; display: block;">'; $products .= '<div id="ts-woocommerce-product-' . $product_id . '-maskcontent" class="maskcontent" style="margin: 0; padding: 0;">'; // Product Thubmnail if ($show_image == "true") { if ($link_page == "false") { $products .= '<div class="ts-woocommerce-link-wrapper"><a id="" class="nch-lightbox-media" data-title="' . $title . '" rel="" href="' . $featured . '" target="' . $link_target . '">'; $products .= '<div class="ts-woocommerce-product-thumbnail" style="background-image: url(' . $thumbnail . ');"></div>'; $products .= '</a></div>'; } else { $products .= '<div class="ts-woocommerce-link-wrapper"><a id="" class="" data-title="' . $title . '" rel="" href="' . get_permalink() . '" target="' . $link_target . '">'; $products .= '<div class="ts-woocommerce-product-thumbnail" style="background-image: url(' . $thumbnail . ');"></div>'; $products .= '</a></div>'; } } // Product Page Link if ($show_link == "true") { $products .= '<div class="ts-woocommerce-link-wrapper"><a href="' . get_permalink() . '" class="ts-woocommerce-product-link" target="_blank"><i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-view ts-ecommerce-forward"></i></a></div>'; } // Product Rating if ($show_rating == "true") { $products .= '<div class="ts-rating-stars-frame" data-auto="' . $rating_auto . '" data-size="' . $rating_size . '" data-width="' . $rating_size * 5 . '" data-rating="' . $rating_value . '" style="margin: 10px 0 0 10px; float: left;">'; $products .= '<div class="ts-star-rating' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-active " style="font-size: ' . $rating_size . 'px; line-height: ' . ($rating_size + 5) . 'px;">'; if ($caption_show == "true" && $caption_position == "left") { $products .= '<div class="ts-rating-caption" style="margin-right: 10px;">'; if ($rating_rtl == "false") { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $products .= '</div>'; } $products .= '<div class="ts-rating-container' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-glyph-holder ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_empty : $color_rated) . ';">'; $products .= '<div class="ts-rating-stars ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_rated : $color_empty) . '; width: ' . $rating_width . '%;"></div>'; $products .= '</div>'; if ($caption_show == "true" && $caption_position == "right") { $products .= '<div class="ts-rating-caption" style="margin-left: 10px;">'; if ($rating_rtl == "false") { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $products .= '</div>'; } $products .= '</div>'; $products .= '</div>'; } // Product Price if ($show_price == "true") { $products .= '<div class="ts-woocommerce-product-price">'; $products .= '<i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-cost ts-ecommerce-pricetag3"></i>'; if ($product->price > 0) { if ($product->price && isset($product->regular_price)) { $from = $product->regular_price; $to = $product->price; if ($from != $to) { $products .= '<div class="ts-woocommerce-product-regular"><del>' . (is_numeric($from) ? woocommerce_price($from) : $from) . '</del> | </div><div class="ts-woocommerce-product-special">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } else { $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } $products .= '</div>'; } $products .= '<div class="ts-woocommerce-product-line"></div>'; // Add to Cart Button (Icon) if ($show_cart == "true") { $products .= '<div class="ts-woocommerce-link-wrapper"><a class="ts-woocommerce-product-purchase" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a></div>'; } // View Description Button if ($show_info == "true") { $products .= '<div id="ts-vcsc-modal-' . $product_id . '-trigger" style="" class="ts-vcsc-modal-' . $product_id . '-parent nch-holder ts-vcsc-font-icon ts-font-icons ts-shortcode ts-icon-align-center" style="">'; $products .= '<a href="#ts-vcsc-modal-' . $product_id . '" class="nch-lightbox-modal" data-title="" data-open="false" data-delay="0" data-type="html" rel="" data-effect="' . $lightbox_effect . '" data-share="0" data-duration="' . $lightbox_speed . '" data-color="' . $lightbox_backlight_selection . '">'; $products .= '<span class="">'; $products .= '<i class="ts-font-icon ts-woocommerce-product-icon ts-woocommerce-product-info ts-ecommerce-information1" style=""></i>'; $products .= '</span>'; $products .= '</a>'; $products .= '</div>'; } // Product In-Stock or Unavailable if ($show_stock == "true") { $products .= '<div class="ts-woocommerce-product-status">'; if ($stock == 'false') { $products .= '<div class="ts-woocommerce-product-stock"><span class="ts-woocommerce-product-outofstock">' . __('Out of Stock', 'woocommerce') . '</span></div>'; } else { if ($stock == 'true') { $products .= '<div class="ts-woocommerce-product-stock"><span class="ts-woocommerce-product-instock">' . __('In Stock', 'woocommerce') . '</span></div>'; } } $products .= '</div>'; } $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; // Product Title $products .= '<h2 class="ts-woocommerce-product-title">'; $products .= $title; $products .= '</h2>'; // Product Description if ($show_info == "true") { $products .= '<div id="ts-vcsc-modal-' . $product_id . '" class="ts-modal-content nch-hide-if-javascript" style="' . $description_style . '">'; $products .= '<div class="ts-modal-white-header"></div>'; $products .= '<div class="ts-modal-white-frame">'; $products .= '<div class="ts-modal-white-inner">'; $products .= '<h2 style="border-bottom: 1px solid #eeeeee; padding-bottom: 10px; line-height: 32px; font-size: 24px; text-align: left;">' . $title . '</h2>'; $products .= '<div class="ts-woocommerce-lightbox-frame" style="width: 100%; height: 32px; margin: 10px auto; padding: 0;">'; $products .= '<a style="position: inherit; margin-left: 10px; float: right;" class="ts-woocommerce-product-purchase" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="color: #000000;" class="ts-woocommerce-product-icon ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a>'; $products .= '<a href="' . get_permalink() . '" target="_parent" style="position: inherit; margin-left: 10px; float: right;" class="ts-woocommerce-product-link"><i style="color: #000000;" class="ts-woocommerce-product-icon ts-woocommerce-product-view ts-ecommerce-forward"></i></a>'; $products .= '<div class="ts-rating-stars-frame" data-auto="' . $rating_auto . '" data-size="' . $rating_size . '" data-width="' . $rating_size * 5 . '" data-rating="' . $rating_value . '" style="margin: 0; float: right;">'; $products .= '<div class="ts-star-rating' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-active " style="font-size: ' . $rating_size . 'px; line-height: ' . ($rating_size + 5) . 'px;">'; if ($caption_show == "true" && $caption_position == "left") { $products .= '<div class="ts-rating-caption" style="margin-right: 10px;">'; if ($rating_rtl == "false") { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $products .= '</div>'; } $products .= '<div class="ts-rating-container' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-glyph-holder ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_empty : $color_rated) . ';">'; $products .= '<div class="ts-rating-stars ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_rated : $color_empty) . '; width: ' . $rating_width . '%;"></div>'; $products .= '</div>'; if ($caption_show == "true" && $caption_position == "right") { $products .= '<div class="ts-rating-caption" style="margin-left: 10px;">'; if ($rating_rtl == "false") { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $products .= '</div>'; } $products .= '</div>'; $products .= '</div>'; $products .= '<div class="ts-woocommerce-product-price" style="position: inherit; margin-right: 10px; float: left; width: auto; margin-top: 0;">'; $products .= '<i style="color: #000000; margin: 0 10px 0 0;" class="ts-woocommerce-product-icon ts-woocommerce-product-cost ts-ecommerce-pricetag3"></i>'; if ($product->price > 0) { if ($product->price && isset($product->regular_price)) { $from = $product->regular_price; $to = $product->price; if ($from != $to) { $products .= '<div class="ts-woocommerce-product-regular"><del style="color: #7F0000;">' . (is_numeric($from) ? woocommerce_price($from) : $from) . '</del> | </div><div class="ts-woocommerce-product-special">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } else { $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } $products .= '</div>'; $products .= '</div>'; $products .= '<div class="ts-woocommerce-product-seperator" style="border-bottom: 1px solid #eeeeee; margin: 10px auto 20px auto; width: 100%;"></div>'; $products .= '<img style="width: 100%; max-width: 250px; height: auto; margin: 10px auto;" class="ts-woocommerce-product-image" src="' . $featured . '" alt="" />'; $products .= '<div class="ts-woocommerce-product-seperator" style="border-bottom: 1px solid #eeeeee; margin: 20px auto 10px auto; width: 100%;"></div>'; $products .= '<div style="margin-top: 20px; text-align: justify;">'; if ($show_content == "excerpt") { $products .= get_the_excerpt(); } else { if ($show_content == "cutcharacters") { $content = apply_filters('the_content', get_the_content()); $excerpt = TS_VCSC_TruncateHTML($content, $cutoff_characters, '...', false, true); $products .= $excerpt; } else { if ($show_content == "complete") { $products .= get_the_content(); } } } $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; } $products .= '</div>'; $products .= '</li>'; } } } $products .= '</ul>'; $products .= '</div>'; if ($posts_lazy == "true") { $products .= '<div class="ts-load-more-wrap">'; $products .= '<span class="ts-timeline-load-more">' . $posts_load . '</span>'; $products .= '</div>'; } wp_reset_postdata(); } else { $products .= '<p>Nothing found. Please check back soon!</p>'; } // Create Post Controls (Filter, Sort) $controls .= '<div id="ts-isotope-posts-grid-controls-' . $postsgrid_random . '" class="ts-isotope-posts-grid-controls">'; if ($directions_menu == 'true' && $posts_lazy == 'false') { $controls .= '<div class="ts-button ts-button-flat ts-timeline-controls-desc ts-isotope-posts-controls-desc ' . ($sort_order == "desc" ? "active" : "") . '"><span class="ts-isotope-posts-controls-desc-image"></span></div>'; $controls .= '<div class="ts-button ts-button-flat ts-timeline-controls-asc ts-isotope-posts-controls-asc ' . ($sort_order == "asc" ? "active" : "") . '"><span class="ts-isotope-posts-controls-asc-image"></span></div>'; } $controls .= '<div class="ts-isotope-posts-grid-controls-menus">'; if ($filter_menu == 'true') { if ($categoriesCount > 1) { $controls .= '<div id="ts-isotope-posts-filter-trigger-' . $postsgrid_random . '" class="ts-isotope-posts-filter-trigger" data-dropdown="#ts-isotope-posts-filter-' . $postsgrid_random . '" data-horizontal-offset="0" data-vertical-offset="0"><span>' . $TS_VCSC_Isotope_Posts_Language['WooFilterProducts'] . '</span></div>'; $controls .= '<div id="ts-isotope-posts-filter-' . $postsgrid_random . '" class="ts-dropdown ts-dropdown-tip ts-dropdown-relative ts-dropdown-anchor-left" style="left: 0px;">'; $controls .= '<ul id="" class="ts-dropdown-menu">'; $controls .= '<li><label style="font-weight: bold;"><input class="ts-isotope-posts-filter ts-isotope-posts-filter-all" type="checkbox" style="margin-right: 10px;" checked="checked" data-type="all" data-key="' . $postsgrid_random . '" data-filter="*">' . $TS_VCSC_Isotope_Posts_Language['SeeAll'] . '</label></li>'; $controls .= '<li class="ts-dropdown-divider"></li>'; foreach ($postCategories as $index => $array) { $controls .= '<li><label><input class="ts-isotope-posts-filter ts-isotope-posts-filter-single" type="checkbox" style="margin-right: 10px;" data-type="single" data-key="' . $postsgrid_random . '" data-filter=".' . $postCategories[$index]['slug'] . '">' . $postCategories[$index]['name'] . '</label></li>'; } $controls .= '</ul>'; $controls .= '</div>'; } } if ($layout_menu == 'true') { $controls .= '<div id="ts-isotope-posts-layout-trigger-' . $postsgrid_random . '" class="ts-isotope-posts-layout-trigger" data-dropdown="#ts-isotope-posts-layout-' . $postsgrid_random . '" data-horizontal-offset="0" data-vertical-offset="0"><span>' . $TS_VCSC_Isotope_Posts_Language['ButtonLayout'] . '</span></div>'; $controls .= '<div id="ts-isotope-posts-layout-' . $postsgrid_random . '" class="ts-dropdown ts-dropdown-tip ts-dropdown-relative ts-dropdown-anchor-left" style="left: 0px;">'; $controls .= '<ul id="" class="ts-dropdown-menu">'; $controls .= '<li><label><input class="ts-isotope-posts-layout" type="radio" name="radio-group-' . $postsgrid_random . '" data-layout="masonry" style="margin-right: 10px;" ' . ($layout == 'masonry' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['Masonry'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-layout" type="radio" name="radio-group-' . $postsgrid_random . '" data-layout="fitRows" style="margin-right: 10px;" ' . ($layout == 'fitRows' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['FitRows'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-layout" type="radio" name="radio-group-' . $postsgrid_random . '" data-layout="straightDown" style="margin-right: 10px;" ' . ($layout == 'straightDown' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['StraightDown'] . '</label></li>'; $controls .= '</ul>'; $controls .= '</div>'; } if ($sort_menu == 'true') { $controls .= '<div id="ts-isotope-posts-sort-trigger-' . $postsgrid_random . '" class="ts-isotope-posts-sort-trigger" data-dropdown="#ts-isotope-posts-sort-' . $postsgrid_random . '" data-horizontal-offset="0" data-vertical-offset="0"><span>' . $TS_VCSC_Isotope_Posts_Language['ButtonSort'] . '</span></div>'; $controls .= '<div id="ts-isotope-posts-sort-' . $postsgrid_random . '" class="ts-dropdown ts-dropdown-tip ts-dropdown-relative ts-dropdown-anchor-left" style="left: 0px;">'; $controls .= '<ul id="" class="ts-dropdown-menu">'; $controls .= '<li><label><input class="ts-isotope-posts-sort" type="radio" name="radio-sort-' . $postsgrid_random . '" data-sort="postName" style="margin-right: 10px;" ' . ($sort_by == 'postName' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['WooTitle'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-sort" type="radio" name="radio-sort-' . $postsgrid_random . '" data-sort="postPrice" style="margin-right: 10px;" ' . ($sort_by == 'postPrice' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['WooPrice'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-sort" type="radio" name="radio-sort-' . $postsgrid_random . '" data-sort="postRatings" style="margin-right: 10px;" ' . ($sort_by == 'postRatings' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['WooRating'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-sort" type="radio" name="radio-sort-' . $postsgrid_random . '" data-sort="postDate" style="margin-right: 10px;" ' . ($sort_by == 'postDate' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['WooDate'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-sort" type="radio" name="radio-sort-' . $postsgrid_random . '" data-sort="postModified" style="margin-right: 10px;" ' . ($sort_by == 'postModified' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['WooModified'] . '</label></li>'; $controls .= '</ul>'; $controls .= '</div>'; } $controls .= '</div>'; $controls .= '<div class="clearFixMe" style="clear:both;"></div>'; $controls .= '</div>'; $closing .= '</div>'; echo $opening; echo $controls; echo $products; echo $closing; } $myvariable = ob_get_clean(); return $myvariable; }
protected function content($atts, $content = null) { $atts = function_exists('vc_map_get_attributes') ? vc_map_get_attributes('kt_featured_products', $atts) : $atts; $atts = shortcode_atts(array('title' => __('Hot Categories', 'kutetheme'), 'box_type' => 'featured', 'ids' => '', 'number' => 4, 'css_animation' => '', 'el_class' => '', 'css' => ''), $atts); extract($atts); $elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, ' trending ', $this->settings['base'], $atts), 'extra' => $this->getExtraClass($el_class), 'css_animation' => $this->getCSSAnimation($css_animation), 'shortcode_custom' => vc_shortcode_custom_css_class($css, ' ')); $elementClass = preg_replace(array('/\\s+/', '/^\\s|\\s$/'), array(' ', ''), implode(' ', $elementClass)); ob_start(); $args = array('post_type' => 'product', 'meta_key' => '_featured', 'meta_value' => 'yes', 'posts_per_page' => $number); if ($ids) { $ids = explode(',', $ids); } else { $ids = array(); } if ($box_type == 'by_id') { $args = array('post_type' => 'product', 'post__in' => $ids); } $products = get_posts($args); $count = count($products); $per_page = 2; $loop = false; if ($count > 2) { $loop = true; } ?> <div class=" <?php echo esc_attr($elementClass); ?> "> <?php if ($title) { ?> <h2 class="trending-title"><?php echo esc_html($title); ?> </h2> <?php } ?> <div class="trending-product owl-carousel nav-center" data-items="1" data-dots="false" data-nav="true" data-autoplay="true" <?php if ($loop) { ?> data-loop="true" <?php } ?> > <?php $page = 1; if ($count % $per_page == 0) { $page = $count / $per_page; } else { $page = $count / $per_page + 1; } ?> <?php for ($i = 1; $i <= $page; $i++) { ?> <ul> <?php $from = ($i - 1) * $per_page; $to = $i * $per_page; for ($from; $from < $to; $from++) { if (isset($products[$from]) && $products[$from]) { $p = $products[$from]; $product = new WC_Product($p->ID); ?> <li> <div class="product-container"> <div class="product-image"> <a href="<?php echo get_permalink($p->ID); ?> "> <?php echo get_the_post_thumbnail($p->ID, 'shop_thumbnai'); ?> </a> </div> <div class="product-info"> <h5 class="product-name"> <a href="<?php echo get_permalink($p->ID); ?> "><?php echo esc_html($p->post_title); ?> </a> </h5> <div class="product-price"> <?php echo $product->get_price_html(); ?> </div> </div> </div> </li> <?php } } ?> </ul> <?php } ?> </div> </div> <?php $result = ob_get_contents(); ob_end_clean(); return $result; }
function WooComposer_Loop_style04($atts, $element) { global $woocommerce; $product_style = $display_elements = $quick_view_style = $img_animate = $text_align = $color_heading = $color_categories = $color_price = ''; $color_rating = $color_rating_bg = $color_quick_bg = $color_quick = $color_cart_bg = $color_cart = $color_product_desc = $advanced_opts = ''; $color_product_desc_bg = $size_title = $size_cat = $size_price = $color_on_sale = $color_on_sale_bg = $label_on_sale = $product_animation = ''; $disp_type = $category = $output = $product_style = $border_style = $border_color = $border_size = $border_radius = $lazy_images = $pagination = ''; $sale_price = $shortcode = $on_sale_alignment = $on_sale_style = $product_img_disp = ''; extract(shortcode_atts(array("disp_type" => "", "category" => "", "shortcode" => "", "product_style" => "style01", "display_elements" => "", "quick_view_style" => "expandable", "label_on_sale" => "Sale!", "text_align" => "left", "img_animate" => "rotate-clock", "pagination" => "", "color_heading" => "", "color_categories" => "", "color_price" => "", "color_rating" => "", "color_rating_bg" => "", "color_quick_bg" => "", "color_quick" => "", "color_cart_bg" => "", "color_on_sale_bg" => "", "color_on_sale" => "", "color_cart" => "", "color_product_desc" => "", "color_product_desc_bg" => "", "size_title" => "", "size_cat" => "", "size_price" => "", "border_style" => "", "border_color" => "", "border_size" => "", "border_radius" => "", "product_animation" => "", "lazy_images" => "", "advanced_opts" => "", "sale_price" => "", "on_sale_style" => "wcmp-sale-circle", "on_sale_alignment" => "wcmp-sale-right", "product_img_disp" => "single"), $atts)); $output = $heading_style = $cat_style = $price_style = $cart_style = $cart_bg_style = $view_style = $view_bg_style = $rating_style = ''; $desc_style = $label_style = $on_sale = $class = $style = $border = $desc_style = $sale_price_size = ''; $image_size = apply_filters('single_product_large_thumbnail_size', 'shop_single'); $img_animate = 'wcmp-img-' . $img_animate; if ($sale_price !== '') { $sale_price_size = 'font-size:' . $sale_price . 'px;'; } if ($border_style !== '') { $border .= 'border:' . $border_size . 'px ' . $border_style . ' ' . $border_color . ';'; $border .= 'border-radius:' . $border_radius . 'px;'; } if ($color_product_desc_bg !== '') { $desc_style .= 'background:' . $color_product_desc_bg . ';'; } if ($color_product_desc !== '') { $desc_style .= 'color:' . $color_product_desc . ';'; } $columns = 3; $display_type = $disp_type; if ($color_heading !== "") { $heading_style = 'color:' . $color_heading . ';'; } if ($size_title !== "") { $heading_style .= 'font-size:' . $size_title . 'px;'; } if ($color_categories !== "") { $cat_style = 'color:' . $color_categories . ';'; } if ($size_cat !== "") { $cat_style .= 'font-size:' . $size_cat . 'px;'; } if ($color_price !== "") { $price_style = 'color:' . $color_price . ';'; } if ($size_price !== "") { $price_style .= 'font-size:' . $size_price . 'px;'; } if ($color_rating !== "") { $rating_style .= 'color:' . $color_rating . ';'; } if ($color_rating_bg !== "") { $rating_style .= 'background:' . $color_rating_bg . ';'; } if ($color_quick_bg !== "") { $view_bg_style = 'background:' . $color_quick_bg . ';'; } if ($color_quick !== "") { $view_style = 'color:' . $color_quick . ';'; } if ($color_cart_bg !== "") { $cart_bg_style = 'background:' . $color_cart_bg . ';'; } if ($color_cart !== "") { $cart_style = 'color:' . $color_cart . ';'; } if ($color_on_sale_bg !== "") { $label_style = 'background:' . $color_on_sale_bg . ';'; } if ($color_on_sale !== "") { $label_style .= 'color:' . $color_on_sale . ';'; } $elemets = explode(",", $display_elements); if ($element == "grid") { $paged = get_query_var('paged') ? get_query_var('paged') : 1; } else { $paged = 1; } $post_count = '12'; /* $output .= do_shortcode($content); */ if ($shortcode !== '') { $new_shortcode = rawurldecode(base64_decode(strip_tags($shortcode))); } $pattern = get_shortcode_regex(); $shortcode_str = $short_atts = ''; preg_match_all("/" . $pattern . "/", $new_shortcode, $matches); $shortcode_str = str_replace('"', '', str_replace(" ", "&", trim($matches[3][0]))); $short_atts = parse_str($shortcode_str); //explode("&",$shortcode_str); if (isset($matches[2][0])) { $display_type = $matches[2][0]; } else { $display_type = ''; } if (!isset($columns)) { $columns = '4'; } if (isset($per_page)) { $post_count = $per_page; } if (isset($number)) { $post_count = $number; } if (!isset($order)) { $order = 'asc'; } if (!isset($orderby)) { $orderby = 'date'; } if (!isset($category)) { $category = ''; } if (!isset($ids)) { $ids = ''; } if ($ids) { $ids = explode(',', $ids); $ids = array_map('trim', $ids); } $col = $columns; if ($columns == "2") { $columns = 6; } elseif ($columns == "3") { $columns = 4; } elseif ($columns == "4") { $columns = 3; } $meta_query = ''; if ($display_type == "recent_products") { $meta_query = WC()->query->get_meta_query(); } if ($display_type == "featured_products") { $meta_query = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes')); } if ($display_type == "top_rated_products") { add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); $meta_query = WC()->query->get_meta_query(); } $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $post_count, 'orderby' => $orderby, 'order' => $order, 'paged' => $paged, 'meta_query' => $meta_query); if ($display_type == "sale_products") { $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'] = $meta_query; $args['post__in'] = $product_ids_on_sale; } if ($display_type == "best_selling_products") { $args['meta_key'] = 'total_sales'; $args['orderby'] = 'meta_value_num'; $args['meta_query'] = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')); } if ($display_type == "product_category") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($category)), 'field' => 'slug', 'operator' => 'IN')); } if ($display_type == "product_categories") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => $ids, 'field' => 'term_id', 'operator' => 'IN')); } $test = ''; if (vc_is_inline()) { $test = "wcmp_vc_inline"; } if ($product_animation == '') { $product_animation = 'no-animation'; } else { $style .= 'opacity:1;'; } if ($element == "grid") { $class = 'vc_span' . $columns . ' '; } $output .= '<div class="woocomposer ' . $test . '" data-columns="' . $col . '">'; $query = new WP_Query($args); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $product_id = get_the_ID(); $uid = uniqid(); $output .= '<div id="product-' . $uid . '" style="' . $style . '" class="' . $class . ' wpb_column column_container wooproduct" data-animation="animated ' . $product_animation . '">'; if ($element == 'carousel') { $output .= '<div class="wcmp-carousel-item">'; } $product_title = get_the_title($product_id); $post = get_post($product_id); $product_desc = get_post($product_id)->post_excerpt; $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $price = $product->get_price_html(); $rating = $product->get_rating_html(); $attributes = $product->get_attributes(); $stock = $product->is_in_stock() ? 'InStock' : 'OutOfStock'; if ($product->is_on_sale()) { $on_sale = apply_filters('woocommerce_sale_flash', $label_on_sale, $post, $product); } else { $on_sale = ''; } if ($quick_view_style == "expandable") { $quick_view_class = 'quick-view-loop'; } else { $quick_view_class = 'quick-view-loop-popup'; } $cat_count = sizeof(get_the_terms($product_id, 'product_cat')); $tag_count = sizeof(get_the_terms($product_id, 'product_tag')); $categories = $product->get_categories(', ', '<span class="posted_in">' . _n('', '', $cat_count, 'woocommerce') . ' ', '.</span>'); $tags = $product->get_tags(', ', '<span class="tagged_as">' . _n('', '', $tag_count, 'woocommerce') . ' ', '.</span>'); $output .= "\n" . '<div class="wcmp-product woocommerce wcmp-' . $product_style . ' ' . $img_animate . '" style="' . $border . ' ' . $desc_style . '">'; $output .= "\n\t" . '<div class="wcmp-product-image">'; if (empty($attachment_ids) && count($attachment_ids) > 1 && $product_img_disp == "carousel") { $uniqid = uniqid(); $output .= '<div class="wcmp-single-image-carousel carousel-in-loop">'; $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); if ($lazy_images == "enable") { $src = plugins_url('../assets/img/loader.gif', __FILE__); } else { $src = $product_img[0]; } $output .= '<div><div class="wcmp-image"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div></div>'; foreach ($attachment_ids as $attachment_id) { $product_img = wp_get_attachment_image_src($attachment_id, $image_size); if ($lazy_images == "enable") { $src = plugins_url('../assets/img/loader.gif', __FILE__); } else { $src = $product_img[0]; } $output .= '<div><div class="wcmp-image"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div></div>'; } $output .= '</div>'; } else { $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); if ($lazy_images == "enable") { $src = plugins_url('../assets/img/loader.gif', __FILE__); } else { $src = $product_img[0]; } $output .= '<a href="' . get_permalink($product_id) . '"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></a>'; } if ($stock == 'OutOfStock') { $output .= "\n" . '<span class="wcmp-out-stock">' . __('Out Of Stock!', 'woocomposer') . '</span>'; } if ($on_sale !== '') { $output .= "\n" . '<div class="wcmp-onsale ' . $on_sale_alignment . ' ' . $on_sale_style . '"><span class="onsale" style="' . $label_style . ' ' . $sale_price_size . '">' . $on_sale . '</span></div>'; } $output .= '<div class="wcmp-add-to-cart" style="' . $cart_bg_style . '"><a style="' . $cart_style . '" title="Add to Cart" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-product_id="' . $product_id . '" data-product_sku="" class="add_to_cart_button product_type_simple"><i class="wooicon-cart4"></i></a></div>'; if (in_array("quick", $elemets)) { $output .= '<div class="wcmp-quick-view ' . $quick_view_class . '" style="' . $view_bg_style . '"><a style="' . $view_style . '" title="Quick View" href="' . get_permalink($product_id) . '"><i class="wooicon-plus32"></i></a></div>'; } if (in_array("reviews", $elemets)) { $output .= "\n" . '<div class="wcmp-star-ratings" style="' . $rating_style . '">' . $rating . '</div>'; } $output .= '</div>'; $output .= "\n\t" . '<div class="wcmp-product-desc">'; $output .= '<a href="' . get_permalink($product_id) . '">'; $output .= "\n\t\t" . '<h2 style="' . $heading_style . '">' . $product_title . '</h2>'; $output .= '</a>'; if (in_array("category", $elemets)) { $output .= '<h5 style="' . $cat_style . '">'; if ($categories !== '') { $output .= $categories; $output .= $tags; } $output .= '</h5>'; } $output .= "\n\t\t" . '<div class="wcmp-price"><span class="price" style="' . $price_style . '">' . $price . '</span></div>'; if (in_array("description", $elemets)) { $output .= "\n\t\t" . '<div class="wcmp-product-content" style="' . $desc_style . '">' . $product_desc . '</div>'; } $output .= "\n\t" . '</div>'; $output .= "\n\t" . '</div>'; if (in_array("quick", $elemets)) { $output .= '<div class="wcmp-quick-view-wrapper woocommerce" data-columns="' . $col . '">'; if ($quick_view_style !== "expandable") { $output .= '<div class="wcmp-quick-view-wrapper woocommerce product">'; $output .= '<div class="wcmp-close-single"><i class="wooicon-cross2"></i></div>'; } $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); if ($lazy_images == "enable") { $src = plugins_url('../assets/img/loader.gif', __FILE__); } else { $src = $product_img[0]; } $output .= '<div class="wcmp-single-image wcmp-quickview-img images"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div>'; if ($quick_view_style !== "expandable") { $output .= '<div class="wcmp-product-content-single">'; } else { $output .= '<div class="wcmp-product-content">'; } ob_start(); do_action('woocommerce_single_product_summary'); $output .= ob_get_clean(); $output .= '</div>'; $output .= '<div class="clear"></div>'; if ($quick_view_style !== "expandable") { $output .= '</div>'; } $output .= '</div>'; } $output .= "\n" . '</div>'; if ($element == 'carousel') { $output .= "\n\t" . '</div>'; } } } if ($pagination == "enable") { $output .= '<div class="wcmp-paginate">'; $output .= woocomposer_pagination($query->max_num_pages); $output .= '</div>'; } $output .= '</div>'; if ($display_type == "top_rated_products") { remove_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); } wp_reset_postdata(); return $output; }
/** * Shows the course cost. * * @since 1.0.0 */ function course_cost($atts) { global $coursepress; extract(shortcode_atts(array('course_id' => in_the_loop() ? get_the_ID() : '', 'course' => false, 'label' => __('Price: ', 'cp'), 'label_tag' => 'strong', 'label_delimeter' => ': ', 'no_cost_text' => __('FREE', 'cp'), 'show_icon' => 'false', 'class' => ''), $atts, 'course_cost')); $course_id = (int) $course_id; $label = sanitize_text_field($label); $label_tag = sanitize_html_class($label_tag); $label_delimeter = sanitize_html_class($label_delimeter); $no_cost_text = sanitize_text_field($no_cost_text); $show_icon = sanitize_text_field($show_icon); $class = sanitize_html_class($class); $show_icon = 'true' == $show_icon ? true : false; // Saves some overhead by not loading the post again if we don't need to. $course = empty($course) ? new Course($course_id) : object_decode($course, 'Course'); $is_paid = get_post_meta($course_id, 'paid_course', true) == 'on' ? true : false; $content = ''; if (cp_use_woo()) { if ($is_paid) { $woo_product = get_post_meta($course_id, 'woo_product', true); $wc_product = new WC_Product($woo_product); $content .= $wc_product->get_price_html(); } else { if ($show_icon) { $content .= '<span class="mp_product_price">' . $no_cost_text . '</span>'; } else { $content .= $no_cost_text; } } } else { if ($is_paid && CoursePress::instance()->marketpress_active) { $mp_product = get_post_meta($course_id, 'marketpress_product', true); $content .= do_shortcode('[mp_product_price product_id="' . $mp_product . '" label=""]'); } else { if ($show_icon) { $content .= '<span class="mp_product_price">' . $no_cost_text . '</span>'; } else { $content .= $no_cost_text; } } } if (!empty($content)) { ob_start(); ?> <div class="course-cost course-cost-<?php echo $course_id; ?> <?php echo $class; ?> "> <?php if (!empty($label)) { ?> <<?php echo $label_tag; ?> class="label"><?php echo $label; echo $label_delimeter; ?> </<?php echo $label_tag; ?> ><?php } echo $content; ?> </div> <?php $content = ob_get_clean(); } // Return the html in the buffer. return $content; }
/** * Display a single prodcut price + cart button **/ function woocommerce_product_add_to_cart($atts) { if (empty($atts)) { return; } global $wpdb, $woocommerce; if (!isset($atts['style'])) { $atts['style'] = 'border:4px solid #ccc; padding: 12px;'; } if ($atts['id']) { $product_data = get_post($atts['id']); } elseif ($atts['sku']) { $product_id = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='_sku' AND meta_value='%s' LIMIT 1", $atts['sku'])); $product_data = get_post($product_id); } else { return; } if ($product_data->post_type == 'product') { $product = $woocommerce->setup_product_data($product_data); if (!$product->is_visible()) { continue; } ob_start(); ?> <p class="product" style="<?php echo $atts['style']; ?> "> <?php echo $product->get_price_html(); ?> <?php woocommerce_template_loop_add_to_cart(); ?> </p><?php return ob_get_clean(); } elseif ($product_data->post_type == 'product_variation') { $product = new WC_Product($product_data->post_parent); $GLOBALS['product'] = $product; $variation = new WC_Product_Variation($product_data->ID); if (!$product->is_visible()) { continue; } ob_start(); ?> <p class="product product-variation" style="<?php echo $atts['style']; ?> "> <?php echo $product->get_price_html(); ?> <?php $link = $product->add_to_cart_url(); $label = apply_filters('add_to_cart_text', __('Add to cart', 'woocommerce')); $link = add_query_arg('variation_id', $variation->variation_id, $link); foreach ($variation->variation_data as $key => $data) { if ($data) { $link = add_query_arg($key, $data, $link); } } echo sprintf('<a href="%s" data-product_id="%s" class="button add_to_cart_button product_type_%s">%s</a>', esc_url($link), $product->id, $product->product_type, $label); ?> </p><?php return ob_get_clean(); } }
/** * Returns range style html price string without min and max. * * @param mixed $price default price * @return string overridden html price string (old style) */ public function get_price_html($price = '') { if (!$this->is_synced()) { $this->sync_composite(); } if ($this->is_priced_per_product()) { // Get the price. if ($this->hide_price_html() || $this->min_composite_price === '') { $price = apply_filters('woocommerce_composite_empty_price_html', '', $this); } else { $suppress_range_format = $this->suppress_range_format || apply_filters('woocommerce_composite_force_old_style_price_html', false, $this); if ($suppress_range_format) { $price = wc_price($this->get_composite_price('min', true)); if ($this->min_composite_regular_price > $this->min_composite_price) { $regular_price = wc_price($this->get_composite_regular_price('min', true)); if ($this->min_composite_price !== $this->max_composite_price) { $price = sprintf(_x('%1$s%2$s', 'Price range: from', 'woocommerce-composite-products'), $this->get_price_html_from_text(), $this->get_price_html_from_to($regular_price, $price) . $this->get_price_suffix()); } else { $price = $this->get_price_html_from_to($regular_price, $price) . $this->get_price_suffix(); } $price = apply_filters('woocommerce_composite_sale_price_html', $price, $this); } elseif ($this->min_composite_price === 0 && $this->max_composite_price === 0) { $free_string = apply_filters('woocommerce_composite_show_free_string', false, $this) ? __('Free!', 'woocommerce') : $price; $price = apply_filters('woocommerce_composite_free_price_html', $free_string, $this); } else { if ($this->min_composite_price !== $this->max_composite_price) { $price = sprintf(_x('%1$s%2$s', 'Price range: from', 'woocommerce-composite-products'), $this->get_price_html_from_text(), $price . $this->get_price_suffix()); } else { $price = $price . $this->get_price_suffix(); } $price = apply_filters('woocommerce_composite_price_html', $price, $this); } } else { if ($this->min_composite_price !== $this->max_composite_price) { $price = sprintf(_x('%1$s–%2$s', 'Price range: from-to', 'woocommerce'), wc_price($this->get_composite_price('min', true)), wc_price($this->get_composite_price('max', true))); } else { $price = wc_price($this->get_composite_price('min', true)); } if ($this->min_composite_regular_price > $this->min_composite_price) { if ($this->min_composite_regular_price !== $this->max_composite_regular_price) { $regular_price = sprintf(_x('%1$s–%2$s', 'Price range: from-to', 'woocommerce'), wc_price($this->get_composite_regular_price('min', true)), wc_price($this->get_composite_regular_price('max', true))); } else { $regular_price = wc_price($this->get_composite_regular_price('min', true)); } $price = apply_filters('woocommerce_composite_sale_price_html', $this->get_price_html_from_to($regular_price, $price) . $this->get_price_suffix(), $this); } elseif ($this->min_composite_price === 0 && $this->max_composite_price === 0) { $free_string = apply_filters('woocommerce_composite_show_free_string', false, $this) ? __('Free!', 'woocommerce') : $price; $price = apply_filters('woocommerce_composite_free_price_html', $free_string, $this); } else { $price = apply_filters('woocommerce_composite_price_html', $price . $this->get_price_suffix(), $this); } } } return apply_filters('woocommerce_get_price_html', $price, $this); } else { return parent::get_price_html(); } }
/** * Update content block * * @param array of update value * * @return array of update block */ function update($params = array()) { // Default values $defaults = array('post_id' => false, 'block_id' => false, 'mode' => false, 'properties' => false); // Parse args $params = wp_parse_args($params, $defaults); extract($params, EXTR_SKIP); // Check minimum requirement parameter if (!$post_id || !$block_id || !$mode || !$properties) { return false; } // Get current value $blocks = get_post_meta($post_id, '_wcng_blocks', true); // If blocks 'is' still empty if (!$blocks) { $blocks = array(); } // Update blocks value $allow_args = array('product_id', 'text', 'image', 'link'); $properties = (array) $properties; foreach ($properties as $arg_key => $arg) { if (in_array($arg_key, $allow_args)) { switch ($arg_key) { case 'product_id': $product_id = intval($arg); $product_image_size = $properties['product_image_size']; if ($product_id) { $blocks[$block_id][$mode][$arg_key] = $product_id; // Populate and store the product data $blocks[$block_id][$mode]['title'] = get_the_title($product_id); $blocks[$block_id][$mode]['permalink'] = get_permalink($product_id); // Get the price $wc_product = new WC_Product($product_id); $blocks[$block_id][$mode]['price'] = strip_tags($wc_product->get_price_html()); // Get the thumbnail, if there's any $post_thumbnail_id = get_post_thumbnail_id($product_id); if ($post_thumbnail_id) { $attachment_src = wp_get_attachment_image_src($post_thumbnail_id, $product_image_size); // Check for image existence if (isset($attachment_src[0])) { $image = $attachment_src[0]; } else { $image = WC_NEWSLETTER_GENERATOR_URL . 'assets/default-product-image.png'; } } else { $image = WC_NEWSLETTER_GENERATOR_URL . 'assets/default-product-image.png'; } $blocks[$block_id][$mode]['image'] = $image; } break; default: $blocks[$block_id][$mode][$arg_key] = sanitize_text_field($arg); break; } } } // Save the blocks value update_post_meta($post_id, '_wcng_blocks', $blocks); // Get the updated postmeta $new_blocks = get_post_meta($post_id, '_wcng_blocks', true); return $new_blocks[$block_id][$mode]; }
function woocommerce_products_live_search() { if (isset($_REQUEST['fn']) && 'get_ajax_search' == $_REQUEST['fn']) { $query_args = array('posts_per_page' => 10, 'no_found_rows' => true, 'post_type' => 'product'); if (isset($_REQUEST['terms'])) { $query_args['s'] = $_REQUEST['terms']; } $search_query = new WP_Query($query_args); $results = array(); if ($search_query->get_posts()) { foreach ($search_query->get_posts() as $the_post) { $title = get_the_title($the_post->ID); if (has_post_thumbnail($the_post->ID)) { $post_thumbnail_ID = get_post_thumbnail_id($the_post->ID); $post_thumbnail_src = wp_get_attachment_image_src($post_thumbnail_ID, 'thumbnail'); } else { $dimensions = wc_get_image_size('thumbnail'); $post_thumbnail_src = array(wc_placeholder_img_src(), esc_attr($dimensions['width']), esc_attr($dimensions['height'])); } $product = new WC_Product($the_post->ID); $price = $product->get_price_html(); $brand = woocommerce_show_brand($the_post->ID, true); $title = html_entity_decode($title, ENT_QUOTES, 'UTF-8'); $results[] = array('value' => $title, 'url' => get_permalink($the_post->ID), 'tokens' => explode(' ', $title), 'image' => $post_thumbnail_src[0], 'price' => $price, 'brand' => $brand); } } else { $results[] = __('Sorry. No results match your search.', 'media_center'); } wp_reset_postdata(); echo json_encode($results); } die; }
<?php the_title(sprintf('<h4><a href="%s" rel="bookmark">', esc_url(get_permalink())), '</a></h4>'); ?> <div class="eone-product-content-description"> <?php the_excerpt(); ?> </div><!-- .eone-product-content-description --> </div><!-- .eone-product-content --> <div class="eone-product-price"> <?php $ecom_product = new WC_Product(get_the_ID()); $ecom_price = $ecom_product->get_price_html(); if ($ecom_price) { echo '<p><span>' . $ecom_price . '</span></p>'; } ?> </div><!-- .eone-product-price --> <div class="eone-product-buy"> <span><a href="<?php echo esc_url(get_permalink()); ?> "> <?php if (of_get_option('eone_latest_section_buy_text')) {
function sf_ajaxsearch() { global $sf_options; $page_classes = sf_page_classes(); $header_layout = $page_classes['header-layout']; $header_search_type = $sf_options['header_search_type']; $header_search_pt = $sf_options['header_search_pt']; $remove_dates = $sf_options['remove_dates']; $search_term = trim($_POST['s']); $search_query_args = array('s' => $search_term, 'post_type' => $header_search_pt, 'post_status' => 'publish', 'suppress_filters' => false, 'numberposts' => -1); $search_query_args = http_build_query($search_query_args); $search_results = get_posts($search_query_args); $count = count($search_results); $shown_results = 5; if ($header_layout == "header-vert" || $header_layout == "header-vert-right") { $shown_results = 2; } if ($header_search_type == "fs-search-on") { $shown_results = 20; } $search_results_ouput = ""; if (!empty($search_results)) { $sorted_posts = $post_type = array(); foreach ($search_results as $search_result) { $sorted_posts[$search_result->post_type][] = $search_result; // Check we don't already have this post type in the post_type array if (empty($post_type[$search_result->post_type])) { // Add the post type object to the post_type array $post_type[$search_result->post_type] = get_post_type_object($search_result->post_type); } } $i = 0; foreach ($sorted_posts as $key => $type) { $search_results_ouput .= '<div class="search-result-pt">'; if (isset($post_type[$key]->labels->name)) { $search_results_ouput .= "<h6>" . $post_type[$key]->labels->name . "</h6>"; } else { if (isset($key)) { $search_results_ouput .= "<h6>" . $key . "</h6>"; } else { $search_results_ouput .= "<h6>" . __("Other", "swiftframework") . "</h6>"; } } foreach ($type as $post) { $img_icon = ""; $post_format = get_post_format($post->ID); if ($post_format == "") { $post_format = 'standard'; } $post_type = get_post_type($post); $product = array(); if ($post_type == "product") { $product = new WC_Product($post->ID); if (!$product->is_visible()) { return; } } if ($post_type == "post") { if ($post_format == "quote" || $post_format == "status") { $img_icon = "ss-quote"; } else { if ($post_format == "image") { $img_icon = "ss-picture"; } else { if ($post_format == "chat") { $img_icon = "ss-chat"; } else { if ($post_format == "audio") { $img_icon = "ss-music"; } else { if ($post_format == "video") { $img_icon = "ss-video"; } else { if ($post_format == "link") { $img_icon = "ss-link"; } else { $img_icon = "ss-pen"; } } } } } } } else { if ($post_type == "product") { $img_icon = "ss-cart"; } else { if ($post_type == "portfolio") { $img_icon = "ss-picture"; } else { if ($post_type == "team") { $img_icon = "ss-user"; } else { if ($post_type == "galleries") { $img_icon = "ss-picture"; } else { $img_icon = "ss-file"; } } } } } $post_title = get_the_title($post->ID); $post_date = get_the_date(); $post_permalink = get_permalink($post->ID); $image = get_the_post_thumbnail($post->ID, 'thumbnail'); $search_results_ouput .= '<div class="search-result">'; $search_results_ouput .= '<a href="' . $post_permalink . '" class="search-result-link"></a>'; if ($image) { $search_results_ouput .= '<div class="search-item-img"><a href="' . $post_permalink . '">' . $image . '</div>'; } else { $search_results_ouput .= '<div class="search-item-img"><a href="' . $post_permalink . '" class="img-holder"><i class="' . $img_icon . '"></i></a></div>'; } $search_results_ouput .= '<div class="search-item-content">'; $search_results_ouput .= '<h5><a href="' . $post_permalink . '">' . $post_title . '</a></h5>'; if ($post_type == "product") { $search_results_ouput .= $product->get_price_html(); } else { if (!$remove_dates) { $search_results_ouput .= '<time>' . $post_date . '</time>'; } } $search_results_ouput .= '</div>'; $search_results_ouput .= '</div>'; $i++; if ($i == $shown_results) { break; } } $search_results_ouput .= '</div>'; if ($i == $shown_results) { break; } } if ($count > 1) { $search_link = get_search_link($search_term); if (strpos($search_link, '?') !== false) { $search_link .= '&post_type=' . $header_search_pt; } else { $search_link .= '?post_type=' . $header_search_pt; } $search_results_ouput .= '<a href="' . $search_link . '" class="all-results">' . sprintf(__("View all %d results", "swiftframework"), $count) . '</a>'; } } else { $search_results_ouput .= '<div class="no-search-results">'; $search_results_ouput .= '<h6>' . __("No results", "swiftframework") . '</h6>'; $search_results_ouput .= '<p>' . __("No search results could be found, please try another query.", "swiftframework") . '</p>'; $search_results_ouput .= '</div>'; } echo $search_results_ouput; die; }
function widgets($args, $instance) { $viewed_products = !empty($_COOKIE['woocommerce_recently_viewed']) ? (array) explode('|', $_COOKIE['woocommerce_recently_viewed']) : array(); $viewed_products = array_filter(array_map('absint', $viewed_products)); if (empty($viewed_products)) { return; } ob_start(); extract($args); $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); $number = absint($instance['number']); $query_args = array('posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'post__in' => $viewed_products, 'orderby' => 'rand'); $query_args['meta_query'] = array(); $query_args['meta_query'][] = WC()->query->stock_status_meta_query(); $query_args['meta_query'] = array_filter($query_args['meta_query']); $r = new WP_Query($query_args); if ($r->have_posts()) { echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } echo '<ul class="simple-post-list">'; global $woocommerce; $product = new WC_Product(get_the_ID()); while ($r->have_posts()) { $r->the_post(); $image_tag = get_image(array('width' => 60, 'echo' => false, 'type' => 'src')); echo '<li> <div class="post-image"> <div class="img-thumbnail"> <a href="' . get_permalink() . '"> <img alt="" class="img-responsive" src="' . $image_tag . '"> </a> </div> </div> <div class="post-info"> <a href="' . get_permalink() . '">' . get_the_title() . '</a> <div class="post-meta"> ' . $product->get_price_html() . ' </div> </div> </li>'; } echo '</ul>'; echo $after_widget; } }
?> </a> <h3><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h3> <?php if (!in_array(get_the_ID(), array_map('intval', $product_ids_on_sale))) { ?> <?php if ('' != $product->get_price_html()) { ?> <div class="et-price-button"> <span class="et-price-sale"><?php echo $product->get_price_html(); ?> </span> </div> <?php } ?> <?php } else { ?> <div class="et-price-button et-product-on-sale"> <span class="et-price-before"><del><?php
/** * Get product data. * * @param WC_Product $product Product instance. * @return array */ protected function get_product_data($product) { $data = array('id' => $product->get_id(), 'name' => $product->get_name(), 'slug' => $product->get_slug(), 'permalink' => $product->get_permalink(), 'date_created' => wc_rest_prepare_date_response($product->get_date_created()), 'date_modified' => wc_rest_prepare_date_response($product->get_date_modified()), 'type' => $product->get_type(), 'status' => $product->get_status(), 'featured' => $product->is_featured(), 'catalog_visibility' => $product->get_catalog_visibility(), 'description' => wpautop(do_shortcode($product->get_description())), 'short_description' => apply_filters('woocommerce_short_description', $product->get_short_description()), 'sku' => $product->get_sku(), 'price' => $product->get_price(), 'regular_price' => $product->get_regular_price(), 'sale_price' => $product->get_sale_price() ? $product->get_sale_price() : '', 'date_on_sale_from' => $product->get_date_on_sale_from() ? date('Y-m-d', $product->get_date_on_sale_from()) : '', 'date_on_sale_to' => $product->get_date_on_sale_to() ? date('Y-m-d', $product->get_date_on_sale_to()) : '', 'price_html' => $product->get_price_html(), 'on_sale' => $product->is_on_sale(), 'purchasable' => $product->is_purchasable(), 'total_sales' => $product->get_total_sales(), 'virtual' => $product->is_virtual(), 'downloadable' => $product->is_downloadable(), 'downloads' => $this->get_downloads($product), 'download_limit' => $product->get_download_limit(), 'download_expiry' => $product->get_download_expiry(), 'download_type' => 'standard', 'external_url' => $product->is_type('external') ? $product->get_product_url() : '', 'button_text' => $product->is_type('external') ? $product->get_button_text() : '', 'tax_status' => $product->get_tax_status(), 'tax_class' => $product->get_tax_class(), 'manage_stock' => $product->managing_stock(), 'stock_quantity' => $product->get_stock_quantity(), 'in_stock' => $product->is_in_stock(), 'backorders' => $product->get_backorders(), 'backorders_allowed' => $product->backorders_allowed(), 'backordered' => $product->is_on_backorder(), 'sold_individually' => $product->is_sold_individually(), 'weight' => $product->get_weight(), 'dimensions' => array('length' => $product->get_length(), 'width' => $product->get_width(), 'height' => $product->get_height()), 'shipping_required' => $product->needs_shipping(), 'shipping_taxable' => $product->is_shipping_taxable(), 'shipping_class' => $product->get_shipping_class(), 'shipping_class_id' => $product->get_shipping_class_id(), 'reviews_allowed' => $product->get_reviews_allowed(), 'average_rating' => wc_format_decimal($product->get_average_rating(), 2), 'rating_count' => $product->get_rating_count(), 'related_ids' => array_map('absint', array_values(wc_get_related_products($product->get_id()))), 'upsell_ids' => array_map('absint', $product->get_upsell_ids()), 'cross_sell_ids' => array_map('absint', $product->get_cross_sell_ids()), 'parent_id' => $product->get_parent_id(), 'purchase_note' => wpautop(do_shortcode(wp_kses_post($product->get_purchase_note()))), 'categories' => $this->get_taxonomy_terms($product), 'tags' => $this->get_taxonomy_terms($product, 'tag'), 'images' => $this->get_images($product), 'attributes' => $this->get_attributes($product), 'default_attributes' => $this->get_default_attributes($product), 'variations' => array(), 'grouped_products' => array(), 'menu_order' => $product->get_menu_order()); return $data; }
function woocomposer_list_shortcode($atts) { global $woocommerce; $img_position = $img_size = $img_border = $border_size = $border_radius = $border_color = $title_font = $price_font = $price_color = $rating_color = $rating_font = $shortcode = ''; extract(shortcode_atts(array("img_position" => "", "shortcode" => "", "img_size" => "", "img_border" => "", "border_size" => "", "border_radius" => "", "border_color" => "", "title_color" => "", "title_font" => "", "price_font" => "", "price_color" => "", "rating_color" => "", "rating_font" => ""), $atts)); $output = $on_sale = $style = $title_style = $pricing_style = $rating_style = ''; if ($img_size !== "") { $style .= 'width:' . $img_size . 'px; height:' . $img_size . 'px;'; } if ($title_color !== "") { $title_style .= 'color:' . $title_color . ';'; } if ($title_font !== "") { $title_style .= 'font-size:' . $title_font . 'px;'; } if ($img_border !== '') { $style .= 'border-style:' . $img_border . ';'; if ($border_size !== '') { $style .= 'border-width:' . $border_size . 'px;'; } if ($border_color !== '') { $style .= 'border-color:' . $border_color . ';'; } if ($border_radius !== '') { $style .= 'border-radius:' . $border_radius . 'px;'; } } if ($price_font !== "") { $pricing_style .= 'font-size:' . $price_font . 'px;'; } if ($price_color !== "") { $pricing_style .= 'color:' . $price_color . ';'; } if ($rating_color !== "") { $rating_style .= 'color:' . $rating_color . ';'; } if ($rating_font !== "") { $rating_style .= 'font-size:' . $rating_font . 'px;'; } $post_count = '12'; $output .= '<div class="woocomposer_list woocommerce">'; /* $output .= do_shortcode($content); */ $pattern = get_shortcode_regex(); if ($shortcode !== '') { $new_shortcode = rawurldecode(base64_decode(strip_tags($shortcode))); } preg_match_all("/" . $pattern . "/", $new_shortcode, $matches); $shortcode_str = str_replace('"', '', str_replace(" ", "&", trim($matches[3][0]))); $short_atts = parse_str($shortcode_str); //explode("&",$shortcode_str); if (isset($matches[2][0])) { $display_type = $matches[2][0]; } else { $display_type = ''; } if (!isset($columns)) { $columns = '4'; } if (isset($per_page)) { $post_count = $per_page; } if (isset($number)) { $post_count = $number; } if (!isset($order)) { $order = 'ASC'; } if (!isset($orderby)) { $orderby = 'date'; } if (!isset($category)) { $category = ''; } if (!isset($ids)) { $ids = ''; } if ($ids) { $ids = explode(',', $ids); $ids = array_map('trim', $ids); } if ($columns == "2") { $columns = 6; } elseif ($columns == "3") { $columns = 4; } elseif ($columns == "4") { $columns = 3; } $meta_query = ''; if ($display_type == "recent_products") { $meta_query = WC()->query->get_meta_query(); } if ($display_type == "featured_products") { $meta_query = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes')); } if ($display_type == "top_rated_products") { add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); $meta_query = WC()->query->get_meta_query(); } $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $post_count, 'orderby' => $orderby, 'order' => $order, 'meta_query' => $meta_query); if ($display_type == "sale_products") { $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'] = $meta_query; $args['post__in'] = $product_ids_on_sale; } if ($display_type == "best_selling_products") { $args['meta_key'] = 'total_sales'; $args['orderby'] = 'meta_value_num'; $args['meta_query'] = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')); } if ($display_type == "product_category") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($category)), 'field' => 'slug', 'operator' => 'IN')); } if ($display_type == "product_categories") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => $ids, 'field' => 'term_id', 'operator' => 'IN')); } $query = new WP_Query($args); $output .= '<ul class="wcmp-product-list wcmp-img-' . $img_position . ' ' . $order . '">'; if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $product_id = get_the_ID(); $post = get_post($product_id); $product_title = get_the_title(); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $price = $product->get_price_html(); $rating = $product->get_rating_html(); $product_var = new WC_Product_Variable($product_id); $available_variations = $product_var->get_available_variations(); $output .= '<li>'; $output .= '<a href="' . get_permalink($product_id) . '">'; $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), 'full'); $output .= '<img style="' . $style . '" src="' . $product_img[0] . '"/>'; $output .= '<span style="' . $title_style . '">' . $product_title . '</span>'; $output .= '</a>'; if ($display_type == "top_rated_products") { $output .= '<div style="' . $rating_style . '">' . $rating . '</div>'; } $output .= '<span class="amount" style="' . $pricing_style . '">' . $price . '</span>'; $output .= '</li>'; } } $output .= "\n" . '</ul>'; $output .= "\n" . '</div>'; if ($display_type == "top_rated_products") { remove_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); } wp_reset_postdata(); return $output; }
)"></div> <?php $i++; } elseif ($i == 2) { ?> <div class="col-sm-11 no-padding product-img" style="float:right;margin-right:28px;"> <div class="product-img-inside" style="background:url(<?php echo $image; ?> "></div> <?php } echo "<div class='content col-xs-12 mobile-top-auto mobile-height-auto mobile-bottom-0'>"; echo "<a href='" . get_the_permalink() . "'><h2>" . get_the_title() . "</h2></a>"; echo "<span class='description hidden-xs'>" . get_the_excerpt() . "</span></br>"; echo "<span class='price'>" . $product->get_price_html() . "</span>"; if ($product->is_in_stock()) { ?> <?php do_action('woocommerce_before_add_to_cart_form'); ?> <form class="cart cart-form" method="post" enctype='multipart/form-data'> <?php do_action('woocommerce_before_add_to_cart_button'); ?> <input type="hidden" name="add-to-cart" value="<?php echo esc_attr($product->id); ?>
function wcsCart() { global $woocommerce; $message = ''; if (isset($_POST['remove_coupn']) && $_POST['remove_coupn'] != '') { $coupon_code = $_POST['remove_coupn']; // Coupon is no longer valid, based on date. Remove it. if ($woocommerce->cart->has_discount(sanitize_text_field($coupon_code))) { if ($woocommerce->cart->remove_coupons(sanitize_text_field($coupon_code))) { $woocommerce->clear_messages(); } $message = $coupon_code . " code remove succesfully"; // Manually recalculate totals. If you do not do this, a refresh is required before user will see updated totals when discount is removed. $woocommerce->cart->calculate_totals(); } } if (isset($_POST['add_coupon']) && $_POST['add_coupon'] != '') { $coupon_code = $_POST['add_coupon']; //if ( $woocommerce->cart->has_discount( $coupon_code ) ) return; $woocommerce->cart->add_discount($coupon_code); if ($woocommerce->cart->applied_coupons) { $message = $coupon_code . " code successfully applied"; } else { $message = $coupon_code . " code does not exist"; } $woocommerce->cart->calculate_totals(); } if ($woocommerce->cart) { $items_in_cart = $woocommerce->cart->cart_contents_count; $prod_ids_in_cart = array(); foreach ($woocommerce->cart->get_cart() as $cart_item_key => $cart_item) { $product_id = apply_filters('woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key); array_push($prod_ids_in_cart, $product_id); } $test01 = 0; $test02 = 0; $test03 = 0; $test04 = 0; if (in_array("566", $prod_ids_in_cart)) { $test01 = 1; } if (in_array("568", $prod_ids_in_cart)) { $test02 = 1; } if (in_array("570", $prod_ids_in_cart)) { $test03 = 1; } if (in_array("572", $prod_ids_in_cart)) { $test04 = 1; } $how_many_tests_in_cart = $test01 + $test02 + $test03 + $test04; if (in_array("574", $prod_ids_in_cart)) { foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) { if ($cart_item['product_id'] == 574) { $woocommerce->cart->set_quantity($cart_item_key, 0); } } if ($how_many_tests_in_cart == 0) { } if ($how_many_tests_in_cart == 1) { $woocommerce->cart->add_to_cart('574', '1', '719', '1'); $_product = new WC_Product_Variation(719); $price_urgent = $_product->get_price_html(); } if ($how_many_tests_in_cart == 2) { $woocommerce->cart->add_to_cart('574', '1', '720', '2'); $_product = new WC_Product_Variation(720); $price_urgent = $_product->get_price_html(); } if ($how_many_tests_in_cart == 3) { $woocommerce->cart->add_to_cart('574', '1', '721', '3'); $_product = new WC_Product_Variation(721); $price_urgent = $_product->get_price_html(); } if ($how_many_tests_in_cart == 4) { $woocommerce->cart->add_to_cart('574', '1', '722', '4'); $_product = new WC_Product_Variation(722); $price_urgent = $_product->get_price_html(); } } // end if there is processing in cart /*$product = new WC_Product( $product_id ); if($product_id != '574') { $price = $product->price; }*/ $html = ''; if ($woocommerce->cart->get_cart_contents_count() > 0) { //$html = '<ul class="cart_list product_list_widget">'; foreach ($woocommerce->cart->get_cart() as $cart_item_key => $cart_item) { $product_id = apply_filters('woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key); $product = new WC_Product($product_id); if ($product_id == 574) { $price = $price_urgent; } else { $price = $product->get_price_html(); } $product = new WC_Product($product_id); //$html .='<li class="mini_cart_item" id="product_id_'.$product_id.'"><a href="javascript:void(0);">'.$product->post->post_title.' ( '. $price.') </a> </li>'; $html .= '<tr id="product_id_' . $product_id . '"><td class="item_name">' . $product->post->post_title . '</td><td class="item_price">' . $price . '</td></tr>'; } $html .= '<tr><td class="item_name"><strong>Subtotal:</strong></td><td class="item_price"><span class="amount">' . $woocommerce->cart->get_cart_subtotal() . '</span></td></tr>'; foreach ($woocommerce->cart->get_coupons() as $code => $coupon) { $code_cc = "'{$code}'"; $label = apply_filters('woocommerce_cart_totals_coupon_label', esc_html(__('Coupon:', 'woocommerce') . ' ' . $coupon->code), $coupon); $html .= '<tr class="cart-discount coupon-' . esc_attr(sanitize_title($code)) . '"><th>' . $label . '</th><td class="item_price">' . wc_custom_cart_totals_coupon_html($coupon) . '</td></tr>'; } $html .= '<tr><td class="item_name"><strong>Total:</strong></td><td class="item_price"><span class="amount">' . $woocommerce->cart->get_cart_total() . '</span></td></tr>'; //$html .= '</ul>'; } else { $html .= '<tr><td class="item_name">No product added</td></tr>'; } //$html .= '<p class="total"><strong>Subtotal:</strong> <span class="amount">'.$woocommerce->cart->get_cart_total().'</span></p>'; } // edn of if woocommerce cart //wc_clear_notices(); echo $html . '##' . $woocommerce->cart->get_cart_contents_count() . '##' . wc_print_notices(); die; }
function woocommerce_custom_product_columns($column) { global $post, $woocommerce; $product = new WC_Product($post->ID); switch ($column) { case "thumb": $product->get_image(); break; case "name": $edit_link = get_edit_post_link($post->ID); $title = _draft_or_post_title(); $post_type_object = get_post_type_object($post->post_type); $can_edit_post = current_user_can($post_type_object->cap->edit_post, $post->ID); echo '<strong><a class="row-title" href="' . $edit_link . '">' . $title . '</a>'; _post_states($post); echo '</strong>'; if ($post->post_parent > 0) { echo ' ← <a href="' . get_edit_post_link($post->post_parent) . '">' . get_the_title($post->post_parent) . '</a>'; } // Excerpt view if (isset($_GET['mode']) && $_GET['mode'] == 'excerpt') { echo apply_filters('the_excerpt', $post->post_excerpt); } // Get actions $actions = array(); $actions['id'] = 'ID: ' . $post->ID; if ($can_edit_post && 'trash' != $post->post_status) { $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this item inline', 'woocommerce')) . '">' . __('Quick Edit', 'woocommerce') . '</a>'; } if (current_user_can($post_type_object->cap->delete_post, $post->ID)) { if ('trash' == $post->post_status) { $actions['untrash'] = "<a title='" . esc_attr(__('Restore this item from the Trash', 'woocommerce')) . "' href='" . wp_nonce_url(admin_url(sprintf($post_type_object->_edit_link . '&action=untrash', $post->ID)), 'untrash-' . $post->post_type . '_' . $post->ID) . "'>" . __('Restore', 'woocommerce') . "</a>"; } elseif (EMPTY_TRASH_DAYS) { $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this item to the Trash', 'woocommerce')) . "' href='" . get_delete_post_link($post->ID) . "'>" . __('Trash', 'woocommerce') . "</a>"; } if ('trash' == $post->post_status || !EMPTY_TRASH_DAYS) { $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this item permanently', 'woocommerce')) . "' href='" . get_delete_post_link($post->ID, '', true) . "'>" . __('Delete Permanently', 'woocommerce') . "</a>"; } } if ($post_type_object->public) { if (in_array($post->post_status, array('pending', 'draft'))) { if ($can_edit_post) { $actions['view'] = '<a href="' . esc_url(add_query_arg('preview', 'true', get_permalink($post->ID))) . '" title="' . esc_attr(sprintf(__('Preview “%s”', 'woocommerce'), $title)) . '" rel="permalink">' . __('Preview', 'woocommerce') . '</a>'; } } elseif ('trash' != $post->post_status) { $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View “%s”', 'woocommerce'), $title)) . '" rel="permalink">' . __('View', 'woocommerce') . '</a>'; } } $actions = apply_filters('post_row_actions', $actions, $post); echo '<div class="row-actions">'; $i = 0; $action_count = sizeof($actions); foreach ($actions as $action => $link) { ++$i; $i == $action_count ? $sep = '' : ($sep = ' | '); echo "<span class='{$action}'>{$link}{$sep}</span>"; } echo '</div>'; get_inline_data($post); /* Custom inline data for woocommerce */ echo ' <div class="hidden" id="woocommerce_inline_' . $post->ID . '"> <div class="sku">' . $product->sku . '</div> <div class="regular_price">' . $product->regular_price . '</div> <div class="sale_price">' . $product->sale_price . '</div> <div class="weight">' . $product->weight . '</div> <div class="length">' . $product->length . '</div> <div class="width">' . $product->width . '</div> <div class="height">' . $product->height . '</div> <div class="visibility">' . $product->visibility . '</div> <div class="stock_status">' . $product->stock_status . '</div> <div class="stock">' . $product->stock . '</div> <div class="manage_stock">' . $product->manage_stock . '</div> <div class="featured">' . $product->featured . '</div> <div class="product_type">' . $product->product_type . '</div> <div class="product_is_virtual">' . $product->virtual . '</div> </div> '; break; case "sku": if ($product->get_sku()) { echo $product->get_sku(); } else { echo '<span class="na">–</span>'; } break; case "product_type": if ($product->product_type == 'grouped') { echo '<span class="product-type tips ' . $product->product_type . '" tip="' . __('Grouped', 'woocommerce') . '"></span>'; } elseif ($product->product_type == 'external') { echo '<span class="product-type tips ' . $product->product_type . '" tip="' . __('External/Affiliate', 'woocommerce') . '"></span>'; } elseif ($product->product_type == 'simple') { if ($product->is_virtual()) { echo '<span class="product-type tips virtual" tip="' . __('Virtual', 'woocommerce') . '"></span>'; } elseif ($product->is_downloadable()) { echo '<span class="product-type tips downloadable" tip="' . __('Downloadable', 'woocommerce') . '"></span>'; } else { echo '<span class="product-type tips ' . $product->product_type . '" tip="' . __('Simple', 'woocommerce') . '"></span>'; } } elseif ($product->product_type == 'variable') { echo '<span class="product-type tips ' . $product->product_type . '" tip="' . __('Variable', 'woocommerce') . '"></span>'; } else { // Assuming that we have other types in future echo '<span class="product-type tips ' . $product->product_type . '" tip="' . ucwords($product->product_type) . '"></span>'; } break; case "price": if ($product->get_price_html()) { echo $product->get_price_html(); } else { echo '<span class="na">–</span>'; } break; case "product_cat": if (!($terms = get_the_term_list($post->ID, 'product_cat', '', ', ', ''))) { echo '<span class="na">–</span>'; } else { echo $terms; } break; case "product_tags": if (!($terms = get_the_term_list($post->ID, 'product_tag', '', ', ', ''))) { echo '<span class="na">–</span>'; } else { echo $terms; } break; case "featured": $url = wp_nonce_url(admin_url('admin-ajax.php?action=woocommerce-feature-product&product_id=' . $post->ID), 'woocommerce-feature-product'); echo '<a href="' . $url . '" title="' . __('Change', 'woocommerce') . '">'; if ($product->is_featured()) { echo '<a href="' . $url . '"><img src="' . $woocommerce->plugin_url() . '/assets/images/featured.png" alt="yes" />'; } else { echo '<img src="' . $woocommerce->plugin_url() . '/assets/images/featured-off.png" alt="no" />'; } echo '</a>'; break; case "is_in_stock": if ($product->is_in_stock()) { echo '<mark class="instock">' . __('In stock', 'woocommerce') . '</mark>'; } else { echo '<mark class="outofstock">' . __('Out of stock', 'woocommerce') . '</mark>'; } if ($product->managing_stock()) { echo ' × ' . $product->get_total_stock(); } break; } }
public function wc_ebs_new_price_fragment($fragments) { global $woocommerce, $post, $product; $product = new WC_Product(the_ID()); $product_id = isset($_POST['product_id']) ? $_POST['product_id'] : $product->id; if (isset($_POST['days'])) { ob_start(); echo '<p itemprop="price" class="price">' . $product->get_price_html() . '</p>'; $fragments['p.price'] = ob_get_clean(); } return $fragments; }
/** * Thumbnail HTML creation, base for index and other components * @param [type] $block_data * @param [type] $el_id * @param [type] $style_preset * @param [type] $layout * @param [type] $lightbox_classes * @param [type] $carousel_textual * @param boolean $with_html * @return [type] */ function uncode_create_single_block($block_data, $el_id, $style_preset, $layout, $lightbox_classes, $carousel_textual, $with_html = true) { $image_orig_w = $image_orig_h = $crop = $item_media = $media_code = $media_mime = $create_link = $title_link = $text_content = $media_attributes = $big_image = $lightbox_data = $single_height = $single_title = $nested = $media_poster = $dummy_oembed = $images_size = $single_family = $object_class = $single_back_color = $single_animation = $is_product = $single_icon = $single_text = $single_style = $single_elements_click = $overlay_color = $overlay_opacity = $tmb_data = ''; $media_type = 'image'; $multiple_items = false; if (isset($block_data['classes'])) { $block_classes = $block_data['classes']; } if (isset($block_data['tmb_data'])) { $tmb_data = $block_data['tmb_data']; } if (isset($block_data['media_id'])) { $item_thumb_id = $block_data['media_id']; } if (isset($block_data['images_size'])) { $images_size = $block_data['images_size']; } if (isset($block_data['single_style'])) { $single_style = $block_data['single_style']; } if (isset($block_data['single_text'])) { $single_text = $block_data['single_text']; } if (isset($block_data['single_elements_click'])) { $single_elements_click = $block_data['single_elements_click']; } if (isset($block_data['overlay_color'])) { $overlay_color = $block_data['overlay_color']; } if (isset($block_data['overlay_opacity'])) { $overlay_opacity = (int) $block_data['overlay_opacity'] / 100; } if (isset($block_data['single_width'])) { $single_width = $block_data['single_width']; } if (isset($block_data['single_height'])) { $single_height = $block_data['single_height']; } if (isset($block_data['single_back_color'])) { $single_back_color = $block_data['single_back_color']; } if (isset($block_data['single_title'])) { $single_title = $block_data['single_title']; } if (isset($block_data['single_icon'])) { $single_icon = $block_data['single_icon']; } if (isset($block_data['poster'])) { $media_poster = $block_data['poster']; } if (isset($block_data['title_classes'])) { $title_classes = !$block_data['title_classes'] ? array('h3') : $block_data['title_classes']; } if (isset($block_data['animation'])) { $single_animation = $block_data['animation']; } if (isset($block_data['product']) && $block_data['product'] === true) { $is_product = true; } else { $is_product = false; } if (!isset($block_classes)) { $block_classes = array(); } if (isset($block_data['link'])) { $create_link = is_array($block_data['link']) ? $block_data['link']['url'] : $block_data['link']; $title_link = $create_link; } $a_classes = array(); if (isset($block_data['link_class'])) { $a_classes[] = $block_data['link_class']; } /*** MEDIA SECTION ***/ if (isset($images_size) && $images_size !== '' && $style_preset !== 'metro') { switch ($images_size) { case 'one-one': $single_height = $single_width; break; case 'four-three': $single_height = $single_width / (4 / 3); break; case 'three-two': $single_height = $single_width / (3 / 2); break; case 'sixteen-nine': $single_height = $single_width / (16 / 9); break; case 'twentyone-nine': $single_height = $single_width / (21 / 9); break; case 'three-four': $single_height = $single_width / (3 / 4); break; case 'two-three': $single_height = $single_width / (2 / 3); break; case 'nine-sixteen': $single_height = $single_width / (9 / 16); break; } $block_classes[] = 'tmb-img-ratio'; } if (empty($item_thumb_id) || FALSE === get_post_status($item_thumb_id)) { $item_media = 'https://placeholdit.imgix.net/~text?txtsize=33&txt=media+not+available&w=500&h=500'; $media_attributes = ''; $image_orig_w = 500; $image_orig_h = 500; } else { /** get media info **/ $items_thumb_id = explode(',', $item_thumb_id); if (count($items_thumb_id) > 1) { if ($media_poster) { $media_attributes = uncode_get_media_info($items_thumb_id[0]); $media_metavalues = unserialize($media_attributes->metadata); $media_mime = $media_attributes->post_mime_type; } else { $multiple_items = true; } } else { $media_attributes = uncode_get_media_info($item_thumb_id); if (!isset($media_attributes)) { $media_attributes = new stdClass(); } $media_metavalues = unserialize($media_attributes->metadata); $media_mime = $media_attributes->post_mime_type; } /** check if open to lightbox **/ if ($lightbox_classes) { if (isset($lightbox_classes['data-title']) && $lightbox_classes['data-title'] === true) { $lightbox_classes['data-title'] = $media_attributes->post_title; } if (isset($lightbox_classes['data-caption']) && $lightbox_classes['data-caption'] === true) { $lightbox_classes['data-caption'] = $media_attributes->post_excerpt; } } /** shortcode carousel **/ if ($multiple_items) { $shortcode = '[vc_gallery nested="yes" el_id="gallery-' . rand() . '" medias="' . $item_thumb_id . '" type="carousel" style_preset="' . $style_preset . '" single_padding="0" thumb_size="' . $images_size . '" carousel_lg="1" carousel_md="1" carousel_sm="1" gutter_size="0" media_items="media" carousel_interval="0" carousel_dots="yes" carousel_dots_mobile="yes" carousel_autoh="yes" carousel_type="fade" carousel_nav="no" carousel_nav_mobile="no" carousel_dots_inside="yes" single_text="overlay" single_border="yes" single_width="' . $single_width . '" single_height="' . $single_height . '" single_text_visible="no" single_text_anim="no" single_overlay_visible="no" single_overlay_anim="no" single_image_anim="no"]'; $media_oembed = uncode_get_oembed($item_thumb_id, $shortcode, 'shortcode', false); $media_code = $media_oembed['code']; $media_type = $media_oembed['type']; if (($key = array_search('tmb-overlay-anim', $block_classes)) !== false) { unset($block_classes[$key]); } if (($key = array_search('tmb-overlay-text-anim', $block_classes)) !== false) { unset($block_classes[$key]); } if (($key = array_search('tmb-image-anim', $block_classes)) !== false) { unset($block_classes[$key]); } $image_orig_w = $single_width; $image_orig_h = $single_height; $object_class = 'nested-carousel object-size'; } else { /** This is a self-hosted image **/ if (strpos($media_mime, 'image/') !== false && $media_mime !== 'image/url' && isset($media_metavalues['width']) && isset($media_metavalues['height'])) { $image_orig_w = $media_metavalues['width']; $image_orig_h = $media_metavalues['height']; /** check if open to lightbox **/ if ($lightbox_classes) { $big_image = uncode_resize_image($media_attributes->guid, $media_attributes->path, $image_orig_w, $image_orig_h, 12, null, false); $create_link = $big_image['url']; } /** calculate height ratio if masonry and thumb size **/ if ($style_preset === 'masonry') { if ($images_size !== '') { $crop = true; } else { $crop = false; } } else { $crop = true; } $resized_image = uncode_resize_image($media_attributes->guid, $media_attributes->path, $image_orig_w, $image_orig_h, $single_width, $single_height, $crop); $item_media = esc_attr($resized_image['url']); $image_orig_w = $resized_image['width']; $image_orig_h = $resized_image['height']; } else { if ($media_mime === 'oembed/svg') { $media_type = 'html'; $media_code = $media_attributes->post_content; $media_code = preg_replace('#\\s(id)="([^"]+)"#', ' $1="$2-' . rand() . '"', $media_code); if ($media_mime === 'oembed/svg') { $media_code = preg_replace('#\\s(xmlns)="([^"]+)"#', '', $media_code); $media_code = preg_replace('#\\s(xmlns:svg)="([^"]+)"#', '', $media_code); $media_code = preg_replace('#\\s(xmlns:xlink)="([^"]+)"#', '', $media_code); } /** This is an iframe **/ } else { if ($media_mime === 'oembed/iframe') { $media_type = 'other'; $media_code = $media_attributes->post_content; $image_orig_w = $media_metavalues['width']; $image_orig_h = $media_metavalues['height']; } else { $object_class = 'object-size'; /** external image **/ if ($media_mime === 'image/url') { $item_media = $media_attributes->guid; $image_orig_w = $media_metavalues['width']; $image_orig_h = $media_metavalues['height']; if ($lightbox_classes) { $create_link = $item_media; } } else { $media_oembed = uncode_get_oembed($item_thumb_id, $media_attributes->guid, $media_attributes->post_mime_type, $media_poster, $media_attributes->post_excerpt, $media_attributes->post_content); /** check if is an image oembed **/ if ($media_oembed['type'] === 'image') { $item_media = esc_attr($media_oembed['code']); $image_orig_w = $media_oembed['width']; $image_orig_h = $media_oembed['height']; $media_type = 'image'; if ($lightbox_classes) { $create_link = $media_oembed['code']; } } else { /** check if there is a poster **/ if (isset($media_oembed['poster']) && $media_oembed['poster'] !== '' && $media_poster) { /** calculate height ratio if masonry and thumb size **/ if ($style_preset === 'masonry') { if ($images_size !== '') { $crop = true; } else { $crop = false; } } else { $crop = true; } if (!empty($media_oembed['poster']) && $media_oembed['poster'] !== '') { $poster_attributes = uncode_get_media_info($media_oembed['poster']); $media_metavalues = unserialize($poster_attributes->metadata); $image_orig_w = $media_metavalues['width']; $image_orig_h = $media_metavalues['height']; $resized_image = uncode_resize_image($poster_attributes->guid, $poster_attributes->path, $image_orig_w, $image_orig_h, $single_width, $single_height, $crop); $item_media = esc_attr($resized_image['url']); $image_orig_w = $resized_image['width']; $image_orig_h = $resized_image['height']; $media_type = 'image'; if ($lightbox_classes) { switch ($media_attributes->post_mime_type) { case 'oembed/twitter': case 'oembed/html': $big_image = uncode_resize_image($poster_attributes->guid, $poster_attributes->path, $image_orig_w, $image_orig_h, 12, null, false); $create_link = $big_image['url']; break; default: $create_link = $media_oembed['code']; break; } } } } else { $media_code = $media_oembed['code']; $media_type = $media_oembed['type']; $object_class = $media_oembed['class']; if ($style_preset === 'metro' || $images_size != '') { $image_orig_w = $single_width; $image_orig_h = $single_height; } else { $image_orig_w = $media_oembed['width']; $image_orig_h = $media_oembed['height']; } if (strpos($media_mime, 'audio/') !== false && isset($media_oembed['poster']) && $media_oembed['poster'] !== '') { $poster_attributes = uncode_get_media_info($media_oembed['poster']); $media_metavalues = unserialize($poster_attributes->metadata); $image_orig_w = $media_metavalues['width']; $image_orig_h = $media_metavalues['height']; $resized_image = uncode_resize_image($poster_attributes->guid, $poster_attributes->path, $image_orig_w, $image_orig_h, $single_width, $single_height, $crop); $media_oembed['dummy'] = $image_orig_h / $image_orig_w * 100; } if ($image_orig_h === 0) { $image_orig_h = 1; } if ($media_oembed['dummy'] !== 0 && $style_preset !== 'metro') { $dummy_oembed = ' style="padding-top: ' . $media_oembed['dummy'] . '%"'; } if ($lightbox_classes && $media_type === 'image') { $create_link = $media_oembed['code']; } } } } } } } } } if ($item_media === '' && !isset($media_attributes->guid) && !$multiple_items) { $media_type = 'image'; $item_media = 'http://placehold.it/500&text=media+not+available'; $image_orig_w = 500; $image_orig_h = 500; } if (!$with_html) { return array('code' => $media_type === 'image' ? esc_url($item_media) : $media_code, 'type' => $media_type, 'width' => $image_orig_w, 'height' => $image_orig_h); } $entry = $inner_entry = ''; foreach ($layout as $key => $value) { switch ($key) { case 'icon': if ($single_icon !== '' && $single_text === 'overlay') { $inner_entry .= '<i class="' . $single_icon . ' t-overlay-icon"></i>'; } break; case 'title': $get_title = isset($media_attributes->post_title) ? $media_attributes->post_title : ''; if ($single_text === 'overlay' && $single_elements_click !== 'yes' || isset($media_attributes->team) && $media_attributes->team || $title_link === '#') { $print_title = $single_title ? $single_title : $media_attributes->post_title; if ($print_title !== '') { $inner_entry .= '<h3 class="t-entry-title ' . trim(implode(' ', $title_classes)) . '">' . $print_title . '</h3>'; } } else { $print_title = $single_title ? $single_title : $get_title; if ($print_title !== '') { $inner_entry .= '<h3 class="t-entry-title ' . trim(implode(' ', $title_classes)) . '"><a href="' . $title_link . '">' . $print_title . '</a></h3>'; } } break; case 'type': $inner_entry .= '<p class="t-entry-type"><span>' . ucfirst(get_post_type($block_data['id'])) . '</span></p>'; break; case 'category': case 'meta': if (isset($value[0]) && $value[0] === 'yesbg') { $with_bg = true; } else { $with_bg = false; } $inner_entry .= '<p class="t-entry-meta">'; if (is_sticky()) { $inner_entry .= '<span class="t-entry-category"><i class="fa fa-ribbon fa-push-right"></i>' . esc_html__('Sticky', 'uncode') . '</span>'; } if ($key === 'meta') { $year = get_the_time('Y'); $month = get_the_time('m'); $day = get_the_time('d'); $date = get_the_date('', $block_data['id']); $inner_entry .= '<span class="t-entry-category"><i class="fa fa-clock fa-push-right"></i><a href="' . get_day_link($year, $month, $day) . '">' . $date . '</a></span>'; } $categories_array = isset($block_data['single_categories_id']) ? $block_data['single_categories_id'] : array(); $cat_icon = false; $tag_icon = false; $cat_count = count($categories_array); $cat_counter = 0; foreach ($categories_array as $t_key => $tax) { $category = ''; $add_comma = true; $term_color = get_option('_uncode_taxonomy_' . $tax); $cat_classes = 't-entry-category'; if (isset($term_color['term_color']) && $term_color['term_color'] !== '' && $with_bg) { $term_color = 'text-' . $term_color['term_color'] . '-color'; } else { $term_color = ''; } if (isset($block_data['single_categories'][$t_key])) { $single_cat = $block_data['single_categories'][$t_key]; if (gettype($single_cat) !== 'string' && isset($single_cat['link'])) { $cat_link = $block_data['single_categories'][$t_key]['link']; if ($block_data['single_categories'][$t_key]['tax'] === 'category' && !$cat_icon) { $category .= '<i class="fa fa-archive2 fa-push-right"></i>'; $cat_icon = true; $add_comma = false; } if ($block_data['single_categories'][$t_key]['tax'] === 'post_tag' && !$tag_icon) { $category .= '<i class="fa fa-tag2 fa-push-right"></i>'; $tag_icon = true; $add_comma = false; } } else { $cat_link = $block_data['single_categories'][$t_key]; } $cat_link = str_replace('<a ', '<a class="' . $term_color . '" ', $cat_link); $category .= ($cat_counter !== 0 && $add_comma ? '<span class="cat-comma">,</span>' : '') . $cat_link; $add_comma = true; } else { $category = ''; } $inner_entry .= '<span class="' . $cat_classes . '">' . $category . '</span>'; $cat_counter++; $category = ''; } $inner_entry .= '</p>'; break; case 'date': $date = get_the_date('', $block_data['id']); $inner_entry .= '<p class="t-entry-meta">'; $inner_entry .= '<span class="t-entry-date">' . $date . '</span>'; $inner_entry .= '</p>'; break; case 'text': $post_format = get_post_format(); if (isset($value[0]) && $value[0] === 'full') { $block_text = apply_filters('the_content', ($post_format === 'link' ? '<i class="fa fa-link fa-push-right"></i>' : '') . get_the_content()); $block_text .= wp_link_pages(array('before' => '<div class="page-links">' . esc_html__('Pages:', 'uncode'), 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>', 'echo' => 0)); } else { $block_text = get_post_field('post_excerpt', $block_data['id']); } if (isset($block_data['text_length']) && $block_data['text_length'] !== '') { $block_text = '<p>' . uncode_truncate($block_text, $block_data['text_length']) . '</p>'; } else { if (isset($value[1]) && !empty($value[1])) { $block_text = '<p>' . uncode_truncate($block_text, $value[1]) . '</p>'; } } if ($single_text === 'overlay' && $single_elements_click !== 'yes') { $inner_entry .= '<p class="t-entry-excerpt">' . preg_replace('/<\\/?a(.|\\s)*?>/', '', $block_text) . '</p>'; } else { if (isset($value[0]) && $value[0] === 'full') { $inner_entry .= $block_text; } else { $inner_entry .= '<p class="t-entry-excerpt">' . $block_text . '</p>'; } } break; case 'link': $btn_shape = ' btn-default'; if (isset($value[0]) && $value[0] !== 'default') { if ($value[0] === 'link') { $btn_shape = ' btn-link'; } else { $btn_shape = ' btn-default btn-' . $value[0]; } } if ($single_text === 'overlay' && $single_elements_click !== 'yes') { $inner_entry .= '<p class="t-entry-readmore"><span class="btn' . $btn_shape . '">Read More</span></p>'; } else { $inner_entry .= '<p class="t-entry-readmore"><a href="' . $create_link . '" class="btn' . $btn_shape . '">Read More</a></p>'; } break; case 'author': $author = get_post_field('post_author', $block_data['id']); $author_name = get_the_author_meta('display_name', $author); $author_link = get_author_posts_url($author); $inner_entry .= '<p class="t-entry-author">'; if ($single_text === 'overlay' && $single_elements_click !== 'yes') { $inner_entry .= get_avatar($author, 80) . '<span>' . esc_html__('by ', 'uncode') . $author_name . '</span>'; } else { $inner_entry .= '<a href="' . $author_link . '">' . get_avatar($author, 80) . '<span>' . esc_html__('by ', 'uncode') . $author_name . '</span></a>'; } $inner_entry .= '</p>'; break; case 'extra': $inner_entry .= '<p class="t-entry-comments entry-small"><span class="extras">'; if (function_exists('dot_irecommendthis')) { global $uncode_irecommendthis; if ($single_text === 'under') { $inner_entry .= $uncode_irecommendthis->dot_recommend($block_data['id'], true); } else { if ($single_elements_click === 'yes') { $inner_entry .= $uncode_irecommendthis->dot_recommend($block_data['id'], true); } else { $inner_entry .= $uncode_irecommendthis->dot_recommend($block_data['id'], false); } } } $num_comments = get_comments_number($block_data['id']); $entry_comments = '<i class="fa fa-speech-bubble"></i><span>' . $num_comments . ' ' . _nx('Comment', 'Comments', $num_comments, 'comments', 'uncode') . '</span>'; if ($single_text === 'overlay' && $single_elements_click !== 'yes') { $inner_entry .= '<span class="extras-wrap">' . $entry_comments . '</span>'; } else { $inner_entry .= '<a class="extras-wrap" href="' . get_comments_link($block_data['id']) . '" title="title">' . $entry_comments . '</a>'; } $inner_entry .= '<span class="extras-wrap"><i class="fa fa-watch"></i><span>' . uncode_estimated_reading_time($block_data['id']) . '</span></span></span></p>'; break; case 'price': global $woocommerce; if (class_exists('WooCommerce')) { $product = new WC_Product($block_data['id']); $inner_entry .= '<span class="price ' . trim(implode(' ', $title_classes)) . '">' . $product->get_price_html() . '</span>'; } break; case 'caption': if (isset($media_attributes->post_excerpt) && $media_attributes->post_excerpt !== '') { $inner_entry .= '<p class="t-entry-meta"><span>' . $media_attributes->post_excerpt . '</span></p>'; } break; case 'description': if (isset($media_attributes->post_content) && $media_attributes->post_content !== '') { $inner_entry .= '<p class="t-entry-excerpt">' . $media_attributes->post_content . '</p>'; } break; case 'team-social': if ($media_attributes->team) { $team_socials = explode("\n", $media_attributes->team_social); $inner_entry .= '<p class="t-entry-comments t-entry-member-social"><span class="extras">'; foreach ($team_socials as $key => $value) { if ($value !== '') { $get_host = parse_url($value); $host = str_replace("www.", "", $get_host['host']); $host = explode('.', $host); if ($host[0] === 'plus') { $host[0] = 'google-' . $host[0]; } $inner_entry .= '<a href="' . esc_url($value) . '" target="_blank"><i class="fa fa-' . esc_attr($host[0]) . '"></i></a>'; } } $inner_entry .= '</span></p>'; } break; case 'sep-one': case 'sep-two': $sep_class = isset($value[0]) && $value[0] === 'reduced' ? ' class="separator-reduced"' : ''; $inner_entry .= '<hr' . $sep_class . ' />'; break; } } if (isset($media_attributes->team) && $media_attributes->team) { $single_elements_click = 'yes'; } if (!empty($layout) && !(count($layout) === 1 && array_key_exists('media', $layout)) && $inner_entry !== '') { if ($single_text === 'under') { $entry .= '<div class="t-entry-text"> <div class="t-entry-text-tc ' . $block_data['text_padding'] . '">'; } $entry .= '<div class="t-entry">'; $entry .= $inner_entry; $entry .= '</div>'; if ($single_text === 'under') { $entry .= '</div> </div>'; } } if ($lightbox_classes) { $lightbox_data = ' ' . implode(' ', array_map(function ($v, $k) { return $k . '="' . $v . '"'; }, $lightbox_classes, array_keys($lightbox_classes))); $lightbox_data .= ' data-lbox="ilightbox_' . $el_id . '"'; $video_src = ''; if (isset($media_attributes->post_mime_type) && strpos($media_attributes->post_mime_type, 'video/') !== false) { $video_src .= 'html5video:{preload:\'true\','; $alt_videos = get_post_meta($item_thumb_id, "_uncode_video_alternative", true); if (!empty($alt_videos)) { foreach ($alt_videos as $key => $value) { $exloded_url = explode(".", strtolower($value)); $ext = end($exloded_url); if ($ext !== '') { $video_src .= $ext . ":'" . $value . "',"; } } } $video_src .= '},'; } $lightbox_data .= ' data-options="' . $video_src . 'thumbnail: \'' . $item_media . '\'"'; } $layoutArray = array_keys($layout); foreach ($layoutArray as $key => $value) { if ($value === 'icon') { unset($layoutArray[$key]); } } if (!array_key_exists('media', $layout)) { $block_classes[] = 'tmb-only-text'; $with_media = false; } else { $with_media = true; } if ($single_text === 'overlay') { $block_classes[] = 'tmb-media-first'; $block_classes[] = 'tmb-media-last'; $block_classes[] = 'tmb-content-overlay'; } else { $block_classes[] = 'tmb-content-under'; $layoutLast = (string) array_pop($layoutArray); if (($layoutLast === 'media' || $layoutLast === '') && $with_media) { $block_classes[] = 'tmb-media-last'; } else { $block_classes[] = 'tmb-media-first'; } } $media_alt = isset($media_attributes->alt) ? $media_attributes->alt : ''; if ($single_back_color === '') { $block_classes[] = 'tmb-no-bg'; } else { $single_back_color = ' style-' . $single_back_color . '-bg'; } $output = '<div class="' . implode(' ', $block_classes) . '"> <div class="' . ($nested !== 'yes' ? 't-inside' : '') . $single_back_color . $single_animation . '" ' . implode(' ', array_map(function ($v, $k) { return $k . '="' . $v . '"'; }, $tmb_data, array_keys($tmb_data))) . '>'; if ($single_text === 'under' && $layoutLast === 'media') { $output .= $entry; } if (array_key_exists('media', $layout) || $single_text === 'overlay') { $output .= '<div class="t-entry-visual"> <div class="t-entry-visual-tc"> <div class="t-entry-visual-cont">'; if ($style_preset === 'masonry' && ($images_size !== '' || ($single_text === 'under' || $single_elements_click !== 'yes')) && array_key_exists('media', $layout)) { if ($media_type === 'image' && $image_orig_w != 0 && $image_orig_h != 0) { $dummy_padding = round($image_orig_h / $image_orig_w * 100, 2); $output .= '<div class="dummy" style="padding-top: ' . $dummy_padding . '%;"></div>'; } } if (($single_text === 'under' || $single_elements_click !== 'yes') && $media_type === 'image') { if ($style_preset === 'masonry') { $a_classes[] = 'pushed'; } $data_values = isset($block_data['link']['target']) && !empty($block_data['link']['target']) && is_array($block_data['link']) ? ' target="' . trim($block_data['link']['target']) . '"' : ''; $output .= '<a href="' . ($media_type === 'image' ? $create_link : '') . '"' . (count($a_classes) > 0 ? ' class="' . trim(implode(' ', $a_classes)) . '"' : '') . $lightbox_data . $data_values . '>'; } $output .= '<div class="t-entry-visual-overlay"><div class="t-entry-visual-overlay-in ' . $overlay_color . '" style="opacity: ' . $overlay_opacity . ';"></div></div> <div class="t-overlay-wrap"> <div class="t-overlay-inner"> <div class="t-overlay-content"> <div class="t-overlay-text ' . $block_data['text_padding'] . '">'; if ($single_text === 'overlay') { $output .= $entry; } else { $output .= '<div class="t-entry t-single-line">'; if (array_key_exists('icon', $layout)) { if ($single_icon !== '') { $output .= '<i class="' . $single_icon . ' t-overlay-icon"></i>'; } } $output .= '</div>'; } $output .= '</div> </div> </div> </div>'; if (array_key_exists('media', $layout)) { if ($style_preset === 'metro') { if ($single_elements_click === 'yes' && $media_type === 'image') { $a_classes[] = 't-background-click'; $data_values = !empty($block_data['link']['target']) ? ' target="' . trim($block_data['link']['target']) . '"' : ''; $output .= '<a href="' . ($media_type === 'image' ? $create_link : '') . '"' . (count($a_classes) > 0 ? ' class="' . trim(implode(' ', $a_classes)) . '"' : '') . $lightbox_data . $data_values . '> <div class="t-background-cover" style="background-image:url(\'' . $item_media . '\')"></div> </a>'; } else { if ($media_type === 'image') { $output .= '<div class="t-background-cover" style="background-image:url(\'' . $item_media . '\')"></div>'; } else { $output .= '<div class="fluid-object ' . trim(implode(' ', $title_classes)) . ' ' . $object_class . '"' . $dummy_oembed . '>' . $media_code . '</div>'; } } } else { if ($media_type === 'image') { $output .= '<img src="' . $item_media . '" width="' . $image_orig_w . '" height="' . $image_orig_h . '" alt="' . $media_alt . '" />'; } else { $output .= '<div class="fluid-object ' . trim(implode(' ', $title_classes)) . ' ' . $object_class . '"' . $dummy_oembed . '>' . $media_code . '</div>'; } } } if (($single_text === 'under' || $single_elements_click !== 'yes') && $media_type === 'image') { $output .= '</a>'; } if ($is_product) { $product = wc_get_product($block_data['id']); $product_add_to_cart = sprintf('<a href="%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" class="%s product_type_%s">%s</a>', esc_url($product->add_to_cart_url()), esc_attr($product->id), esc_attr($product->get_sku()), $product->is_purchasable() ? 'add_to_cart_button' : '', esc_attr($product->product_type), esc_html($product->add_to_cart_text())); $output .= '<div class="add-to-cart-overlay">' . $product_add_to_cart . '</div>'; } $output .= '</div> </div> </div>'; } if ($single_text === 'under' && $layoutLast !== 'media') { $output .= $entry; } $output .= '</div> </div>'; return $output; }
function WooComposer_Single_style03($atts) { $product_id = $product_style = $display_elements = $img_animate = $text_align = $color_heading = $color_categories = $color_price = ''; $color_rating = $color_rating_bg = $color_quick_bg = $color_quick = $color_cart_bg = $color_cart = $color_product_desc = ''; $color_product_desc_bg = $size_title = $size_cat = $size_price = $color_on_sale = $color_on_sale_bg = $label_on_sale = $border_style = ''; $border_color = $border_size = $border_radius = $sale_price = $on_sale_alignment = $on_sale_style = $product_img_disp = ''; extract(shortcode_atts(array("product_id" => "", "product_style" => "style01", "display_elements" => "", "label_on_sale" => "Sale!", "text_align" => "left", "img_animate" => "rotate-clock", "color_heading" => "", "color_categories" => "", "color_price" => "", "color_rating" => "", "color_rating_bg" => "", "color_quick_bg" => "", "color_quick" => "", "color_cart_bg" => "", "color_on_sale_bg" => "", "color_on_sale" => "", "color_cart" => "", "color_product_desc" => "", "color_product_desc_bg" => "", "size_title" => "", "size_cat" => "", "size_price" => "", "border_style" => "", "border_color" => "", "border_size" => "", "border_radius" => "", "sale_price" => "", "on_sale_style" => "wcmp-sale-circle", "on_sale_alignment" => "wcmp-sale-right", "product_img_disp" => "single"), $atts)); $output = $heading_style = $cat_style = $price_style = $cart_style = $cart_bg_style = $view_style = $view_bg_style = $rating_style = ''; $desc_style = $label_style = $border = $desc_style = $sale_price_size = ''; $image_size = apply_filters('single_product_large_thumbnail_size', 'shop_single'); if ($sale_price !== '') { $sale_price_size = 'font-size:' . $sale_price . 'px;'; } $img_animate = 'wcmp-img-' . $img_animate; if ($border_style !== '') { $border .= 'border:' . $border_size . 'px ' . $border_style . ' ' . $border_color . ';'; $border .= 'border-radius:' . $border_radius . 'px;'; } if ($color_product_desc_bg !== '') { $desc_style .= 'background:' . $color_product_desc_bg . ';'; } if ($color_product_desc !== '') { $desc_style .= 'color:' . $color_product_desc . ';'; } if ($color_heading !== "") { $heading_style = 'color:' . $color_heading . ';'; } if ($size_title !== "") { $heading_style .= 'font-size:' . $size_title . 'px;'; } if ($color_categories !== "") { $cat_style = 'color:' . $color_categories . ';'; } if ($size_cat !== "") { $cat_style .= 'font-size:' . $size_cat . 'px;'; } if ($color_price !== "") { $price_style = 'color:' . $color_price . ';'; } if ($size_price !== "") { $price_style .= 'font-size:' . $size_price . 'px;'; } if ($color_rating !== "") { $rating_style .= 'color:' . $color_rating . ';'; } if ($color_rating_bg !== "") { $rating_style .= 'background:' . $color_rating_bg . ';'; } if ($color_quick_bg !== "") { $view_bg_style = 'background:' . $color_quick_bg . ';'; } if ($color_quick !== "") { $view_style = 'color:' . $color_quick . ';'; } if ($color_cart_bg !== "") { $cart_bg_style = 'background:' . $color_cart_bg . ';'; } if ($color_cart !== "") { $cart_style = 'color:' . $color_cart . ';'; } if ($color_on_sale_bg !== "") { $label_style = 'background:' . $color_on_sale_bg . ';'; } if ($color_on_sale !== "") { $label_style .= 'color:' . $color_on_sale . ';'; } $elemets = explode(",", $display_elements); $product_title = get_the_title($product_id); $post = get_post($product_id); $product_desc = get_post($product_id)->post_excerpt; $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $price = $product->get_price_html(); $rating = $product->get_rating_html(); $attributes = $product->get_attributes(); $stock = $product->is_in_stock() ? 'InStock' : 'OutOfStock'; if ($product->is_on_sale()) { $on_sale = apply_filters('woocommerce_sale_flash', $label_on_sale, $post, $product); } else { $on_sale = ''; } $cat_count = sizeof(get_the_terms($product_id, 'product_cat')); $tag_count = sizeof(get_the_terms($product_id, 'product_tag')); $categories = $product->get_categories(', ', '<span class="posted_in">' . _n('', '', $cat_count, 'woocommerce') . ' ', '.</span>'); $tags = $product->get_tags(', ', '<span class="tagged_as">' . _n('', '', $tag_count, 'woocommerce') . ' ', '.</span>'); $output .= "\n" . '<div class="wcmp-product woocommerce wcmp-' . $product_style . ' ' . $img_animate . '" style="' . $border . ' ' . $desc_style . '">'; $output .= "\n\t" . '<div class="wcmp-product-image">'; if (!empty($attachment_ids) && count($attachment_ids) > 1 && $product_img_disp == "carousel") { $uniqid = uniqid(); $output .= '<div class="wcmp-single-image-carousel">'; $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); $src = $product_img[0]; $output .= '<div><div class="wcmp-image"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div></div>'; foreach ($attachment_ids as $attachment_id) { $product_img = wp_get_attachment_image_src($attachment_id, $image_size); $output .= '<div><div class="wcmp-image"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div></div>'; } $output .= '</div>'; } else { $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); $src = $product_img[0]; $output .= '<a href="' . get_permalink($product_id) . '"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></a>'; } if ($on_sale !== '') { $output .= "\n" . '<div class="wcmp-onsale ' . $on_sale_alignment . ' ' . $on_sale_style . '"><span class="onsale" style="' . $label_style . ' ' . $sale_price_size . '">' . $on_sale . '</span></div>'; } if ($stock == 'OutOfStock') { $output .= "\n" . '<span class="wcmp-out-stock">' . __('Out Of Stock!', 'woocomposer') . '</span>'; } $output .= '</div>'; $output .= "\n\t" . '<div class="wcmp-product-desc">'; $output .= '<a href="' . get_permalink($product_id) . '">'; $output .= "\n\t\t" . '<h2 style="' . $heading_style . '">' . $product_title . '</h2>'; $output .= '</a>'; if (in_array("category", $elemets)) { $output .= '<h5 style="' . $cat_style . '">'; if ($categories !== '') { $output .= $categories; $output .= $tags; } $output .= '</h5>'; } $output .= "\n\t\t" . '<div class="wcmp-price"><span class="price" style="' . $price_style . '">' . $price . '</span></div>'; $output .= '<div class="wcmp-style3-cart-block">'; /*Class Start wcmp-style3-cart-block*/ $output .= '<div class="wcmp-add-to-cart" style="' . $cart_bg_style . '"><a style="' . $cart_style . '" title="Add to Cart" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-product_id="' . $product_id . '" data-product_sku="" class="button add_to_cart_button product_type_simple">Add to Cart</a></div>'; if (in_array("reviews", $elemets)) { $output .= "\n" . '<div class="wcmp-star-ratings" style="' . $rating_style . '">' . $rating . '</div>'; } if (in_array("quick", $elemets)) { $output .= '<div class="wcmp-quick-view quick-view-single" style="' . $view_bg_style . '"><a style="' . $view_style . '" title="Quick View" href="' . get_permalink($product_id) . '"><i class="wooicon-plus32"></i></a></div>'; } $output .= '</div>'; /*Class End wcmp-style3-cart-block*/ if (in_array("description", $elemets)) { $output .= "\n\t\t" . '<div class="wcmp-product-content" style="' . $desc_style . '">' . $product_desc . '</div>'; } if (in_array("quick", $elemets)) { $query = new WP_Query(array('post_type' => 'product', 'post__in' => array($product_id))); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $output .= '<div class="wcmp-quick-view-wrapper">'; $output .= '<div class="wcmp-quick-view-wrapper woocommerce">'; $output .= '<div class="wcmp-close-single"><i class="wooicon-cross2"></i></div>'; if (!empty($attachment_ids) && count($attachment_ids) > 1) { $uniqid = uniqid(); $output .= '<div class="wcmp-image-carousel wcmp-carousel-' . $uniqid . '" data-class="wcmp-carousel-' . $uniqid . '">'; foreach ($attachment_ids as $attachment_id) { $product_img = wp_get_attachment_image_src($attachment_id, $image_size); $output .= '<div><div class="wcmp-image"><img src="' . $product_img[0] . '"/></div></div>'; } $output .= '</div>'; } else { $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); $output .= '<div class="wcmp-single-image"><img src="' . $product_img[0] . '"/></div>'; } $output .= '<div class="wcmp-product-content-single">'; ob_start(); do_action('woocommerce_single_product_summary'); $output .= ob_get_clean(); $output .= '</div>'; $output .= '<div class="clear"></div>'; $output .= '</div>'; $output .= '</div>'; } } } $output .= "\n\t" . '</div>'; $output .= "\n\t" . '</div>'; return $output; }
echo do_shortcode('[yith_wcwl_add_to_wishlist]'); ?> <?php } ?> </p> </div> <div class="price_col"> <?php if ($product->get_price() != '') { ?> <p><span class="price_count"><?php echo $product->get_price_html(); ?> </span></p> <?php } ?> <?php if (!empty($term_brand_image['brand_image'])) { ?> <div class="aff_tag"> <img src="<?php $params = array('width' => 120, 'height' => 90); echo bfi_thumb($term_brand_image['brand_image'], $params); ?>
function previous_post_link_product() { $product = get_adjacent_post_product(true, '', true); if (empty($product)) { return; } $product_obj = new WC_Product($product->ID); $image = get_the_post_thumbnail($product->ID, apply_filters('single_product_small_thumbnail_size', 'shop_thumbnail')); ?> <div class="prev-product" onclick="window.location='<?php echo get_permalink($product->ID); ?> '"> <div class="hide-info"> <?php echo $image; ?> <div> <span><?php echo $product->post_title; ?> </span> <span class="price"><?php echo $product_obj->get_price_html(); ?> </span> </div> </div> </div> <?php }
/** * Get standard product data that applies to every product type * * @since 2.1 * @param WC_Product $product * @return WC_Product */ private function get_product_data($product) { return array('title' => $product->get_title(), 'id' => (int) $product->is_type('variation') ? $product->get_variation_id() : $product->id, 'created_at' => $this->server->format_datetime($product->get_post_data()->post_date_gmt), 'updated_at' => $this->server->format_datetime($product->get_post_data()->post_modified_gmt), 'type' => $product->product_type, 'status' => $product->get_post_data()->post_status, 'downloadable' => $product->is_downloadable(), 'virtual' => $product->is_virtual(), 'permalink' => $product->get_permalink(), 'sku' => $product->get_sku(), 'price' => $product->get_price(), 'regular_price' => $product->get_regular_price(), 'sale_price' => $product->get_sale_price() ? $product->get_sale_price() : null, 'price_html' => $product->get_price_html(), 'taxable' => $product->is_taxable(), 'tax_status' => $product->get_tax_status(), 'tax_class' => $product->get_tax_class(), 'managing_stock' => $product->managing_stock(), 'stock_quantity' => $product->get_stock_quantity(), 'in_stock' => $product->is_in_stock(), 'backorders_allowed' => $product->backorders_allowed(), 'backordered' => $product->is_on_backorder(), 'sold_individually' => $product->is_sold_individually(), 'purchaseable' => $product->is_purchasable(), 'featured' => $product->is_featured(), 'visible' => $product->is_visible(), 'catalog_visibility' => $product->visibility, 'on_sale' => $product->is_on_sale(), 'product_url' => $product->is_type('external') ? $product->get_product_url() : '', 'button_text' => $product->is_type('external') ? $product->get_button_text() : '', 'weight' => $product->get_weight() ? $product->get_weight() : null, 'dimensions' => array('length' => $product->length, 'width' => $product->width, 'height' => $product->height, 'unit' => get_option('woocommerce_dimension_unit')), 'shipping_required' => $product->needs_shipping(), 'shipping_taxable' => $product->is_shipping_taxable(), 'shipping_class' => $product->get_shipping_class(), 'shipping_class_id' => 0 !== $product->get_shipping_class_id() ? $product->get_shipping_class_id() : null, 'description' => wpautop(do_shortcode($product->get_post_data()->post_content)), 'short_description' => apply_filters('woocommerce_short_description', $product->get_post_data()->post_excerpt), 'reviews_allowed' => 'open' === $product->get_post_data()->comment_status, 'average_rating' => wc_format_decimal($product->get_average_rating(), 2), 'rating_count' => (int) $product->get_rating_count(), 'related_ids' => array_map('absint', array_values($product->get_related())), 'upsell_ids' => array_map('absint', $product->get_upsells()), 'cross_sell_ids' => array_map('absint', $product->get_cross_sells()), 'parent_id' => $product->post->post_parent, 'categories' => wp_get_post_terms($product->id, 'product_cat', array('fields' => 'names')), 'tags' => wp_get_post_terms($product->id, 'product_tag', array('fields' => 'names')), 'images' => $this->get_images($product), 'featured_src' => (string) wp_get_attachment_url(get_post_thumbnail_id($product->is_type('variation') ? $product->variation_id : $product->id)), 'attributes' => $this->get_attributes($product), 'downloads' => $this->get_downloads($product), 'download_limit' => (int) $product->download_limit, 'download_expiry' => (int) $product->download_expiry, 'download_type' => $product->download_type, 'purchase_note' => wpautop(do_shortcode(wp_kses_post($product->purchase_note))), 'total_sales' => metadata_exists('post', $product->id, 'total_sales') ? (int) get_post_meta($product->id, 'total_sales', true) : 0, 'variations' => array(), 'parent' => array(), 'grouped_products' => array()); }
function wp_ajax_query($atts = '') { include_once ABSPATH . 'wp-admin/includes/plugin.php'; global $waq_id; $is_ajax = 0; if ($atts == '') { $is_ajax = 1; $atts = $_GET; if ($atts['global_query']) { unset($atts['no_found_rows']); unset($atts['suppress_filters']); unset($atts['cache_results']); unset($atts['update_post_term_cache']); unset($atts['update_post_meta_cache']); unset($atts['nopaging']); } } if ($atts['post_excerpt_limit'] > 0) { add_filter('excerpt_length', 'waq_custom_excerpt_length', 999); } if ($atts['multisite']) { switch_to_blog($atts['multisite']); } foreach ($atts as $key => $val) { if ($atts[$key] == null || $atts[$key] == 'null' || $atts[$key] == '') { unset($atts[$key]); } } $my_query = null; $my_query = new WP_Query($atts); $html = ''; if ($my_query->have_posts()) { ob_start(); if ($atts['layout'] == 'classic') { echo '<div>'; } //fix firefox append while ($my_query->have_posts()) { $my_query->the_post(); if ($atts['post_type'] == 'attachment') { $thumb = wp_get_attachment_image_src(get_the_ID(), $atts['thumb_size']); $full = wp_get_attachment_image_src(get_the_ID(), 'large'); } else { $thumb = wp_get_attachment_image_src(get_post_thumbnail_id(), $atts['thumb_size']); $full = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large'); } ?> <div class="ajax-item"> <div class="ajax-item-pad"> <?php if (has_post_thumbnail() || $atts['post_type'] == 'attachment') { if ($atts['thumb_hover_popup']) { ?> <a rel="prettyPhoto[waq<?php echo $atts['waq_id']; ?> ]" href="<?php echo $full['0']; ?> " title="<?php the_title(); ?> "> <?php } else { ?> <a href="<?php echo get_permalink(); ?> " title="<?php the_title(); ?> "> <?php } ?> <div class="ajax-item-thumb"> <img src="<?php echo $thumb['0']; ?> " title="<?php the_title(); ?> " alt="<?php the_title(); ?> " width="<?php echo $atts['col_width']; ?> " /> <?php if ($atts['thumb_hover_icon']) { ?> <div class="link-overlay fa <?php echo $atts['thumb_hover_icon']; ?> "></div> <?php } ?> </div> </a> <?php } ?> <div class="ajax-item-content-wrap <?php echo has_post_thumbnail() ? '' : 'no-thumb'; ?> "> <?php if ($atts['post_title_size']) { ?> <h2 class="ajax-item-head"> <a href="<?php echo get_permalink(); ?> " title="<?php the_title(); ?> "> <?php the_title(); ?> </a> </h2> <br /> <?php } ?> <?php if ($atts['post_meta_size']) { ?> <div class="ajax-item-meta"> <?php if (is_plugin_active('woocommerce/woocommerce.php') && $atts['post_type'] == 'product') { //woo product $product = new WC_Product(get_the_ID()); ?> <span><?php echo $product->get_price_html(); ?> <a href="<?php echo do_shortcode('[add_to_cart_url id="' . get_the_ID() . '"]'); ?> " title="<?php _e('Add to cart', 'leafcolor'); ?> "><i class="fa fa-shopping-cart"></i>+</a></span> <?php } else { ?> <span><i class="fa fa-clock-o"></i> <?php the_time(get_option('date_format')); ?> <i class="fa fa-user"></i> <?php the_author_link(); ?> </span> <?php } ?> </div> <br /> <?php } ?> <?php if ($atts['post_excerpt_size']) { ?> <div class="ajax-item-content"> <?php if ($atts['full_post'] == 1) { the_content(); } elseif ($atts['fullpost'] == -1) { echo ''; } else { the_excerpt(); } ?> </div> <?php } ?> </div> <div class="clear"></div> </div> </div> <?php } wp_reset_postdata(); if ($atts['layout'] == 'classic') { echo '</div>'; } //fix firefox append $html = ob_get_clean(); if ($is_ajax == 1) { echo $html; exit; } remove_filter('excerpt_length', 'waq_custom_excerpt_length'); return $html; } else { if ($is_ajax == 1) { echo '-11'; exit; } remove_filter('excerpt_length', 'waq_custom_excerpt_length'); return 'No post'; } if ($atts['multisite']) { restore_current_blog(); } }