/** * Returns classic grid element for a given product * * @param object $post Product post object * @param string $archive_template * @return string */ function get_grid_archive_theme($post, $archive_template = null) { $archive_template = isset($archive_template) ? $archive_template : get_product_listing_template(); $return = ''; if ($archive_template == 'grid') { $image_id = get_post_thumbnail_id($post->ID); $thumbnail_product = wp_get_attachment_image_src($image_id, 'classic-grid-listing'); $product_name = get_product_name(); if ($thumbnail_product) { $img_class['alt'] = $product_name; $img_class['class'] = 'classic-grid-image'; $image = wp_get_attachment_image($image_id, 'classic-grid-listing', false, $img_class); } else { $url = default_product_thumbnail_url(); $image = '<img src="' . $url . '" class="classic-grid-image" alt="' . $product_name . '" >'; } $archive_price = apply_filters('archive_price_filter', '', $post); $classic_grid_settings = get_classic_grid_settings(); $row_class = get_row_class($classic_grid_settings); $return = '<div class="archive-listing product-' . $post->ID . ' classic-grid ' . $row_class . ' ' . product_class($post->ID) . '">'; $return .= '<a href="' . get_permalink() . '">'; //$return .= '<div style="background-image:url(\'' . $url . '\');" class="classic-grid-element"></div>'; $return .= '<div class="classic-grid-image-wrapper"><div class="pseudo"></div><div class="image">' . $image . '</div></div>'; $return .= '<h3 class="product-name">' . $product_name . '</h3>' . $archive_price . '</a></div>'; } return $return; }
/** * Returns modern grid element for a given product * * @param object $post Product post object * @param string $archive_template * @return string */ function get_default_archive_theme($post, $archive_template = null) { $archive_template = isset($archive_template) ? $archive_template : get_product_listing_template(); $return = ''; if ($archive_template == 'default') { $archive_price = apply_filters('archive_price_filter', '', $post); $modern_grid_settings = get_modern_grid_settings(); $thumbnail_product = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'modern-grid-listing'); $img_class = ''; if ($thumbnail_product) { $url = $thumbnail_product[0]; if (!empty($thumbnail_product[2])) { $ratio = $thumbnail_product[1] / $thumbnail_product[2]; if ($ratio <= 1.35 && $ratio > 1.2) { $img_class = ' class="higher"'; } else { if ($ratio <= 1.15) { $img_class = ' class="higher rect"'; } else { if ($ratio > 2) { $img_class = ' class="wider rect"'; } } } } } else { $url = default_product_thumbnail_url(); } $product_name = get_the_title(); $return = '<div class="al_archive product-' . $post->ID . ' modern-grid-element ' . design_schemes('box', 0) . ' ' . product_listing_size_class($thumbnail_product) . ' ' . product_class($post->ID) . '">'; $return .= '<div class="pseudo"></div>'; $return .= '<a href="' . get_permalink() . '"><img' . $img_class . ' src="' . $url . '" alt="' . $product_name . '">'; $return .= '<h3 class="product-name ' . design_schemes('box', 0) . '">' . $product_name . '</h3>'; if ($modern_grid_settings['attributes'] == 1) { $attributes_number = product_attributes_number(); $at_val = ''; $any_attribute_value = ''; for ($i = 1; $i <= $attributes_number; $i++) { $at_val = get_post_meta($post->ID, "_attribute" . $i, true); if (!empty($at_val)) { $any_attribute_value = $at_val . $i; } } if ($attributes_number > 0 && !empty($any_attribute_value)) { $return .= '<div class="product-attributes"><table class="attributes-table">'; for ($i = 1; $i <= $attributes_number; $i++) { $attribute_value = get_post_meta($post->ID, "_attribute" . $i, true); if (!empty($attribute_value)) { $return .= '<tr><td>' . get_post_meta($post->ID, "_attribute-label" . $i, true) . '</td><td>' . get_post_meta($post->ID, "_attribute" . $i, true) . ' ' . get_post_meta($post->ID, "_attribute-unit" . $i, true) . '</td></tr>'; } } $return .= '</table></div>'; } } $return .= $archive_price . '</a></div>'; } return $return; }
/** * Returns modern grid element for a given product * * @param object $post Product post object * @param string $archive_template * @return string */ function get_default_archive_theme($post, $archive_template = null) { $archive_template = isset($archive_template) ? $archive_template : get_product_listing_template(); $return = ''; if ($archive_template == 'default') { $product_id = $post->ID; $archive_price = apply_filters('archive_price_filter', '', $post); $modern_grid_settings = get_modern_grid_settings(); $image_id = get_post_thumbnail_id($product_id); $thumbnail_product = wp_get_attachment_image_src($image_id, 'modern-grid-listing'); $product_name = get_the_title(); if ($thumbnail_product) { $url = $thumbnail_product[0]; $img_class['alt'] = $product_name; $img_class['class'] = "modern-grid-image"; if (!empty($thumbnail_product[2])) { $ratio = $thumbnail_product[1] / $thumbnail_product[2]; if ($ratio <= 1.35 && $ratio > 1.2) { $img_class['class'] .= " higher"; } else { if ($ratio <= 1.15) { $img_class['class'] .= " higher rect"; } else { if ($ratio > 2) { $img_class['class'] .= " wider rect"; } } } } $image = wp_get_attachment_image($image_id, 'modern-grid-listing', false, $img_class); } else { $url = default_product_thumbnail_url(); $image = '<img class="modern-grid-image" src="' . $url . '" alt="' . $product_name . '">'; } $return = '<div class="al_archive product-' . $product_id . ' modern-grid-element ' . design_schemes('box', 0) . ' ' . product_listing_size_class($thumbnail_product) . ' ' . product_class($product_id) . '">'; $return .= '<div class="pseudo"></div>'; $return .= '<a href="' . get_permalink($product_id) . '">' . $image; $return .= '<h3 class="product-name ' . design_schemes('box', 0) . '">' . $product_name . '</h3>'; if ($modern_grid_settings['attributes'] == 1) { $attributes_number = product_attributes_number(); if ($attributes_number > 0 && has_product_any_attributes($product_id)) { $return .= '<div class="product-attributes"><table class="attributes-table">'; for ($i = 1; $i <= $attributes_number; $i++) { $attribute_value = get_attribute_value($i, $product_id); if (!empty($attribute_value)) { $return .= '<tr><td class="attribute-label-listing">' . get_attribute_label($i, $product_id) . '</td><td><span class="attribute-value-listing">' . get_attribute_value($i, $product_id) . '</span> <span class="attribute-unit-listing">' . get_attribute_unit($i, $product_id) . '</span></td></tr>'; } } $return .= '</table></div>'; } } $return .= $archive_price . '</a></div>'; } return $return; }
function get_list_archive_theme($post, $archive_template = null) { $archive_template = isset($archive_template) ? $archive_template : get_product_listing_template(); $return = ''; if ($archive_template == 'list') { if (wp_get_attachment_url(get_post_thumbnail_id($post->ID))) { $url = wp_get_attachment_url(get_post_thumbnail_id($post->ID)); } else { $url = default_product_thumbnail_url(); } $return = '<div class="archive-listing list example">'; $return .= '<a href="' . get_permalink() . '"><span class="div-link"></span></a>'; $return .= '<div class="product-image" style="background-image:url(\'' . $url . '\')"></div>'; $return .= '<div class="product-name">' . get_the_title() . '</div>'; $return .= '<div class="product-short-descr"><p>' . c_list_desc($post->ID) . '</p></div></div>'; } return $return; }
function get_list_archive_theme($post, $archive_template = null) { $archive_template = isset($archive_template) ? $archive_template : get_product_listing_template(); $return = ''; if ($archive_template == 'list') { $thumbnail_product = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'classic-list-listing'); if ($thumbnail_product) { $url = $thumbnail_product[0]; } else { $url = default_product_thumbnail_url(); } $product_name = get_product_name(); $return = '<div class="archive-listing product-' . $post->ID . ' list ' . product_class($post->ID) . '">'; $return .= '<a href="' . get_permalink() . '"><span class="div-link"></span></a>'; $return .= '<div class="classic-list-image-wrapper"><div class="pseudo"></div><img src="' . $url . '" class="classic-list-image" alt="' . $product_name . '" ></div>'; $return .= '<div class="product-name">' . $product_name . '</div>'; $return .= '<div class="product-short-descr"><p>' . c_list_desc($post->ID) . '</p></div></div>'; } return $return; }
function classic_grid_additional_styling($styles) { $archive_template = get_product_listing_template(); if ($archive_template == 'grid') { $grid_settings = get_classic_grid_settings(); if ($grid_settings['entries'] != 3) { $width = number_format(100 / $grid_settings['entries']) - 3; $styles .= '.classic-grid.archive-listing{width:' . $width . '%;}'; } } return $styles; }
/** * Returns realted products * * @global object $post * @param int $products_limit * @param boolean $markup * @return string */ function get_related_products($products_limit = null, $markup = false) { if (!isset($products_limit)) { $products_limit = get_current_per_row(); } $current_product_id = get_the_ID(); $taxonomy = get_current_screen_tax(); $post_type = get_current_screen_post_type(); $terms = get_the_terms($current_product_id, $taxonomy); if (is_array($terms) && !empty($taxonomy) && !empty($post_type)) { $terms = array_reverse($terms); $archive_template = get_product_listing_template(); $i = 0; $inside = ''; $products = array(); foreach ($terms as $term) { $query_param = array('post_type' => $post_type, 'tax_query' => array(array('taxonomy' => $taxonomy, 'field' => 'slug', 'terms' => $term->slug)), 'posts_per_page' => $products_limit); $query = new WP_Query($query_param); while ($query->have_posts()) { $query->the_post(); global $post; if ($current_product_id != $post->ID) { $i++; $products[] = $post->ID; } if ($i >= $products_limit) { break; } } wp_reset_postdata(); reset_row_class(); if ($i >= $products_limit) { break; } } $div = ''; if (!empty($products)) { $products = implode(',', $products); if ($markup) { $div = '<div class="related-products">'; $single_names = get_single_names(); if (!empty($single_names['other_categories'])) { $div .= '<h2 class="catalog-header">' . $single_names['other_categories'] . '</h2>'; } $div .= do_shortcode('[show_products product="' . $products . '"]'); $div .= '</div>'; } else { $div = do_shortcode('[show_products product="' . $products . '"]'); } } return $div; } return; }
function archive_custom_design() { $tab = $_GET['tab']; $submenu = $_GET['submenu']; if ($submenu == 'archive-design') { ?> <script> jQuery( '.settings-submenu a' ).removeClass( 'current' ); jQuery( '.settings-submenu a#archive-design' ).addClass( 'current' ); </script> <form method="post" action="options.php"> <?php settings_fields('product_design'); $archive_template = get_product_listing_template(); $modern_grid_settings = get_modern_grid_settings(); $default_classic_grid_settings = array('entries' => 3); $classic_grid_settings = get_option('classic_grid_settings', $default_classic_grid_settings); ?> <h2><?php _e('Design Settings', 'ecommerce-product-catalog'); ?> </h2> <h3><?php _e('Product Listing', 'ecommerce-product-catalog'); ?> </h3> <table class="design-table"> <thead></thead> <tbody> <tr id="default-theme"> <td class="with-additional-styling theme-name"> <input type="radio" name="archive_template" value="default"<?php checked('default' == $archive_template); ?> ><?php _e('Modern Grid', 'ecommerce-product-catalog'); ?> </td> <td rowspan="2" class="theme-example"><?php example_default_archive_theme(); ?> </td> </tr> <tr><td class="additional-styling"><strong><?php _e('Additional Settings', 'ecommerce-product-catalog'); ?> </strong><br><input title="<?php _e('Use this only with short attributes labels and values e.g. Color: Red', 'ecommerce-product-catalog'); ?> " type="checkbox" name="modern_grid_settings[attributes]" value="1"<?php checked(1, isset($modern_grid_settings['attributes']) ? $modern_grid_settings['attributes'] : ''); ?> ><?php _e('Show Attributes', 'ecommerce-product-catalog'); ?> <br><?php _e('Per row', 'ecommerce-product-catalog'); ?> : <input type="number" min="1" max="5" step="1" class="number_box" name="modern_grid_settings[per-row]" value="<?php echo $modern_grid_settings['per-row']; ?> "><?php _e('products', 'ecommerce-product-catalog'); ?> </td></tr> <tr><td colspan="2" class="separator"></td></tr> <tr id="list-theme"> <td class="with-additional-styling theme-name"><input type="radio" name="archive_template" value="list"<?php checked('list' == $archive_template); ?> ><?php _e('Classic List', 'ecommerce-product-catalog'); ?> </td> <td class="theme-example"><?php example_list_archive_theme(); ?> </td> </tr> <tr><td colspan="2" class="separator"></td></tr> <tr id="grid-theme"> <td class="with-additional-styling theme-name"> <input type="radio" name="archive_template" value="grid"<?php checked('grid' == $archive_template); ?> ><?php _e('Classic Grid', 'ecommerce-product-catalog'); ?> </td> <td rowspan="2" class="theme-example"><?php example_grid_archive_theme(); ?> </td> </tr> <tr> <td class="additional-styling"><strong><?php _e('Additional Settings', 'ecommerce-product-catalog'); ?> </strong><br><?php _e('Per row', 'ecommerce-product-catalog'); ?> : <input type="number" min="1" step="1" class="number_box" title="<?php _e('The product listing element width will adjust accordingly to your theme content width.', 'ecommerce-product-catalog'); ?> " name="classic_grid_settings[entries]" value="<?php echo $classic_grid_settings['entries']; ?> "><?php _e('products', 'ecommerce-product-catalog'); ?> </td> </tr> <tr><td colspan="2" class="separator"></td></tr> <?php do_action('product_listing_theme_settings', $archive_template); ?> </tbody> </table> <p class="submit"> <input type="submit" class="button-primary" value="<?php _e('Save changes', 'ecommerce-product-catalog'); ?> " /> </p> </form> <?php } }
/** * Shows categories on product listing for custom templates usage * * @return string */ function ic_product_listing_categories_shortcode() { ob_start(); $multiple_settings = get_multiple_settings(); $archive_template = get_product_listing_template(); ic_product_listing_categories($archive_template, $multiple_settings); return ob_get_clean(); }
/** * Returns per row setting for current product listing theme * @return int */ function get_current_per_row() { $archive_template = get_product_listing_template(); $per_row = 3; if ($archive_template == 'default') { $settings = get_modern_grid_settings(); $per_row = $settings['per-row']; } else { if ($archive_template == 'grid') { $settings = get_classic_grid_settings(); $per_row = $settings['entries']; } } return apply_filters('current_per_row', $per_row, $archive_template); }
/** * Adds per row class to modern grid product listing container * * @param string $class * @return string */ function add_modern_lising_class($class) { $archive_template = get_product_listing_template(); if ($archive_template == 'default') { $settings = get_modern_grid_settings(); $class .= 'per-row-' . $settings['per-row']; } return $class; }
function show_parent_product_categories($echo = 1, $return = '') { $multiple_settings = get_multiple_settings(); $taxonomy_name = apply_filters('current_product_catalog_taxonomy', 'al_product-cat'); $archive_template = get_product_listing_template(); if ($multiple_settings['product_listing_cats'] == 'on') { if ($multiple_settings['cat_template'] != 'template') { $product_subcategories = wp_list_categories('show_option_none=No_cat&echo=0&title_li=&taxonomy=' . $taxonomy_name . '&parent=0'); if (!strpos($product_subcategories, 'No_cat')) { $return = '<div class="product-subcategories">' . $product_subcategories . '</div>'; } } else { $show_categories = do_shortcode('[show_categories parent="0"]'); if (!empty($show_categories)) { $return = '<div class="product-subcategories ' . $archive_template . '">' . $show_categories; if ($archive_template != 'list') { $return .= '<hr>'; } $return .= '</div>'; } } } return echo_ic_setting($return, $echo); }
// Exit if accessed directly } /** * The template for displaying products archive content. * * @version 1.1.3 * @package ecommerce-product-catalog/templates * @author Norbert Dreszer */ global $post; $default_archive_names = default_archive_names(); $multiple_settings = get_multiple_settings(); $archive_names = get_archive_names(); do_action('product_listing_begin', $multiple_settings); $listing_class = apply_filters('product_listing_classes', 'al_product responsive type-page'); ?> <article id="product_listing" <?php post_class($listing_class); ?> > <?php do_action('before_product_listing_entry', $post, $archive_names); ?> <div class="entry-content"> <?php $archive_template = get_product_listing_template(); do_action('product_listing_entry_inside', $archive_template, $multiple_settings); ?> </div> </article><?php do_action('product_listing_end', $archive_template, $multiple_settings);
/** * Shows categories on product listing for custom templates usage * * @return string */ function ic_product_listing_categories() { ob_start(); $multiple_settings = get_multiple_settings(); $archive_template = get_product_listing_template(); $taxonomy_name = apply_filters('current_product_catalog_taxonomy', 'al_product-cat'); if (!is_tax() && !is_search()) { $before_archive = content_product_adder_archive_before(); if ($before_archive != '<div class="entry-summary"></div>') { echo $before_archive; } if ($multiple_settings['product_listing_cats'] == 'on' || $multiple_settings['product_listing_cats'] == 'cats_only') { if ($multiple_settings['cat_template'] != 'template') { $product_subcategories = wp_list_categories('show_option_none = No_cat&echo = 0&title_li = &taxonomy = ' . $taxonomy_name . '&parent = 0'); if (!strpos($product_subcategories, 'No_cat')) { do_action('before_product_listing_category_list'); echo '<div class = "product-subcategories">' . $product_subcategories . '</div>'; } } else { $show_categories = do_shortcode('[show_categories parent = "0" shortcode_query = "no"]'); if (!empty($show_categories)) { do_action('before_product_listing_category_list'); echo $show_categories; if ($archive_template != 'list' && !is_ic_only_main_cats()) { echo '<hr>'; } } } } } else { if (is_tax()) { $term = get_queried_object()->term_id; if (is_ic_category_image_enabled()) { $term_img = get_product_category_image_id($term); echo wp_get_attachment_image($term_img, apply_filters('product_cat_image_size', 'large'), false, array('class' => 'product-category-image')); } $term_description = term_description(); if (!empty($term_description)) { echo '<div class = "taxonomy-description">' . $term_description . '</div>'; } if ($multiple_settings['category_top_cats'] == 'on' || $multiple_settings['category_top_cats'] == 'only_subcategories') { if ($multiple_settings['cat_template'] != 'template') { $product_subcategories = wp_list_categories('show_option_none = No_cat&echo = 0&title_li = &taxonomy = ' . $taxonomy_name . '&child_of = ' . $term); if (!strpos($product_subcategories, 'No_cat')) { ?> <div class="product-subcategories"> <?php do_action('before_category_subcategories'); echo $product_subcategories; ?> </div> <?php } } else { $show_categories = do_shortcode('[show_categories parent = ' . get_queried_object_id() . ' shortcode_query = no]'); if (!empty($show_categories)) { do_action('before_category_subcategories'); echo $show_categories; if ($archive_template != 'list' && !is_ic_only_main_cats()) { echo '<hr>'; } } } } } } return ob_get_clean(); }