/** * Shows product SKU value * * @param type $atts * @return string */ function ic_product_sku_table($atts) { $args = shortcode_atts(array('product' => get_the_ID()), $atts); $single_names = get_single_names(); return get_product_sku_table($args['product'], $single_names); }
/** * 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; }
/** * Returns related categories table * * @param int $product_id * @param array $v_single_names * @param string $taxonomy_name * @return string */ function get_related_categories($product_id, $v_single_names = null, $taxonomy_name = 'al_product-cat') { $single_names = isset($v_single_names) ? $v_single_names : get_single_names(); $terms = wp_get_post_terms($product_id, $taxonomy_name, array("fields" => "ids")); if (empty($terms) || is_wp_error($terms) || get_integration_type() == 'simple') { return; } $term = $terms[0]; $categories = wp_list_categories('title_li=&taxonomy=' . $taxonomy_name . '&include=' . $term . '&echo=0&hierarchical=0'); $table = ''; if ($categories != '<li class="cat-item-none">No categories</li>') { $table .= '<div id="product_subcategories" class="product-subcategories">'; $table .= '<table>'; $table .= '<tr>'; $table .= '<td>'; $table .= $single_names['other_categories']; $table .= '</td>'; $table .= '<td>'; $table .= $categories; $table .= '</td>'; $table .= '</tr>'; $table .= '</table>'; $table .= '</div>'; return $table; } return; }
<?php if (!defined('ABSPATH')) { exit; // Exit if accessed directly } /** * The template to display product attributes on product page or with a shortcode * * Copy it to your theme implecode folder to edit the output: your-theme-folder-name/implecode/product-attributes.php * * @version 1.1.2 * @package ecommerce-product-catalog/templates/template-parts/product-page * @author Norbert Dreszer */ $single_names = get_single_names(); $product_id = ic_get_product_id(); $attributes_number = product_attributes_number(); $table = ''; if ($attributes_number > 0 && has_product_any_attributes($product_id)) { ?> <div id="product_features" class="product-features"> <h3><?php echo $single_names['product_features']; ?> </h3> <table class="features-table"><?php for ($i = 1; $i <= $attributes_number; $i++) { $attribute_value = get_attribute_value($i, $product_id); if (!empty($attribute_value)) { ?>
function custom_names_content() { ?> <div class="names-product-settings settings-wrapper"> <?php $tab = $_GET['tab']; $submenu = $_GET['submenu']; ?> <div class="settings-submenu"> <h3> <a id="single-names" class="element current" href="<?php echo admin_url('edit.php?post_type=al_product&page=product-settings.php&tab=names-settings&submenu=single-names'); ?> "><?php _e('Single Product', 'ecommerce-product-catalog'); ?> </a> <a id="archive-names" class="element" href="<?php echo admin_url('edit.php?post_type=al_product&page=product-settings.php&tab=names-settings&submenu=archive-names'); ?> "><?php _e('Product Listings', 'ecommerce-product-catalog'); ?> </a> </h3> </div><?php if ($submenu == 'single-names') { ?> <div id="single_names" class="setting-content submenu"> <script> jQuery( '.settings-submenu a' ).removeClass( 'current' ); jQuery( '.settings-submenu a#single-names' ).addClass( 'current' ); </script> <form method="post" action="options.php"> <?php settings_fields('product_names_single'); $single_names = get_single_names(); ?> <h2><?php _e('Front-end Labels', 'ecommerce-product-catalog'); ?> </h2> <h3><?php _e('Single Product Labels', 'ecommerce-product-catalog'); ?> </h3> <table class="wp-list-table widefat product-settings-table" style="clear:right; text-align: left;"> <thead><th><strong><?php _e('Front-end Element', 'ecommerce-product-catalog'); ?> </strong></th><th><strong><?php _e('Front-end Text', 'ecommerce-product-catalog'); ?> </strong></th></thead> <tbody> <tr><td><?php _e('Price Label', 'ecommerce-product-catalog'); ?> </td><td><input type="text" name="single_names[product_price]" value="<?php echo esc_html($single_names['product_price']); ?> " /></td></tr> <tr><td><?php _e('Free Product Text', 'ecommerce-product-catalog'); ?> </td><td><input type="text" name="single_names[free]" value="<?php echo esc_html($single_names['free']); ?> " /></td></tr> <tr><td><?php _e('SKU Label', 'ecommerce-product-catalog'); ?> </td><td><input type="text" name="single_names[product_sku]" value="<?php echo esc_html($single_names['product_sku']); ?> " /></td></tr> <tr><td><?php _e('Shipping Label', 'ecommerce-product-catalog'); ?> </td><td><input type="text" name="single_names[product_shipping]" value="<?php echo esc_html($single_names['product_shipping']); ?> " /></td></tr> <tr><td><?php _e('Features Label', 'ecommerce-product-catalog'); ?> </td><td><input type="text" name="single_names[product_features]" value="<?php echo esc_html($single_names['product_features']); ?> " /></td></tr> <tr><td><?php _e('Another Categories', 'ecommerce-product-catalog'); ?> </td><td><input type="text" name="single_names[other_categories]" value="<?php echo esc_html($single_names['other_categories']); ?> " /></td></tr> <tr><td><?php _e('Return to Products', 'ecommerce-product-catalog'); ?> </td><td><input type="text" name="single_names[return_to_archive]" value="<?php echo esc_html($single_names['return_to_archive']); ?> " /></td></tr> <?php do_action('single_names_table', $single_names); ?> </tbody> </table> <p class="submit"> <input type="submit" class="button-primary" value="<?php _e('Save changes', 'ecommerce-product-catalog'); ?> " /> </p> </form> </div> <div class="helpers"><div class="wrapper"><?php main_helper(); ?> </div></div><?php } else { if ($submenu == 'archive-names') { ?> <div id="archive_names" class="setting-content submenu"> <script> jQuery( '.settings-submenu a' ).removeClass( 'current' ); jQuery( '.settings-submenu a#archive-names' ).addClass( 'current' ); </script> <form method="post" action="options.php"><?php settings_fields('product_names_archive'); $archive_names = get_archive_names(); ?> <h2><?php _e('Front-end Labels', 'ecommerce-product-catalog'); ?> </h2><?php $disabled = ''; if (get_integration_type() == 'simple') { $disabled = 'disabled'; if (is_integration_mode_selected()) { implecode_warning(sprintf(__('Product listing pages are disabled with simple theme integration. See <a href="%s">Theme Integration Guide</a> to enable product listing pages.', 'ecommerce-product-catalog'), 'https://implecode.com/wordpress/product-catalog/theme-integration-guide/#cam=simple-mode&key=front-labels')); } else { implecode_warning(sprintf(__('Product listing pages are disabled due to a lack of theme integration.%s', 'ecommerce-product-catalog'), sample_product_button('p'))); } } ?> <h3><?php _e('Product Listing Labels', 'ecommerce-product-catalog'); ?> </h3> <table class="wp-list-table widefat product-settings-table" style="clear:right; text-align: left; width: 100%;"> <style>.names-product-settings .setting-content th {text-align: left;}</style> <thead><th><strong><?php _e('Front-end Element', 'ecommerce-product-catalog'); ?> </strong></th><th style="width:69%"><strong><?php _e('Front-end Text', 'ecommerce-product-catalog'); ?> </strong></th></thead> <tbody> <?php implecode_settings_text(__('Product Archive Title', 'ecommerce-product-catalog'), 'archive_names[all_products]', $archive_names['all_products'], null, 1, 'wide', null, $disabled); implecode_settings_text(__('Categories Header', 'ecommerce-product-catalog'), 'archive_names[all_main_categories]', $archive_names['all_main_categories'], null, 1, 'wide', null, $disabled); implecode_settings_text(__('Subcategories Header', 'ecommerce-product-catalog'), 'archive_names[all_subcategories]', $archive_names['all_subcategories'], null, 1, 'wide', null, $disabled); implecode_settings_text(__('Category Prefix', 'ecommerce-product-catalog'), 'archive_names[all_prefix]', $archive_names['all_prefix'], null, 1, 'wide', null, $disabled); implecode_settings_text(__('Category Products Header', 'ecommerce-product-catalog'), 'archive_names[category_products]', $archive_names['category_products'], null, 1, 'wide', null, $disabled); implecode_settings_text(__('Next Page Link', 'ecommerce-product-catalog'), 'archive_names[next_products]', $archive_names['next_products'], null, 1, 'wide', null, $disabled); implecode_settings_text(__('Previous Page Link', 'ecommerce-product-catalog'), 'archive_names[previous_products]', $archive_names['previous_products'], null, 1, 'wide', null, $disabled); ?> </tbody> </table> <p class="submit"> <input type="submit" <?php echo $disabled; ?> class="button-primary" value="<?php _e('Save changes', 'ecommerce-product-catalog'); ?> " /> </p> </form> </div> <div class="helpers"><div class="wrapper"><?php main_helper(); ?> </div></div><?php } } do_action('names-settings'); ?> </div><?php }
/** * Returns back to products URL * * @param array $v_single_names * @return string */ function get_back_to_products_url($v_single_names = null) { if (is_ic_product_listing_enabled()) { $single_names = isset($v_single_names) ? $v_single_names : get_single_names(); $listing_url = product_listing_url(); if (!empty($listing_url)) { $url = '<a class="back-to-products" href="' . product_listing_url() . '">' . $single_names['return_to_archive'] . '</a>'; return $url; } } return; }
function ecommerce_product_catalog_upgrade() { if (is_admin()) { $plugin_data = get_plugin_data(AL_PLUGIN_MAIN_FILE); $plugin_version = $plugin_data["Version"]; $database_plugin_version = get_option('ecommerce_product_catalog_ver', $plugin_version); if ($database_plugin_version != $plugin_version) { update_option('ecommerce_product_catalog_ver', $plugin_version); $first_version = (string) get_option('first_activation_version', $plugin_version); if (version_compare($first_version, '1.9.0') < 0 && version_compare($database_plugin_version, '2.2.4') < 0) { $hide_info = 0; enable_advanced_mode($hide_info); } if (version_compare($first_version, '2.0.0') < 0 && version_compare($database_plugin_version, '2.2.4') < 0) { $archive_multiple_settings = get_multiple_settings(); $archive_multiple_settings['product_listing_cats'] = 'off'; $archive_multiple_settings['cat_template'] = 'link'; update_option('archive_multiple_settings', $archive_multiple_settings); } if (version_compare($first_version, '2.0.1') < 0 && version_compare($database_plugin_version, '2.2.4') < 0) { add_product_caps(); } if (version_compare($first_version, '2.0.4') < 0 && version_compare($database_plugin_version, '2.2.4') < 0) { delete_transient('implecode_extensions_data'); } if (version_compare($first_version, '2.2.5') < 0 && version_compare($database_plugin_version, '2.2.5') < 0) { $archive_names = get_option('archive_names'); $archive_names['all_main_categories'] = ''; $archive_names['all_products'] = ''; $archive_names['all_subcategories'] = ''; update_option('archive_names', $archive_names); } if (version_compare($first_version, '2.3.6') < 0 && version_compare($database_plugin_version, '2.3.6') < 0) { $archive_multiple_settings = get_multiple_settings(); $archive_multiple_settings['default_sidebar'] = 1; update_option('archive_multiple_settings', $archive_multiple_settings); } if (version_compare($first_version, '2.4.0') < 0 && version_compare($database_plugin_version, '2.4.0') < 0) { $archive_multiple_settings = get_multiple_settings(); $archive_multiple_settings['related'] = 'categories'; update_option('archive_multiple_settings', $archive_multiple_settings); update_option('old_sort_bar', 1); } if (version_compare($first_version, '2.4.15') < 0 && version_compare($database_plugin_version, '2.4.15') < 0) { save_default_multiple_settings(); } if (version_compare($first_version, '2.4.16') < 0 && version_compare($database_plugin_version, '2.4.16') < 0) { $single_names = get_single_names(); $single_names['free'] = ''; update_option('single_names', $single_names); ic_save_global('single_names', $single_names); } flush_rewrite_rules(); } } }