本文整理汇总了PHP中is_product函数的典型用法代码示例。如果您正苦于以下问题:PHP is_product函数的具体用法?PHP is_product怎么用?PHP is_product使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_product函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sv_remove_product_page_skus
function sv_remove_product_page_skus($enabled)
{
if (!is_admin() && is_product()) {
return false;
}
return $enabled;
}
示例2: simulator
/**
* 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());
}
}
开发者ID:pensesmart,项目名称:woocommerce-correios,代码行数:35,代码来源:class-wc-correios-product-shipping-simulator.php
示例3: process_request
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;
}
}
}
示例4: sv_wc_swap_mpc_rows
/**
* 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 );
}
}
');
}
示例5: m_wedding_post_classes
function m_wedding_post_classes($classes)
{
if (function_exists('is_woocommerce') && is_woocommerce() && !is_product()) {
$classes[] = 'animated fadeInUp';
}
return $classes;
}
示例6: set_styles
/**
* 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;
}
示例7: display_bool
/**
* Should Display 360 or Not
*
* @package WooCommerce 360° Image
* @author Captain Theme <info@captaintheme.com>
* @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;
}
示例8: jbst_layout
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);
}
}
}
}
示例9: awts_display_total_sales
/**
* 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;
}
示例10: enqueue_scripts
/**
* enqueue_checkout_script.
*/
public function enqueue_scripts()
{
if (!is_product()) {
return;
}
wp_enqueue_script('wcj-product-input-fields');
}
示例11: dt_woocommerce_init_template_config
/**
* 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);
}
示例12: wolf_get_header_post_id
/**
* 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;
}
示例13: is_embedded_product
/**
* 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;
}
示例14: tesseract_woocommerce_wrapper_start
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 . '">';
}
示例15: siw_remove_unnecessary_scripts
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');
}