function sv_remove_product_page_skus($enabled) { if (!is_admin() && is_product()) { return false; } return $enabled; }
/** * Get the post id to use to display a header * For example, if a header is set for the blog, we will use it for the archive and search page * * @return int $id */ function wolf_get_header_post_id() { if (is_404() || is_page_template('page-templates/home.php')) { return; } $post_id = null; $shop_page_id = wolf_get_woocommerce_shop_page_id(); $is_shop_page = function_exists('is_shop') ? is_shop() : false; $is_product_taxonomy = function_exists('is_product_taxonomy') ? is_product_taxonomy() : false; $is_single_product = function_exists('is_product') ? is_product() : false; // is blog if (get_option('page_for_posts') && wolf_is_blog() && false == $is_shop_page && false == $is_product_taxonomy) { $post_id = get_option('page_for_posts'); // if woocommerce } elseif ($is_shop_page || $is_product_taxonomy) { $post_id = $shop_page_id; // is single product } elseif ($is_single_product) { if (get_post_meta(get_the_ID(), '_header_bg_img', true) || get_post_meta(get_the_ID(), '_header_bg_color', true)) { $post_id = get_the_ID(); } else { $post_id = $shop_page_id; } } else { $post_id = get_the_ID(); } return $post_id; }
/** * Display the simulator. * * @return string Simulator HTML. */ public static function simulator() { global $product; if (!is_product() || !self::$activated) { return; } if ($product->needs_shipping() && $product->is_in_stock() && in_array($product->product_type, array('simple', 'variable'))) { $options = get_option('woocommerce_correios_settings'); if ('variable' == $product->product_type) { $style = 'display: none'; $ids = array(); foreach ($product->get_available_variations() as $variation) { $_variation = get_product($variation['variation_id']); $ids[] = $_variation->needs_shipping() ? $_variation->variation_id : ''; } $ids = implode(',', array_filter($ids)); } else { $style = ''; $ids = $product->id; } if (isset($options['display_date']) && 'yes' == $options['display_date']) { $title = __('Shipping and delivery time', 'woocommerce-correios'); $description = __('Calculate the shipping and delivery time estimated to your region.', 'woocommerce-correios'); } else { $title = __('Shipping', 'woocommerce-correios'); $description = __('Calculate shipping estimated to your region.', 'woocommerce-correios'); } woocommerce_get_template('single-product/correios-simulator.php', array('product' => $product, 'style' => $style, 'ids' => $ids, 'title' => $title, 'description' => $description), '', WC_Correios::get_templates_path()); } }
function init() { if (!is_product()) { add_action('wp_footer', array($this, 'print_footer_scrips'), 99); add_filter('woocommerce_product_gallery_attachment_ids', array($this, 'add_featured_image_to_thumbnails')); } }
function jbst_layout() { global $jbst_layout; global $jbstecommerce; global $post; if ($jbst_layout) { return; } /* get the page layout */ $jbst_layout = jbst_default_page_layout; if (is_singular(array('page', 'post'))) { if (!($jbst_layout = get_post_meta($post->ID, '_cmb_page_layout', true))) { $jbst_layout = of_get_option('default_page_layout', jbst_default_page_layout); } } else { if (is_page() || is_home()) { $jbst_layout = of_get_option('default_page_layout', jbst_default_page_layout); } elseif (is_search()) { $jbst_layout = of_get_option('default_search_layout', jbst_default_page_layout); } elseif (is_archive()) { $jbst_layout = of_get_option('default_archive_layout', jbst_default_page_layout); } else { $jbst_layout = of_get_option('default_blog_layout', jbst_default_page_layout); } if ($jbstecommerce == true) { if (is_shop()) { $jbst_layout = of_get_option('default_shop_layout', jbst_default_page_layout); } if (is_product()) { $jbst_layout = of_get_option('default_product_layout', jbst_default_page_layout); } } } }
public function process_request() { global $post; $postID = $post->ID; if (is_product() && isset($_GET['wsd_share'])) { switch ($_GET['wsd_share']) { case 'facebook': $fb_url = $this->http() . '://www.facebook.com/sharer.php?u=' . rawurlencode(get_permalink($postID)) . '&t=' . rawurlencode($post->post_title); // Redirect to Facebook wp_redirect($fb_url); die; break; case 'twitter': $post_title = html_entity_decode(wp_kses($post->post_title, null)); $post_link = get_permalink($postID); $text = $post_title; $url = $post_link; $twitter_url = add_query_arg(urlencode_deep(array_filter(compact('text', 'url'))), 'https://twitter.com/intent/tweet'); // Redirect to Twitter wp_redirect($twitter_url); die; break; } } }
/** * Adds JS code to footer on product pages * to swap width and length price calculator field rows * * This will print on any product, therefore it'd be best * to add some checks to ensure it prints on MPC products * with width and length needed fields (Area LxW measurement) */ function sv_wc_swap_mpc_rows() { // bail if we're not on a product page if (!(function_exists('is_product') && is_product())) { return; } wc_enqueue_js(' var $price_calculator = $( "#price_calculator" ); if ( $price_calculator ) { var $length_needed = $price_calculator.find( "label[for=length_needed]" ), $width_needed = $price_calculator.find( "label[for=width_needed]" ); if ( $length_needed && $width_needed ) { $length_tr = $length_needed.closest( "tr" ); $width_tr = $width_needed.closest( "tr" ); $width_tr.after( $length_tr ); } } '); }
function m_wedding_post_classes($classes) { if (function_exists('is_woocommerce') && is_woocommerce() && !is_product()) { $classes[] = 'animated fadeInUp'; } return $classes; }
/** * Enqueue CSS and custom styles. * @since 1.0.0 * @return string CSS */ public function set_styles($is_product_archive, $is_checkout_process) { //Shop css and hooks $this->shop(); //Messages css $this->messages(); if (is_product()) { //It's product page! $this->its_product(); } else { if ($is_product_archive) { wp_localize_script('etp-script', 'sfpSettings', array('shopLayout' => $this->get('wc-shop-layout'), 'mobStore' => $this->get('wc-mob-store'), 'infiniteScroll' => $this->get('wc-infinite-scroll'))); //It's a product archive maybe a shop $this->its_product_archive(); } else { if ($is_checkout_process) { //Enable distraction free checkout if set $this->distraction_free_checkout(); $hide_breadcrumbs = $this->get('hide-wc-breadcrumbs-checkout'); $this->remove_breadcrumbs($hide_breadcrumbs); } else { //It's checkout process page $this->its_non_woocommerce_page(); } } } return $this->css; }
/** * Should Display 360 or Not * * @package WooCommerce 360° Image * @author Captain Theme <*****@*****.**> * @since 1.0.1 */ public function display_bool() { /* * We only want to do the following on the front-end, so rule out if it's in the admin or not */ if (!is_admin()) { // Vars for Gallery Images global $post; $product = get_product($post); // Only do this for products if ($product) { $attachment_ids = $product->get_gallery_attachment_ids(); if (is_product() && get_post_meta(get_the_ID(), 'wc360_enable', true) && $attachment_ids) { $bool = true; } else { $bool = false; } } else { $bool = false; } } else { $bool = false; } return $bool; }
/** * Init theme config for shop. * */ function dt_woocommerce_init_template_config($name = '') { dt_woocommerce_add_config_actions(); if ('shop' != $name) { return; } $config = presscore_get_config(); $post_id = null; if (is_shop()) { $post_id = woocommerce_get_page_id('shop'); } else { if (is_cart()) { $post_id = woocommerce_get_page_id('cart'); } else { if (is_checkout()) { $post_id = woocommerce_get_page_id('checkout'); } } } presscore_config_base_init($post_id); if (is_product_category() || is_product_tag()) { $post_id = woocommerce_get_page_id('shop'); if ($post_id) { $config->set('post_id', $post_id); presscore_config_populate_sidebar_and_footer_options(); $config->set('post_id', null); } } if (!is_product()) { add_filter('presscore_get_page_title', 'dt_woocommerce_get_page_title', 20); } // replace theme breadcrumbs add_filter('presscore_get_breadcrumbs-html', 'dt_woocommerce_replace_theme_breadcrumbs', 20, 2); }
/** * Loading functionality to user to get WooCommerce Total Sales information of the specific product. * * @return void */ public function awts_display_total_sales($price = '', $product = '') { $only_backend = get_option('woo_total_sales_single_product_only_be'); $only_single_product = get_option('woo_total_sales_single_product_only_fe'); //check if visibile only on backend if (isset($only_backend) && $only_backend == 'yes') { if (!is_admin()) { return $price; } } //check if visibile only on single product page if (isset($only_single_product) && $only_single_product == 'yes') { if (!is_product() && !is_admin()) { return $price; } } //From admin setting $singular = get_option('woo_total_sales_singular'); $plural = get_option('woo_total_sales_plural'); $items_sold = $this->awts_get_total_sales_per_product($product->id); $items_sold = isset($items_sold) ? absint($items_sold->_qty) : 0; $price_texts = ''; $price_texts .= $price; if ($items_sold != 0) { $price_texts .= '<div class="items-sold" ><span class="items-sold-texts" >'; $price_texts .= sprintf(esc_html(_n(!empty($singular) ? $singular : '%d item sold', !empty($plural) ? $plural : '%d items sold', $items_sold, 'woo-total-sales')), $items_sold); $price_texts .= '</span></div>'; } return $price_texts; }
/** * enqueue_checkout_script. */ public function enqueue_scripts() { if (!is_product()) { return; } wp_enqueue_script('wcj-product-input-fields'); }
function tesseract_woocommerce_wrapper_start() { $layout_loop = get_theme_mod('tesseract_woocommerce_loop_layout'); $layout_product = get_theme_mod('tesseract_woocommerce_product_layout'); if (is_shop() || is_product_category() || is_product_tag()) { if ($layout_loop == 'sidebar-left' || $layout_loop == 'sidebar-right') { $primclass = 'with-sidebar'; $primclass .= $layout_loop == 'sidebar-left' ? ' sidebar-left' : ' sidebar-right'; } else { if ($layout_loop == 'fullwidth' || !$layout_loop) { $primclass = 'no-sidebar'; } } } else { if (is_product()) { if ($layout_product == 'sidebar-left' || $layout_product == 'sidebar-right') { $primclass = 'with-sidebar'; $primclass .= $layout_product == 'sidebar-left' ? ' sidebar-left' : ' sidebar-right'; } else { if ($layout_product == 'fullwidth' || !$layout_product) { $primclass = 'no-sidebar'; } } } else { $primclass = 'sidebar-default'; } } echo '<div id="primary" class="content-area ' . $primclass . '">'; }
/** * Check if this is an embedded product - to make sure we don't mess up regular posts. * * @since 2.4.11 * @return bool */ public static function is_embedded_product() { if (function_exists('is_embed') && is_embed() && is_product()) { return true; } return false; }
function siw_remove_unnecessary_scripts() { //variatie als radiobuttons if (!is_product()) { wp_dequeue_script('kt-wc-add-to-cart-variation-radio'); } //woocommerce ajax filter if (!is_shop() && !is_product_category() && !is_product_tag()) { wp_dequeue_script('yith-wcan-script'); wp_dequeue_style('yith-wcan-frontend'); } //woocommerce wp_dequeue_script('woocommerce'); //wp-embed wp_deregister_script('wp-embed'); //search&filter wp_dequeue_style('search-filter-chosen-styles'); wp_dequeue_style('search-filter-plugin-styles'); wp_deregister_script('search-filter-chosen-script'); wp_deregister_script('jquery-ui-datepicker'); wp_deregister_script('search-filter-plugin-build'); wp_register_script('search-filter-plugin-build', plugins_url('search-filter-pro/public/assets/js/search-filter-build.min.js'), array('jquery'), '', TRUE); //kadence slider wordt alleen gebruikt op de homepage. if (!is_front_page()) { wp_dequeue_script('kadence_slider_js'); wp_dequeue_style('kadence_slider_css'); } //ncf font wp_dequeue_style('ncf_lato_font'); //styling van mailpoet widget wp_deregister_style('validate-engine-css'); }
/** * Body classes filter. * * @param array $classes * @return array */ function dt_woocommerce_body_class($classes) { if (is_product() && 'disabled' !== presscore_get_config()->get('header_title')) { $classes[] = 'hide-product-title'; } return $classes; }
function rd_after_container() { $post_sidebar = ''; if (is_product()) { if (get_field('product_sidebar')) { $post_sidebar = get_field('product_sidebar'); } if ($post_sidebar == 'sidebar_default' || empty($post_sidebar)) { $post_sidebar = rd_options('reedwan_woo_product_sidebar_position'); } } elseif (is_shop()) { $pageID = get_option('woocommerce_shop_page_id'); if (get_field('page_sidebar', $pageID)) { $post_sidebar = get_field('page_sidebar', $pageID); } if ($post_sidebar == 'sidebar_default' || empty($post_sidebar)) { $post_sidebar = rd_options('reedwan_woo_archive_sidebar_position'); } } elseif (is_product_category() || is_product_tag()) { $post_sidebar = rd_options('reedwan_woo_archive_sidebar_position'); } else { $post_sidebar = 'sidebar_none'; } echo '</div>'; if ($post_sidebar != 'sidebar_none') { echo '<div class="sidebar grid_3">'; if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('woo-sidebar')) { } echo '</div>'; } echo '</div></div></div>'; }
function meso_close_jigoshop_content_wrappers() { if (is_product()) { echo '</div>'; } echo '</div></div>'; }
public function wcva_register_my_scripts() { global $post, $product; if (!$post) { return; } $displaytypenumber = 0; $product = get_product($post->ID); if (is_product()) { $displaytypenumber = wcva_return_displaytype_number($product, $post); } wp_register_style('wcva-frontend', wcva_PLUGIN_URL . 'css/front-end.css'); $goahead = 1; if (isset($_SERVER['HTTP_USER_AGENT'])) { $agent = $_SERVER['HTTP_USER_AGENT']; } if (preg_match('/(?i)msie [5-8]/', $agent)) { $goahead = 0; } if ($displaytypenumber > 0 && $goahead == 1) { wp_deregister_script('wc-add-to-cart-variation'); wp_dequeue_script('wc-add-to-cart-variation'); wp_register_script('wc-add-to-cart-variation', wcva_PLUGIN_URL . 'js/manage-variation-selection.js', array('jquery'), false, true); } if (is_product()) { if ($displaytypenumber > 0 && $goahead == 1) { wp_enqueue_script('wc-add-to-cart-variation'); } wp_enqueue_style('wcva-frontend'); } }
function flatsome_admin_bar_helper() { global $wp_admin_bar; $optionUrl = get_admin_url() . 'themes.php?page=optionsframework'; $adminUrl = get_admin_url(); if (is_category() || is_home()) { $wp_admin_bar->add_menu(array('parent' => false, 'id' => 'admin_bar_helper', 'title' => 'Blog Layout', 'href' => $optionUrl . '&tab=of-option-blog')); } if (ux_is_woocommerce_active()) { if (is_checkout() || is_cart()) { $wp_admin_bar->add_menu(array('parent' => false, 'id' => 'admin_bar_helper', 'title' => 'Checkout Settings', 'href' => $adminUrl . 'admin.php?page=wc-settings&tab=checkout')); } if (is_product()) { $wp_admin_bar->add_menu(array('parent' => false, 'id' => 'admin_bar_helper', 'title' => 'Product Page Layout', 'href' => $optionUrl . '&tab=of-option-productpage')); } if (is_account_page()) { $wp_admin_bar->add_menu(array('parent' => false, 'id' => 'admin_bar_helper', 'title' => 'My Account Page', 'href' => $adminUrl . 'admin.php?page=wc-settings&tab=account')); } if (is_shop() || is_product_category()) { $wp_admin_bar->add_menu(array('parent' => false, 'id' => 'admin_bar_helper', 'title' => 'Shop Settings')); $wp_admin_bar->add_menu(array('parent' => 'admin_bar_helper', 'id' => 'admin_bar_helper_flatsome', 'title' => 'Category Page Layout', 'href' => $optionUrl . '&tab=of-option-categorypage')); $wp_admin_bar->add_menu(array('parent' => 'admin_bar_helper', 'id' => 'admin_bar_helper_woocommerce', 'title' => 'Shop Page Display', 'href' => $adminUrl . 'admin.php?page=wc-settings&tab=products§ion=display')); } } }
/** * widget function. * * @see WP_Widget * * @param array $args * @param array $instance * * @return void */ public function widget($args, $instance) { global $product; if (!is_product()) { return; } if ($product->product_type === 'composite') { $layout_style = $product->get_composite_layout_style(); $layout_style_variation = $product->get_composite_layout_style_variation(); $show_widget = apply_filters('woocommerce_composite_summary_widget_display', $layout_style === 'paged' && $layout_style_variation !== 'componentized', $layout_style, $layout_style_variation, $product); if (!$show_widget) { return; } } else { return; } echo $args['before_widget']; $default = isset($this->settings['title']['std']) ? $this->settings['title']['std'] : ''; if ($title = apply_filters('widget_title', empty($instance['title']) ? $default : $instance['title'], $instance, $this->id_base)) { echo $args['before_title'] . $title . $args['after_title']; } // Insert widget placeholder elements - code in woocommerce.js will update them as required ob_start(); ?> <div class="widget_composite_summary_content" data-container_id="<?php echo $product->id; ?> "> <div class="widget_composite_summary_elements cp_clearfix"></div> <div class="widget_composite_summary_price cp_clearfix"></div> <div class="widget_composite_summary_error cp_clearfix"></div> </div><?php echo ob_get_clean(); echo $args['after_widget']; }
/** * Init theme config for shop. * * @param string $name */ function dt_woocommerce_configure_template($name = '') { dt_woocommerce_configure_mini_cart(); // Add template configuration actions. $config = presscore_config(); $mod_wc_config = dt_woocommerce_template_config($config); add_action('dt_wc_loop_start', array($mod_wc_config, 'setup')); add_action('dt_wc_loop_end', array($mod_wc_config, 'cleanup')); // Stop if not on woocommerce page. if ('shop' !== $name) { return; } // From what page get settings? $post_id = null; if (is_shop()) { $post_id = woocommerce_get_page_id('shop'); } else { if (is_cart()) { $post_id = woocommerce_get_page_id('cart'); } else { if (is_checkout()) { $post_id = woocommerce_get_page_id('checkout'); } } } if ($post_id) { $config->set('post_id', $post_id); } if (!is_product()) { add_filter('presscore_get_page_title', 'dt_woocommerce_get_page_title', 20); } // Replace theme breadcrumbs. add_filter('presscore_get_breadcrumbs-html', 'dt_woocommerce_replace_theme_breadcrumbs', 20, 2); }
function woothemes_add_css() { global $woo_options; wp_register_style('prettyPhoto', get_template_directory_uri() . '/includes/css/prettyPhoto.css'); wp_register_style('non-responsive', get_template_directory_uri() . '/css/non-responsive.css'); // Disable prettyPhoto css if WooCommerce is activated and user is on the product page $woocommerce_activated = is_woocommerce_activated(); $woocommerce_lightbox = get_option('woocommerce_enable_lightbox') == 'yes' ? true : false; $woocommerce_product = false; if ($woocommerce_activated) { $woocommerce_product = is_product(); } if ($woocommerce_activated && $woocommerce_product && $woocommerce_lightbox) { wp_deregister_style('prettyPhoto'); } // Conditionally load the Portfolio CSS, where needed. $load_portfolio_css = false; if (is_page_template('template-portfolio.php') || is_singular() && get_post_type() == 'portfolio' || is_post_type_archive('portfolio') || is_tax('portfolio-gallery')) { $load_portfolio_css = true; } // Allow child themes/plugins to load the portfolio CSS when they need it. $load_portfolio_css = apply_filters('woo_load_portfolio_css', $load_portfolio_css); if ($load_portfolio_css) { wp_enqueue_style('prettyPhoto'); } do_action('woothemes_add_css'); }
/** * Change the login text from what's set in our WooCommerce settings * so we're not talking about checkout for a product review. * * @param string $login_text the original text from Social Login settings * @return strong $login_text the updated text for PRPro use */ function sv_wc_social_login_change_prpro_login_text($login_text) { // Only modify the text from this option if we're on a product page if (is_product()) { $login_text = __('You can also create an account or log in with a social network.', 'my-textdomain'); } return $login_text; }
function woocommerce_variable_empty_price_html_custom() { if (is_product()) { return '<a class="single_add_to_cart_button button alt" href="mailto:sales@alliedscientificpro.com?Subject=Please send a quote for ' . get_the_title() . '" title=" Contact Us"> Get a quote now!</a>'; } else { return '<a class="contact-us-links" href="mailto:sales@alliedscientificpro.com?Subject=Please send a quote for ' . get_the_title() . '" title=" Contact Us"> Get a quote now!</a>'; } }
/** * WooCommerce conditionals * * is_woocommerce - Returns true if on a page which uses WooCommerce templates (cart and checkout are standard pages with shortcodes and thus are not included) **/ function is_woocommerce() { if (is_shop() || is_product_category() || is_product_tag() || is_product()) { return true; } else { return false; } }
function quark_woocommerce_before_main_content() { if (is_shop() && !of_get_option('woocommerce_shopsidebar', '1') || is_product() && !of_get_option('woocommerce_productsidebar', '1')) { echo '<div class="col grid_12_of_12">'; } else { echo '<div class="col grid_10_of_12 offset_1">'; } }
function x_is_product() { if (function_exists('is_product') && is_product()) { return true; } else { return false; } }
public function plugin_compatibility_filters() { if (is_product()) { if (!$this->user_can_purchase(get_product(get_the_ID()))) { add_filter('woocommerce_bv_render_form', '__return_false'); } } }