当前位置: 首页>>代码示例>>PHP>>正文


PHP is_cart函数代码示例

本文整理汇总了PHP中is_cart函数的典型用法代码示例。如果您正苦于以下问题:PHP is_cart函数的具体用法?PHP is_cart怎么用?PHP is_cart使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了is_cart函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: hide_minicart

 public function hide_minicart($bool)
 {
     if (is_cart() || is_checkout()) {
         return false;
     }
     return $bool;
 }
开发者ID:aragonc,项目名称:3clicks,代码行数:7,代码来源:g1-woocommerce.php

示例2: widget

 /**
  * widget function.
  *
  * @see WP_Widget
  * @access public
  * @param array $args
  * @param array $instance
  * @return void
  */
 function widget($args, $instance)
 {
     global $woocommerce;
     extract($args);
     if (is_cart() || is_checkout()) {
         return;
     }
     $title = apply_filters('widget_title', empty($instance['title']) ? __('Cart', 'woocommerce') : $instance['title'], $instance, $this->id_base);
     $hide_if_empty = empty($instance['hide_if_empty']) ? 0 : 1;
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     if ($hide_if_empty) {
         echo '<div class="hide_cart_widget_if_empty">';
     }
     // Insert cart widget placeholder - code in woocommerce.js will update this on page load
     echo '<div class="widget_shopping_cart_content"></div>';
     if ($hide_if_empty) {
         echo '</div>';
     }
     echo $after_widget;
     if ($hide_if_empty && sizeof($woocommerce->cart->get_cart()) == 0) {
         $woocommerce->add_inline_js("\n\t\t\t\tjQuery('.hide_cart_widget_if_empty').closest('.widget_shopping_cart').hide();\n\n\t\t\t\tjQuery('body').bind('adding_to_cart', function(){\n\t\t\t\t\tjQuery('.hide_cart_widget_if_empty').closest('.widget_shopping_cart').fadeIn();\n\t\t\t\t});\n\t\t\t");
     }
 }
开发者ID:googlecode-mirror,项目名称:wpmu-demo,代码行数:35,代码来源:class-wc-widget-cart.php

示例3: child_manage_woocommerce_styles

/**
 * Remove WooCommerce Generator tag, styles, and scripts from the homepage.
 * Tested and works with WooCommerce 2.0+
 *
 * @author Greg Rickaby
 * @since 2.0.0
 */
function child_manage_woocommerce_styles()
{
    remove_action('wp_head', array($GLOBALS['woocommerce'], 'generator'));
    if (!is_woocommerce() && !is_cart() && !is_checkout()) {
        wp_dequeue_style('woocommerce_frontend_styles');
        wp_dequeue_style('woocommerce_fancybox_styles');
        wp_dequeue_style('woocommerce_chosen_styles');
        wp_dequeue_style('woocommerce_prettyPhoto_css');
        wp_dequeue_script('wc_price_slider');
        wp_dequeue_script('wc-single-product');
        wp_dequeue_script('wc-add-to-cart');
        wp_dequeue_script('wc-cart-fragments');
        wp_dequeue_script('wc-checkout');
        wp_dequeue_script('wc-add-to-cart-variation');
        wp_dequeue_script('wc-single-product');
        wp_dequeue_script('wc-cart');
        wp_dequeue_script('wc-chosen');
        wp_dequeue_script('woocommerce');
        wp_dequeue_script('prettyPhoto');
        wp_dequeue_script('prettyPhoto-init');
        wp_dequeue_script('jquery-blockui');
        wp_dequeue_script('jquery-placeholder');
        wp_dequeue_script('fancybox');
        wp_dequeue_script('jqueryui');
    }
}
开发者ID:vespertines,项目名称:wordpress_theme_starter,代码行数:33,代码来源:woocommerce.php

示例4: mango_current_page_id

function mango_current_page_id()
{
    global $post, $wp_query;
    $current_page_id = '';
    // Get The Page ID You Need
    //wp_reset_postdata();
    if (class_exists("woocommerce")) {
        if (is_shop()) {
            ///|| is_product_category() || is_product_tag()) {
            $current_page_id = get_option('woocommerce_shop_page_id');
        } elseif (is_cart()) {
            $current_page_id = get_option('woocommerce_cart_page_id');
        } elseif (is_checkout()) {
            $current_page_id = get_option('woocommerce_checkout_page_id');
        } elseif (is_account_page()) {
            $current_page_id = get_option('woocommerce_myaccount_page_id');
        } elseif (is_view_order_page()) {
            $current_page_id = get_option('woocommerce_view_order_page_id');
        }
    }
    if ($current_page_id == '') {
        if (is_home() && is_front_page()) {
            $current_page_id = '';
        } elseif (is_home()) {
            $current_page_id = get_option('page_for_posts');
        } elseif (is_search() || is_category() || is_tag() || is_tax()) {
            $current_page_id = '';
            //}elseif(class_exists("woocommerce") && (is_shop() || is_product_category() || is_cart() || is_checkout() || is_account_page() || is_view_order_page() )){
            // $current_page_id = '';
        } elseif (!is_404()) {
            $current_page_id = $post->ID;
        }
    }
    return $current_page_id;
}
开发者ID:nickkoskowski,项目名称:Work-Depot,代码行数:35,代码来源:general.php

示例5: woodrobe_body_class

function woodrobe_body_class($classes)
{
    if (is_woocommerce() || is_cart() || is_checkout() || is_account_page()) {
        $classes[] = 'woodrobe';
    }
    return $classes;
}
开发者ID:peterjohnhunt,项目名称:woodrobe,代码行数:7,代码来源:woodrobe.php

示例6: hide_coupon_field_on_cart

function hide_coupon_field_on_cart($enabled)
{
    if (is_cart()) {
        $enabled = false;
    }
    return $enabled;
}
开发者ID:MortenAndersen,项目名称:wpbase,代码行数:7,代码来源:woo-wpbase.php

示例7: wc_minimum_order_amount

function wc_minimum_order_amount()
{
    global $woocommerce;
    $postcode = get_user_meta(get_current_user_id(), 'shipping_postcode', true);
    if (strstr(' 90024 90027 90028 90029 90034 90036 90038 90039 90046 90048 90064 90066 90067 90068 90069 90095 90230 90291 90401 90402 90403 90404 90405 91505 91506 91602 91604 91607 91608 90010 90012 90019 90020 90025 90232 91601 91606 90073 90031 90090 90005 90004 90026 90035 90056 90211 90212 ', $postcode)) {
        $minimum = 60;
    } else {
        if (strstr(' 90045 90049 90016 90292 91423 90008 90018 90045 90049 90210 90245 90272 90293 90077 90094 91403 91436 90079 90210 90007 90015 90017 90057 90071 90089 90266 90013 90014 ', $postcode)) {
            $minimum = 100;
        } else {
            $minimum = false;
        }
    }
    if ($minimum == false) {
        wc_print_notice(sprintf('We are unable to service your area at this time. Please give us a call at (323) 450-7708 to discuss arrangements for your delivery.', wc_price($minimum), wc_price(WC()->cart->subtotal)), 'error');
        echo "<script>\n\t\t\t\tjQuery(document).ready(function(\$) {\n\t\t\t\t\t\$('.checkout-button').addClass('disabled');\n\t\t\t\t\t\$('.checkout-button').click(function(e) { e.preventDefault(); });\n\t\t\t\t});\n\t\t\t</script>";
    } elseif (WC()->cart->subtotal < $minimum) {
        if (is_cart()) {
            wc_print_notice(sprintf('Based on your zip code ' . $postcode . ', you must have an order with a minimum of %s to checkout. Your current order total is %s.', wc_price($minimum), wc_price(WC()->cart->subtotal)), 'error');
            echo "\n\t\t\t\t<script>\n\t\t\t\t\tjQuery(document).ready(function(\$) {\n\t\t\t\t\t\t\$('.checkout-button').addClass('disabled');\n\t\t\t\t\t\t\$('.checkout-button').click(function(e) { e.preventDefault(); });\n\t\t\t\t\t});\n\t\t\t\t</script>";
        } else {
            wc_add_notice(sprintf('Based on your zip code ' . $postcode . ', you must have an order with a minimum of %s to checkout. Your current order total is %s.', wc_price($minimum), wc_price(WC()->cart->subtotal)), 'error');
        }
    }
}
开发者ID:keyshames,项目名称:tcm2016,代码行数:25,代码来源:checkout.php

示例8: auto_update_cart_total

function auto_update_cart_total()
{
    // Only run in the Cart
    if (is_cart()) {
        global $woocommerce;
        ?>
        <script>
            jQuery(function($){
			   var 	currency = '<?php 
        echo get_woocommerce_currency_symbol();
        ?>
';
			   $('input[name*="qty"]').change(function(){
					var quantity_number = $(this).val();
					var prices = $(this).closest('.cart_item').find('.product-price').find('.amount').html().replace(/[^0-9\.]+/g,"");
					var sub_total = quantity_number*prices;
					$(this).closest('.cart_item').find('.product-subtotal').find('.amount').html(currency+sub_total.toFixed(2));				
					var sum = 0;
					setTimeout(function(){
						$('.product-subtotal .amount').each(function(){
							var $amt = $(this);
							sum += parseFloat($amt.html().replace(/[^0-9\.]+/g,""));
							$('.cart-subtotal .amount').html(currency+sum.toFixed(2));
							$('.order-total .amount').html(currency+sum.toFixed(2));		
						})
					}, 300);					
				})
            });
        </script>
    <?php 
    }
}
开发者ID:rrapuya,项目名称:woocommerce-cart-auto-update-total,代码行数:32,代码来源:functions.php

示例9: flatsome_admin_bar_helper

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&section=display'));
        }
    }
}
开发者ID:B1aZer,项目名称:yaltatoys_wp,代码行数:25,代码来源:helpers.php

示例10: 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);
 }
开发者ID:noman90rauf,项目名称:wp-content,代码行数:38,代码来源:mod-wc-template-config.php

示例11: wholesale_price

 /**
  * wholesale_price.
  */
 function wholesale_price($price, $product)
 {
     if (!wcj_is_product_wholesale_enabled($product->id)) {
         return $price;
     }
     // Show only on checkout and cart pages
     $is_ajax = is_admin() && (defined('DOING_AJAX') && DOING_AJAX) ? true : false;
     if (!(is_checkout() || is_cart() || $is_ajax)) {
         return $price;
     }
     // Get quanitity from cart
     $quanitities = array();
     $the_cart = WC()->cart->get_cart();
     foreach ($the_cart as $cart_item_key => $values) {
         if (!isset($quanitities[$values['product_id']])) {
             $quanitities[$values['product_id']] = 0;
         }
         $quanitities[$values['product_id']] += $values['quantity'];
     }
     foreach ($quanitities as $product_id => $product_quantity) {
         if ($product_id == $product->id) {
             // Found matching product in the cart
             if ($product_quantity > 1) {
                 // Setting wholesale price
                 $price = $this->get_wholesale_price($price, $product_quantity);
                 $precision = get_option('woocommerce_price_num_decimals', 2);
                 return round($price, $precision);
             }
         }
     }
     return $price;
 }
开发者ID:sawan34,项目名称:tanzi,代码行数:35,代码来源:class-wcj-wholesale-price.php

示例12: wc_autoship_upsell_cart_item_name

function wc_autoship_upsell_cart_item_name($name, $item, $item_key)
{
    if (!is_cart()) {
        return $name;
    }
    $product_id = $item['product_id'];
    $autoship_enabled = get_post_meta($product_id, '_wc_autoship_enable_autoship', true);
    if ($autoship_enabled != 'yes') {
        // No autoship
        return $name;
    }
    $var_product_id = !empty($item['variation_id']) ? $item['variation_id'] : $item['product_id'];
    $product = wc_get_product($var_product_id);
    $price = $product->get_price();
    $autoship_price = (double) apply_filters('wc_autoship_price', get_post_meta($var_product_id, '_wc_autoship_price', true), $var_product_id, 0, get_current_user_id(), 0);
    $diff = $product->get_price() - $autoship_price;
    $upsell_title = '';
    $upsell_class = '';
    if (isset($item['wc_autoship_frequency'])) {
        $upsell_title = __('<span class="wc-autoship-upsell-icon">&#9998;</span> Change Auto-Ship', 'wc-autoship-upsell');
        $upsell_class = 'wc-autoship-upsell-change-autoship';
    } elseif ($autoship_price > 0 && $diff > 0) {
        $upsell_title = __('<span class="wc-autoship-upsell-icon">&plus;</span>Save ' . wc_price($diff) . ' with Auto-Ship', 'wc-autoship-upsell');
        $upsell_class = 'wc-autoship-upsell-add-autoship-savings';
    } else {
        $upsell_title = __('<span class="wc-autoship-upsell-icon">&plus;</span>Add to Auto-Ship', 'wc-autoship-upsell');
        $upsell_class = 'wc-autoship-upsell-add-autoship';
    }
    $upsell_title = apply_filters('wc-autoship-upsell-title', $upsell_title, $item, $item_key);
    ob_start();
    ?>
			<div class="wc-autoship-upsell-container <?php 
    echo $upsell_class;
    ?>
">
				<button type="button" class="wc-autoship-upsell-cart-toggle"
					data-cart-item-key="<?php 
    echo esc_attr($item_key);
    ?>
"
					data-product-id="<?php 
    echo esc_attr($product->id);
    ?>
"
					data-remove-from-cart-url="<?php 
    echo esc_attr(WC()->cart->get_remove_url($item_key));
    ?>
"
					data-add-to-cart-url="<?php 
    echo esc_attr($product->add_to_cart_url());
    ?>
"><?php 
    echo $upsell_title;
    ?>
</button>
			</div>
		<?php 
    $upsell_content = ob_get_clean();
    return $name . $upsell_content;
}
开发者ID:patternsinthecloud,项目名称:woocommerce-autoship-upsell,代码行数:60,代码来源:woocommerce-autoship-upsell.php

示例13: woocommerce_cart_tab

 function woocommerce_cart_tab()
 {
     global $woocommerce;
     $skin = get_option('wc_ct_skin');
     $position = get_option('wc_ct_horizontal_position');
     $widget = get_option('wc_ct_cart_widget');
     if (!is_cart() && !is_checkout()) {
         if ($widget == 'yes') {
             echo '<div class="' . $position . ' cart-tab ' . $skin . '">';
         } else {
             echo '<div class="' . $position . ' cart-tab no-animation ' . $skin . '">';
         }
         wcct_cart_button();
         // Display the widget if specified
         if ($widget == 'yes') {
             // Check for WooCommerce 2.0 and display the cart widget
             if (version_compare(WOOCOMMERCE_VERSION, "2.0.0") >= 0) {
                 the_widget('WC_Widget_Cart', 'title=');
             } else {
                 the_widget('WooCommerce_Widget_Cart', 'title=');
             }
         }
         echo '</div>';
     }
 }
开发者ID:iplaydu,项目名称:Bob-Ellis-Shoes,代码行数:25,代码来源:cart-tab.php

示例14: xt_get_page_ID

function xt_get_page_ID()
{
    global $wp_query, $post;
    $page_id = false;
    if (is_home() && get_option('page_for_posts')) {
        $page_id = get_option('page_for_posts');
    } elseif (is_front_page() && get_option('page_on_front')) {
        $page_id = get_option('page_on_front');
    } else {
        if (function_exists('is_shop') && is_shop() && get_option('woocommerce_shop_page_id') != '') {
            $page_id = get_option('woocommerce_shop_page_id');
        } else {
            if (function_exists('is_cart') && is_cart() && get_option('woocommerce_cart_page_id') != '') {
                $page_id = get_option('woocommerce_cart_page_id');
            } else {
                if (function_exists('is_checkout') && is_checkout() && get_option('woocommerce_checkout_page_id') != '') {
                    $page_id = get_option('woocommerce_checkout_page_id');
                } else {
                    if (function_exists('is_account_page') && is_account_page() && get_option('woocommerce_myaccount_page_id') != '') {
                        $page_id = get_option('woocommerce_myaccount_page_id');
                    } else {
                        if ($wp_query && !empty($wp_query->queried_object) && !empty($wp_query->queried_object->ID)) {
                            $page_id = $wp_query->queried_object->ID;
                        } else {
                            if (!empty($post->ID)) {
                                $page_id = $post->ID;
                            }
                        }
                    }
                }
            }
        }
    }
    return $page_id;
}
开发者ID:venturepact,项目名称:blog,代码行数:35,代码来源:functions.php

示例15: wpex_add_itemcart_to_menu

 function wpex_add_itemcart_to_menu($items, $args)
 {
     // Add to main menu only
     if ('main_menu' == $args->theme_location) {
         // Get style from theme mod
         $style = get_theme_mod('woo_menu_icon_style', 'drop-down');
         // Add class for the toggle
         if ('drop-down' == $style) {
             $class = 'wcmenucart-toggle-dropdown';
         } elseif ('overlay' == $style) {
             $class = 'wcmenucart-toggle-overlay';
         } elseif ('store' == $style) {
             $class = '';
         } elseif ('custom-link' == $style) {
             $class = '';
         } else {
             $class = '';
         }
         // Only add toggle class when needed
         if (is_cart() || is_checkout()) {
             $class = '';
         }
         // Add cart link to menu items
         $items .= '<li class="' . $class . ' woo-menu-icon">' . wpex_wcmenucart_menu_item() . '</li>';
     }
     // Return menu items
     return $items;
 }
开发者ID:sergey-h,项目名称:naman,代码行数:28,代码来源:woo-menucart.php


注:本文中的is_cart函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。