/**
 * 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');
    }
}
 /**
  * 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");
     }
 }
Example #3
1
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;
}
Example #4
0
function hide_coupon_field_on_cart($enabled)
{
    if (is_cart()) {
        $enabled = false;
    }
    return $enabled;
}
Example #5
0
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');
        }
    }
}
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 
    }
}
Example #7
0
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'));
        }
    }
}
 /**
  * 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;
 }
 /**
  * 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);
 }
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;
}
Example #11
0
 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>';
     }
 }
Example #12
0
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;
}
Example #13
0
function woodrobe_body_class($classes)
{
    if (is_woocommerce() || is_cart() || is_checkout() || is_account_page()) {
        $classes[] = 'woodrobe';
    }
    return $classes;
}
Example #14
0
 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;
 }
function child_manage_woocommerce_styles()
{
    //remove generator meta tag
    remove_action('wp_head', array($GLOBALS['woocommerce'], 'generator'));
    //first check that woo exists to prevent fatal errors
    if (function_exists('is_woocommerce')) {
        //dequeue scripts and styles
        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');
        }
    }
}
Example #16
0
    /**
     * Cart Link
     * Displayed a link to the cart including the number of items present and the cart total
     *
     * @since  2.2.6
     *
     * @param  array $settings Settings
     *
     * @return array           Settings
     */
    function odin_cart_link()
    {
        if (is_cart()) {
            $class = 'current-menu-item active';
        } else {
            $class = '';
        }
        ?>
		<li class="<?php 
        echo esc_attr($class);
        ?>
">
			<a class="cart-contents" href="<?php 
        echo esc_url(WC()->cart->get_cart_url());
        ?>
" title="<?php 
        _e('View your shopping cart', 'odin');
        ?>
">
				<?php 
        echo wp_kses_data(WC()->cart->get_cart_total());
        ?>
 <span class="count"><?php 
        echo wp_kses_data(sprintf(_n('%d item', '%d items', WC()->cart->get_cart_contents_count(), 'odin'), WC()->cart->get_cart_contents_count()));
        ?>
</span>
			</a>
		</li>
		<?php 
    }
 /**
  * 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);
 }
Example #18
0
 /**
  * Widget
  * Display the widget in the sidebar
  * Save output to the cache if empty
  *
  * @param  array  sidebar arguments
  * @param  array  instance
  */
 public function widget($args, $instance)
 {
     // Hide widget if page is the cart or checkout
     if (is_cart() || is_checkout()) {
         return false;
     }
     extract($args);
     // Set the widget title
     $title = apply_filters('widget_title', $instance['title'] ? $instance['title'] : __('Cart', 'fflcommerce'), $instance, $this->id_base);
     // Print the widget wrapper & title
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     // Get the contents of the cart
     $cart_contents = fflcommerce_cart::$cart_contents;
     // If there are items in the cart print out a list of products
     if (!empty($cart_contents)) {
         // Open the list
         echo '<ul class="cart_list">';
         foreach ($cart_contents as $key => $value) {
             // Get product instance
             $_product = $value['data'];
             if ($_product->exists() && $value['quantity'] > 0) {
                 echo '<li>';
                 // Print the product image & title with a link to the permalink
                 echo '<a href="' . esc_attr(get_permalink($_product->id)) . '" title="' . esc_attr($_product->get_title()) . '">';
                 // Print the product thumbnail image if exists else display placeholder
                 echo has_post_thumbnail($_product->id) ? get_the_post_thumbnail($_product->id, 'shop_tiny') : fflcommerce_get_image_placeholder('shop_tiny');
                 // Print the product title
                 echo '<span class="js_widget_product_title">' . $_product->get_title() . '</span>';
                 echo '</a>';
                 // Displays variations and cart item meta
                 echo fflcommerce_cart::get_item_data($value);
                 // Print the quantity & price per product
                 echo '<span class="js_widget_product_price">' . $value['quantity'] . ' &times; ' . $_product->get_price_html() . '</span>';
                 echo '</li>';
             }
         }
         echo '</ul>';
         // Close the list
         // Print the cart total
         echo '<p class="total"><strong>';
         echo __('Subtotal', 'fflcommerce');
         echo ':</strong> ' . fflcommerce_price($this->total_cart_items());
         echo '</p>';
         do_action('fflcommerce_widget_cart_before_buttons');
         // Print view cart & checkout buttons
         $view_cart_button_label = isset($instance['view_cart_button']) ? $instance['view_cart_button'] : __('View Cart &rarr;', 'fflcommerce');
         $checkout_button_label = isset($instance['checkout_button']) ? $instance['checkout_button'] : __('Checkout &rarr;', 'fflcommerce');
         echo '<p class="buttons">';
         echo '<a href="' . esc_attr(fflcommerce_cart::get_cart_url()) . '" class="button">' . __($view_cart_button_label, 'fflcommerce') . '</a>';
         echo '<a href="' . esc_attr(fflcommerce_cart::get_checkout_url()) . '" class="button checkout">' . __($checkout_button_label, 'fflcommerce') . '</a>';
         echo '</p>';
     } else {
         echo '<span class="empty">' . __('No products in the cart.', 'fflcommerce') . '</span>';
     }
     // Print closing widget wrapper
     echo $after_widget;
 }
 /**
  * Handles the subscription upgrade/downgrade process.
  *
  * @since 1.4
  */
 public static function subscription_switch_handler()
 {
     global $woocommerce, $post;
     // If the current user doesn't own the subscription, remove the query arg from the URL
     if (isset($_GET['switch-subscription'])) {
         // Visiting a switch link for someone elses subscription
         if (!WC_Subscriptions_Manager::user_owns_subscription($_GET['switch-subscription'])) {
             wp_redirect(remove_query_arg('switch-subscription'));
             exit;
         } else {
             if (isset($_GET['auto-switch'])) {
                 $switch_message = __('You have an active subscription to this product. Choosing a new subscription will replace your existing subscription.', 'woocommerce-subscriptions');
             } else {
                 $switch_message = __('Choose a new subscription.', 'woocommerce-subscriptions');
             }
             WC_Subscriptions::add_notice($switch_message, 'notice');
         }
     } elseif ((is_cart() || is_checkout()) && false !== self::cart_contains_subscription_switch()) {
         WC_Subscriptions::add_notice(__('Once sign up is complete, this will replace your existing subscription.', 'woocommerce-subscriptions'), 'notice');
     } elseif (is_product() && ($product = get_product($post))) {
         // Automatically initiate the switch process for limited variable subscriptions
         if (($product->is_type(array('variable-subscription', 'subscription_variation')) || 0 !== $product->post->post_parent) && WC_Subscriptions_Product::is_subscription($product->id) && 'yes' === $product->limit_subscriptions) {
             // Check if the user has an active subscription for this product, and if so, initiate the switch process
             $subscriptions = WC_Subscriptions_Manager::get_users_subscriptions();
             foreach ($subscriptions as $subscription_key => $subscription) {
                 if ($subscription['product_id'] == $product->id && 'active' == $subscription['status']) {
                     wp_redirect(add_query_arg('auto-switch', 'true', self::get_switch_link($subscription_key)));
                     exit;
                 }
             }
         }
     }
 }
    function storefront_header_cart()
    {
        if (is_woocommerce_activated()) {
            if (is_cart()) {
                $class = 'current-menu-item';
            } else {
                $class = '';
            }
            ?>
		<ul class="site-header-cart menu">
			<li class="<?php 
            echo esc_attr($class);
            ?>
">
				<?php 
            storefront_cart_link();
            ?>
			</li>
			<li>
				<?php 
            the_widget('WC_Widget_Cart', 'title=');
            ?>
			</li>
		</ul>
		<div class="social-icons">
			<a href="http://instagram.com/homeboyadvance" class="icon-instagram" target="_blank"></a>
			<a href="http://facebook.com/homeboyadvance" class="icon-facebook" target="_blank"></a>
			<a href="http://twitter.com/homeboyadvance" class="icon-twitter" target="_blank"></a>
		</div>
		<?php 
        }
    }
Example #21
0
    function storefront_header_cart()
    {
        if (is_woocommerce_activated()) {
            if (is_cart()) {
                $class = 'current-menu-item';
            } else {
                $class = '';
            }
            ?>
            <ul class="site-header-cart menu">
                <li class="<?php 
            echo esc_attr($class);
            ?>
">
                    <?php 
            storefront_cart_link();
            ?>
                </li>
                <li>
                    <?php 
            the_widget('WC_Widget_Cart', 'title=');
            ?>
                </li>
            </ul>
            <?php 
        }
    }
Example #22
0
 public function hide_minicart($bool)
 {
     if (is_cart() || is_checkout()) {
         return false;
     }
     return $bool;
 }
/**
 * Enqueue scripts required for exemption management on the checkout page
 */
function enqueue_checkout_scripts()
{
    if (!is_admin() && is_checkout() || is_cart()) {
        // Enqueue Magnific Popup
        wp_enqueue_style('mpop-css', WT_PLUGIN_DIR_URL . 'css/magnificPopup.css');
        wp_enqueue_script('mpop-js', WT_PLUGIN_DIR_URL . 'js/magnificPopup.js', array('jquery'), '1.0', true);
    }
}
 /**
  * Loading minicart option on wp_head section.
  *
  * @return void
  */
 public function woo_floating_minicart()
 {
     if (!(is_cart() || is_checkout())) {
         echo "<div class='awfm-warp-content'>";
         $this->awfm_woocommerce_mini_cart();
         echo "</div>";
     }
 }
Example #25
0
function wpt_footer_cart_link()
{
    global $woocommerce;
    if (sizeof($woocommerce->cart->cart_contents) > 0 && (!is_cart() && !is_checkout())) {
        echo '<a class="btn" href="' . $woocommerce->cart->get_cart_url() . '" title="' . __('Cart') . '">' . __('Cart') . '</a>';
        echo '<a class="btn" href="' . $woocommerce->cart->get_checkout_url() . '" title="' . __('Checkout') . '">' . __('Checkout') . '</a>';
    }
}
 public function add_box_thumb($thumb, $post_id)
 {
     if (!$this->is_in_sidebar() && !is_cart() && !is_checkout()) {
         return self::show_badge_on_product($thumb, $post_id);
     } else {
         return $thumb;
     }
 }
 /**
  * change_labels.
  *
  * @version 2.5.7
  * @since   2.5.7
  */
 function change_labels()
 {
     if (function_exists('is_cart') && is_cart()) {
         wp_enqueue_style('wcj-shipping-calculator', wcj_plugin_url() . '/includes/css/wcj-shipping-calculator.css', array(), WCJ()->version);
         wp_enqueue_script('wcj-shipping-calculator-js', wcj_plugin_url() . '/includes/js/wcj-shipping-calculator.js', array('jquery'), WCJ()->version, true);
         wp_localize_script('wcj-shipping-calculator-js', 'alg_object', array('calculate_shipping_label' => get_option('wcj_shipping_calculator_label_calculate_shipping', ''), 'update_totals_label' => get_option('wcj_shipping_calculator_label_update_totals', '')));
     }
 }
 /**
  * Attaches the "set_subscription_prices_for_calculation" filter to the WC Product's woocommerce_get_price hook.
  *
  * This function is hooked to "woocommerce_before_calculate_totals" so that WC will calculate a subscription
  * product's total based on the total of it's price per period and sign up fee (if any).
  *
  * @since 1.2
  */
 public static function add_calculation_price_filter()
 {
     // Only hook when totals are being calculated completely (on cart & checkout pages)
     if (!self::cart_contains_subscription() || !is_checkout() && !is_cart() && !defined('WOOCOMMERCE_CHECKOUT') && !defined('WOOCOMMERCE_CART')) {
         return;
     }
     // Set which price should be used for calculation
     add_filter('woocommerce_get_price', __CLASS__ . '::set_subscription_prices_for_calculation', 100, 2);
 }
Example #29
0
 function ci_theme_woo_pages_fullwidth_option($value, $object_id, $meta_key, $single)
 {
     if ('page_layout' == $meta_key) {
         if (woocommerce_enabled() && (is_cart() || is_checkout() || is_account_page())) {
             return 'full';
         }
     }
     return $value;
 }
Example #30
-1
    function wpex_cart_widget_dropdown()
    {
        // If disabled bail
        if (!get_theme_mod('woo_menu_icon', true)) {
            return;
        }
        // Do nothing if it isn't the corrent style
        if ('drop-down' != get_theme_mod('woo_menu_icon_style', 'drop-down')) {
            return;
        }
        // Globals & vars
        global $woocommerce;
        $shop_page_url = get_permalink(woocommerce_get_page_id('shop'));
        $cart_contents_count = $woocommerce->cart->cart_contents_count;
        // Not needed on checkout
        if (is_checkout()) {
            return false;
        }
        // Not needed on cart page when items exist
        if (is_cart() && sizeof($cart_contents_count) !== 0) {
            return false;
        }
        ?>
		
		<div id="current-shop-items-dropdown" class="clr">
			<div id="current-shop-items-inner" class="clr">
				<?php 
        // Display WooCommerce cart
        the_widget('WC_Widget_Cart', 'title= ');
        ?>
			</div><!-- #current-shop-items-inner -->
		</div><!-- #current-shop-items-dropdown -->
		
	<?php 
    }