/**
  * Add a "Change Shipping Address" button to the "My Subscriptions" table for those subscriptions
  * which require shipping.
  *
  * @param array $all_actions The $subscription_key => $actions array with all actions that will be displayed for a subscription on the "My Subscriptions" table
  * @param array $subscriptions All of a given users subscriptions that will be displayed on the "My Subscriptions" table
  * @since 1.3
  */
 public static function add_edit_address_subscription_action($all_actions, $subscriptions)
 {
     foreach ($all_actions as $subscription_key => $actions) {
         $order = new WC_Order($subscriptions[$subscription_key]['order_id']);
         $needs_shipping = false;
         foreach ($order->get_items() as $item) {
             if ($item['product_id'] !== $subscriptions[$subscription_key]['product_id']) {
                 continue;
             }
             $product = $order->get_product_from_item($item);
             if (!is_object($product)) {
                 // In case a product has been deleted
                 continue;
             }
             if ($product->needs_shipping()) {
                 $needs_shipping = true;
             }
         }
         if ($needs_shipping && in_array($subscriptions[$subscription_key]['status'], array('active', 'on-hold'))) {
             // WC 2.1+
             if (function_exists('wc_get_endpoint_url')) {
                 $all_actions[$subscription_key] = array('change_address' => array('url' => add_query_arg(array('subscription' => $subscription_key), wc_get_endpoint_url('edit-address', 'shipping')), 'name' => __('Change Address', 'woocommerce-subscriptions'))) + $all_actions[$subscription_key];
             } else {
                 $all_actions[$subscription_key] = array('change_address' => array('url' => add_query_arg(array('address' => 'shipping', 'subscription' => $subscription_key), get_permalink(woocommerce_get_page_id('edit_address'))), 'name' => __('Change Address', 'woocommerce-subscriptions'))) + $all_actions[$subscription_key];
             }
         }
     }
     return $all_actions;
 }
 /**
  * Prevent caching on dynamic pages.
  *
  * @access public
  * @return void
  */
 public function init()
 {
     if (false === ($wc_page_uris = get_transient('woocommerce_cache_excluded_uris'))) {
         if (woocommerce_get_page_id('cart') < 1 || woocommerce_get_page_id('checkout') < 1 || woocommerce_get_page_id('myaccount') < 1) {
             return;
         }
         $wc_page_uris = array();
         $cart_page = get_post(woocommerce_get_page_id('cart'));
         $checkout_page = get_post(woocommerce_get_page_id('checkout'));
         $account_page = get_post(woocommerce_get_page_id('myaccount'));
         $wc_page_uris[] = '/' . $cart_page->post_name;
         $wc_page_uris[] = '/' . $checkout_page->post_name;
         $wc_page_uris[] = '/' . $account_page->post_name;
         $wc_page_uris[] = 'p=' . $cart_page->ID;
         $wc_page_uris[] = 'p=' . $checkout_page->ID;
         $wc_page_uris[] = 'p=' . $account_page->ID;
         set_transient('woocommerce_cache_excluded_uris', $wc_page_uris);
     }
     if (is_array($wc_page_uris)) {
         foreach ($wc_page_uris as $uri) {
             if (strstr($_SERVER['REQUEST_URI'], $uri)) {
                 $this->nocache();
                 break;
             }
         }
     }
 }
    function widget($args, $instance)
    {
        $me = wp_get_current_user();
        if ($me->ID == 0) {
            return;
        }
        $funds = get_user_meta($me->ID, 'account_funds', true);
        if (empty($funds)) {
            $funds = 0;
        }
        extract($args);
        $title = apply_filters('widget_title', $instance['title']);
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        ?>
		<p><?php 
        printf(__('You currently have <b>%s</b> in your account', 'wc_account_funds'), woocommerce_price($funds));
        ?>
</p>
        <p style="text-align:center;"><a class="button" href="<?php 
        echo get_permalink(woocommerce_get_page_id('myaccount'));
        ?>
"><?php 
        _e('Deposit Funds', 'wc_account_funds');
        ?>
</a></p>
        <?php 
        echo $after_widget;
    }
Esempio n. 4
0
function sk_wcmenucart($menu, $args)
{
    // Проверяем, установлен ли и активирован плагин WooCommerce и добавляем новый элемент в меню, назначенному основным меню навигации
    if (!in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins'))) || 'mainmenu' !== $args->theme_location) {
        return $menu;
    }
    ob_start();
    global $woocommerce;
    $viewing_cart = __('View your shopping cart', 'your-theme-slug');
    $start_shopping = __('Start shopping', 'your-theme-slug');
    $cart_url = $woocommerce->cart->get_cart_url();
    $shop_page_url = get_permalink(woocommerce_get_page_id('shop'));
    $cart_contents_count = $woocommerce->cart->cart_contents_count;
    $cart_contents = sprintf(_n('%d item', '%d items', $cart_contents_count, 'your-theme-slug'), $cart_contents_count);
    $cart_total = $woocommerce->cart->get_cart_total();
    // Раскомментируйте строку ниже для того, чтобы скрыть иконку корзины в меню, когда нет добавленных товаров в корзине.
    if ($cart_contents_count > 0) {
        if ($cart_contents_count == 0) {
            $menu_item = '<li class="right"><a class="wcmenucart-contents" href="' . $shop_page_url . '" title="' . $start_shopping . '">';
        } else {
            $menu_item = '<li class="right"><a class="wcmenucart-contents" href="' . $cart_url . '" title="' . $viewing_cart . '">';
        }
        $menu_item .= '<i class="fa fa-shopping-cart"></i> ';
        $menu_item .= $cart_contents . ' - ' . $cart_total;
        $menu_item .= '</a></li>';
        // Раскомментируйте строку ниже для того, чтобы скрыть иконку корзины в меню, когда нет добавленных товаров в корзине.
    }
    echo $menu_item;
    $social = ob_get_clean();
    return $menu . $social;
}
function continue_shopping_button()
{
    $shop_page_url = get_permalink(woocommerce_get_page_id('shop'));
    echo '<div class="">';
    echo ' <a href="' . $shop_page_url . '" class="button">Continue Shopping →</a>';
    echo '</div>';
}
Esempio n. 6
0
 function include_woocommerce_template($tmpl)
 {
     global $gantry;
     $find = array('woocommerce.php');
     $file = '';
     if (is_single() && get_post_type() == 'product') {
         $file = 'single-product.php';
         $find[] = $file;
     } elseif (is_tax('product_cat') || is_tax('product_tag')) {
         $term = get_queried_object();
         $file = 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
         $find[] = 'taxonomy-' . $term->taxonomy . '.php';
         $find[] = $file;
     } elseif (is_post_type_archive('product') || is_page(woocommerce_get_page_id('shop'))) {
         $file = 'archive-product.php';
         $find[] = $file;
     }
     $find = array_reverse($find);
     $template = GantryBodyLayout::locate_type($find);
     if ($template && $template != '') {
         return $template;
     } else {
         woocommerce_content();
         return '';
     }
     return $tmpl;
 }
 /**
  * Constructor
  */
 public function __construct()
 {
     global $woocommerce;
     $this->method_title = 'Amazon Payments Advanced';
     $this->id = 'amazon_payments_advanced';
     $this->has_fields = function_exists('is_checkout_pay_page') ? is_checkout_pay_page() : is_page(woocommerce_get_page_id('pay'));
     $this->icon = apply_filters('woocommerce_amazon_pa_logo', plugins_url(basename(dirname(dirname(__FILE__))) . '/assets/images/amazon-payments.gif'));
     // Load the form fields.
     $this->init_form_fields();
     // Load the settings.
     $this->init_settings();
     // Define user set variables
     $this->title = $this->settings['title'];
     $this->seller_id = $this->settings['seller_id'];
     $this->mws_access_key = $this->settings['mws_access_key'];
     $this->secret_key = $this->settings['secret_key'];
     $this->sandbox = $this->settings['sandbox'] == 'yes' ? true : false;
     $this->payment_capture = isset($this->settings['payment_capture']) ? $this->settings['payment_capture'] : '';
     // Get endpoint
     $location = in_array($woocommerce->countries->get_base_country(), array('US', 'GB', 'DE')) ? $woocommerce->countries->get_base_country() : 'US';
     $this->endpoint = $this->sandbox ? $this->endpoints['sandbox'][$location] : $this->endpoints['production'][$location];
     // Get refererence ID
     $this->reference_id = !empty($_REQUEST['amazon_reference_id']) ? $_REQUEST['amazon_reference_id'] : '';
     if (isset($_POST['post_data'])) {
         parse_str($_POST['post_data'], $post_data);
         if (isset($post_data['amazon_reference_id'])) {
             $this->reference_id = $post_data['amazon_reference_id'];
         }
     }
     add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
 }
 /**
  * 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 custom_add_to_cart_message()
{
    global $woocommerce;
    $return_to = get_permalink(woocommerce_get_page_id('shop'));
    $message = sprintf('<a href="%s" class="button wc-forward">%s</a> %s', $return_to, __('Continue Shopping', 'woocommerce'), __('<p>Product successfully added to your cart.</p>', 'woocommerce'));
    return $message;
}
Esempio n. 10
0
    function wpex_wcmenucart_menu_item()
    {
        // Vars
        global $woocommerce;
        // URL
        if ('custom-link' == get_theme_mod('woo_menu_icon_style', 'drop-down') && ($custom_link = get_theme_mod('woo_menu_icon_custom_link'))) {
            $url = esc_url($custom_link);
        } else {
            $url = get_permalink(woocommerce_get_page_id('shop'));
        }
        // Cart total
        if (get_theme_mod('woo_menu_icon_amount')) {
            $cart_total = $woocommerce->cart->get_cart_total();
        } else {
            $cart_total = '';
        }
        ob_start();
        ?>
			<a href="<?php 
        echo $url;
        ?>
" class="wcmenucart" title="<?php 
        _e('Your Cart', 'wpex');
        ?>
">
				<span class="wcmenucart-count"><span class="fa fa-shopping-cart"></span><?php 
        echo $cart_total;
        ?>
</span>
			</a>
		<?php 
        return ob_get_clean();
    }
Esempio n. 11
0
 function loginForm()
 {
     do_action('loginx_before_login_form');
     if (parent::useWoo() && !$_GET['password'] && !$_POST['reset'] && !$_GET['reset'] && !$_GET['resend'] && !$_GET['act']) {
         print '<script>window.location.href = "' . get_permalink(woocommerce_get_page_id('myaccount')) . '";</script>';
         exit;
     }
     require_once PHPX_DIR . '/phpx_form.php';
     $form = new phpx_form();
     if (parent::loginx_successMessage()) {
         $text = '<div class="loginx_success">' . parent::loginx_successMessage('get') . '</div>';
     } else {
         if ($_GET['password'] || $_POST['reset']) {
             $form->startForm(parent::loginx_getURL() . '?password=1');
             if (parent::loginx_errorMessage()) {
                 $form->freeText(parent::loginx_errorMessage('get'), 'loginx_error');
             }
             $form->freeText($this->options['password_text']);
             $form->textField('Email/Username', 'email', '', true);
             $form->hidden('nonce', wp_create_nonce('loginx'));
             $text = '<div id="loginx_password">' . $form->endForm() . '</div>';
         } else {
             if ($_GET['reset']) {
                 $user_id = $this->wpdb->get_var($this->wpdb->prepare('select user_id from ' . $this->wpdb->prefix . 'loginx_key where loginx_key = %s and loginx_expire > %d limit 1', $_GET['reset'], time()));
                 if (!$user_id) {
                     $text = '<div class="loginx_error">' . $this->options['bad_key'] . '</div>';
                 } else {
                     $form->startForm(parent::loginx_getURL());
                     if (parent::loginx_errorMessage()) {
                         $form->freeText(parent::loginx_errorMessage('get'), 'loginx_error');
                     }
                     $form->freeText($this->options['password_reset_text']);
                     $form->password('Password', 'pass', true, 6);
                     $form->password('Confirm Password', 'pass_confirm', true, 6, true);
                     $form->hidden('nonce', wp_create_nonce('loginx'));
                     $form->hidden('reset', $_GET['reset']);
                     $text = '<div id="loginx_password">' . $form->endForm() . '</div>';
                 }
             } else {
                 $form->startForm($this->loginx_getURL());
                 if (parent::loginx_errorMessage()) {
                     $form->freeText(parent::loginx_errorMessage('get'), 'loginx_error');
                 }
                 $form->textField('Username', 'username', '', true);
                 $form->password('Password', 'password', true, 4);
                 //$form->checkBox('Remember Me?', 'remember', 0);
                 $form->hidden('remember', 'forever');
                 $form->hidden('nonce', wp_create_nonce('loginx'));
                 $form->freeText('<div id="loginx_password_link"><a href="' . get_permalink() . '?password=1">Forgot Login/Password?</a></div>');
                 $form->freeText('<div id="loginx_register_link"><a href="' . get_permalink($this->options['register_page']) . '">Register</a></div>');
                 if (function_exists('rpx_init')) {
                     $form->freeText(do_shortcode('[rpxlogin]'));
                 }
                 $text = '<div id="loginx_form">' . $form->endForm() . '</div>';
             }
         }
     }
     do_action('loginx_after_login_form');
     return $text;
 }
Esempio n. 12
0
 function showProfile()
 {
     global $current_user;
     get_currentuserinfo();
     $username = !isset($_GET['u']) || $_GET['u'] == '' ? $current_user->user_nicename : $_GET['u'];
     $user = get_user_by('slug', $username);
     $GLOBALS['avatar_user_id'] = $user->ID;
     $trans['::AVATAR::'] = get_avatar($user->user_email, 92);
     $trans['::DISPLAYNAME::'] = $user->display_name;
     $trans['::REGDATE::'] = date(get_option('date_format'), strtotime($user->user_registered));
     $trans['::INFO::'] = str_replace("\r\n", '<br />', $user->user_description);
     if ($user->ID == $current_user->ID) {
         $passwordLink = '<a href="' . get_permalink($this->options['profile_page']) . '?password=1">Change Password</a>';
         if (parent::useWoo()) {
             $passwordLink = '<a href="' . get_permalink(woocommerce_get_page_id('change_password')) . '">Change Password</a> | <a href="' . get_permalink(woocommerce_get_page_id('myaccount')) . '">My Account</a>';
         }
         $trans['::LINKS::'] = '<a href="' . get_permalink($this->options['profile_page']) . '?edit=1">Edit Profile</a> | ' . $passwordLink . $myAccountLink;
     } else {
         $trans['::LINKS::'] = '';
     }
     $trans['::POSTS::'] = $this->formatList('Latest Posts', $user, $this->getPosts($user->ID));
     $trans['::COMMENTS::'] = $this->formatList('Latest Comments', $user, $this->getComments($user->ID), 'comment');
     $trans['::PURCHASES::'] = $this->formatList('Latest Purchases', $user, $this->getPurchases($user->ID, 'woo'), 'purchase');
     $this->text = strtr(file_get_contents(LOGINX_DIR . 'templates/showProfile.tpl.php'), $trans);
 }
Esempio n. 13
0
 /**
  * Срабатывает на событие Init.
  * метод приватный, публичный доступ оставлен для корректной работы user_function_call
  */
 public function _initHooks()
 {
     remove_all_filters('woocommerce_cart_link');
     //удаляем ссылку на корзину
     remove_all_filters('woo_nav_after');
     //удаляем сам блок корзины
     remove_all_filters('woocommerce_simple_add_to_cart');
     remove_action('woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart', 30);
     /**
      * удаляем станицу корзины из базы
      */
     $cart_id = woocommerce_get_page_id('cart');
     if ($cart_id) {
         wp_delete_post($cart_id);
     }
     /**
      * Меняем работу ссылки добавления в корзину. Теперь она переадресовывает на партнёрку.
      */
     add_action('woocommerce_simple_add_to_cart', array($this, 'hook_change_link'), 1, 2);
     add_filter('woocommerce_loop_add_to_cart_link', array($this, 'hook_change_link'), 1, 2);
     /**
      * Подгружаем изображение из мета-поля поста
      */
     add_filter('woocommerce_single_product_image_html', array($this, 'hook_woocommerce_single_product_image_html'), 1, 2);
     add_action('woocommerce_placeholder_img', array($this, 'hook_woocommerce_placeholder_img'), 11, 1);
 }
Esempio n. 14
0
/**
 * Get theme option value
 * @param string $option
 * @return mix|boolean
 */
function ts_get_opt($option)
{
    global $ts_theme_options;
    $local = false;
    //get local from main shop page
    if (class_exists('WooCommerce') && (is_shop() || is_product_category() || is_product_tag())) {
        $shop_page = woocommerce_get_page_id('shop');
        if (!empty($shop_page)) {
            $value = ts_get_post_opt($option . '-local', (int) $shop_page);
            $local = true;
        }
        //get local from metaboxes for the post value and override if not empty
    } else {
        if (is_singular()) {
            $value = ts_get_post_opt($option . '-local');
            $local = true;
        }
    }
    //return local value if exists
    if ($local === true) {
        //if $value is an array we need to check if first element is not empty before we return $value
        $first_element = null;
        if (is_array($value)) {
            $first_element = reset($value);
        }
        if (is_string($value) && (strlen($value) > 0 || !empty($value)) || is_array($value) && !empty($first_element)) {
            return $value;
        }
    }
    if (isset($ts_theme_options[$option])) {
        return $ts_theme_options[$option];
    }
    return false;
}
/**
 * Prevent non-admin access to backend
 */
function woocommerce_prevent_admin_access()
{
    if (get_option('woocommerce_lock_down_admin') == 'yes' && !is_ajax() && !current_user_can('edit_posts')) {
        wp_safe_redirect(get_permalink(woocommerce_get_page_id('myaccount')));
        exit;
    }
}
Esempio n. 16
0
/**
 * Place a cart icon with number of items and total cost in the menu bar.
 */
function activello_woomenucart($menu, $args)
{
    // Check if WooCommerce is active and add a new item to a menu assigned to Primary Navigation Menu location
    if (!in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins'))) || 'primary' !== $args->theme_location) {
        return $menu;
    }
    ob_start();
    global $woocommerce;
    $viewing_cart = __('View your shopping cart', 'activello');
    $start_shopping = __('Start shopping', 'activello');
    $cart_url = $woocommerce->cart->get_cart_url();
    $shop_page_url = get_permalink(woocommerce_get_page_id('shop'));
    $cart_contents_count = $woocommerce->cart->cart_contents_count;
    $cart_contents = sprintf(_n('%d item', '%d items', $cart_contents_count, 'activello'), $cart_contents_count);
    $cart_total = $woocommerce->cart->get_cart_total();
    // Uncomment the line below to hide nav menu cart item when there are no items in the cart
    // if ( $cart_contents_count > 0 ) {
    if ($cart_contents_count == 0) {
        $menu_item = '<li class="menu-item"><a class="woo-menu-cart" href="' . $shop_page_url . '" title="' . $start_shopping . '">';
    } else {
        $menu_item = '<li class="menu-item"><a class="woo-menu-cart" href="' . $cart_url . '" title="' . $viewing_cart . '">';
    }
    $menu_item .= '<i class="fa fa-shopping-cart"></i> ';
    $menu_item .= $cart_contents . ' - ' . $cart_total;
    $menu_item .= '</a></li>';
    // Uncomment the line below to hide nav menu cart item when there are no items in the cart
    // }
    echo $menu_item;
    $social = ob_get_clean();
    return $menu . $social;
}
    function woocommerce_archive_product_content()
    {
        if (!is_search()) {
            $shop_page = get_post(woocommerce_get_page_id('shop'));
            $shop_page_title = apply_filters('the_title', get_option('woocommerce_shop_page_title') ? get_option('woocommerce_shop_page_title') : $shop_page->post_title);
            if (is_object($shop_page)) {
                $shop_page_content = $shop_page->post_content;
            }
        } else {
            $shop_page_title = __('Search Results:', 'woocommerce') . ' &ldquo;' . get_search_query() . '&rdquo;';
            if (get_query_var('paged')) {
                $shop_page_title .= ' &mdash; ' . __('Page', 'woocommerce') . ' ' . get_query_var('paged');
            }
            $shop_page_content = '';
        }
        ?>
<h1 class="page-title"><?php 
        echo $shop_page_title;
        ?>
</h1>

		<?php 
        if (!empty($shop_page_content)) {
            echo apply_filters('the_content', $shop_page_content);
        }
        ?>

		<?php 
        woocommerce_get_template_part('loop', 'shop');
        ?>

		<?php 
        do_action('woocommerce_pagination');
    }
Esempio n. 18
0
function wbst_woomenucart($menu, $args)
{
    // Check if WooCommerce is active and add a new item to a menu assigned to "Navbar Upper Right" (Primary Navigation Menu) location
    if (!in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins'))) || 'navbar_upper_right' !== $args->theme_location) {
        return $menu;
    }
    ob_start();
    global $woocommerce;
    $viewing_cart = __('View your shopping cart', 'wbst');
    $start_shopping = __('Start shopping', 'wbst');
    $cart_url = $woocommerce->cart->get_cart_url();
    $shop_page_url = get_permalink(woocommerce_get_page_id('shop'));
    $cart_contents_count = $woocommerce->cart->cart_contents_count;
    $cart_contents = sprintf(_n('%d item', '%d items', $cart_contents_count, 'wbst'), $cart_contents_count);
    $cart_total = $woocommerce->cart->get_cart_total();
    if ($cart_contents_count == 0) {
        $menu_item = '<li class="pull-right"><a class="woo-menu-cart" href="' . $shop_page_url . '" title="' . $start_shopping . '">';
    } else {
        $menu_item = '<li class="pull-right"><a class="woo-menu-cart" href="' . $cart_url . '" title="' . $viewing_cart . '">';
    }
    $menu_item .= '<i class="fa fa-shopping-cart"></i> ';
    $menu_item .= $cart_contents . ' - ' . $cart_total;
    $menu_item .= '</a></li>';
    echo $menu_item;
    $social = ob_get_clean();
    return $menu . $social;
}
 /**
  * called by the action get_sidebar. this is what places this into the theme
  */
 public static function get_sidebar($index = 'default-sidebar')
 {
     wp_reset_query();
     global $wp_query;
     $post = $wp_query->get_queried_object();
     if (is_post_type_archive('product')) {
         $post = get_post(woocommerce_get_page_id('shop'));
     }
     if (isset($post->ID)) {
         $selected_sidebar = get_post_meta($post->ID, '_selected_sidebar', true);
     } else {
         $selected_sidebar = "";
     }
     if ($selected_sidebar != '' && $selected_sidebar != "0") {
         echo "\n\n<!-- begin generated sidebar [{$selected_sidebar}] -->\n";
         //echo "<!-- selected: $selected_sidebar -->";
         dynamic_sidebar('ht_' . $selected_sidebar);
         echo "\n<!-- end generated sidebar -->\n\n";
     } else {
         //dynamic_sidebar($index);
         if (!function_exists('dynamic_sidebar') || !dynamic_sidebar($index)) {
             //echo '<div id="search" class="widget widget_search">';
             //get_search_form();
             //echo '</div>';
         }
     }
 }
Esempio n. 20
0
function ep_addVCCustomCss()
{
    $shortcodes_custom_css = '';
    //if is main-page
    if (is_page_template('main-page.php')) {
        $page_ids = get_all_page_ids();
        $current_page_id = get_the_ID();
        if (count($page_ids) > 0) {
            foreach ($page_ids as $page_id) {
                $separate_page = get_post_meta($page_id, "page-position-switch", true);
                if ($separate_page !== "0" && $page_id != $current_page_id) {
                    $shortcodes_custom_css .= get_post_meta($page_id, '_wpb_shortcodes_custom_css', true);
                }
            }
            if ($shortcodes_custom_css != '') {
                echo '<style type="text/css" data-type="vc_shortcodes-custom-css">';
                echo $shortcodes_custom_css;
                echo '</style>';
            }
        }
    } else {
        if (function_exists("is_shop")) {
            $shortcodes_custom_css = get_post_meta(woocommerce_get_page_id('shop'), '_wpb_shortcodes_custom_css', true);
            if (is_shop() && $shortcodes_custom_css != '') {
                echo '<style type="text/css" data-type="vc_shortcodes-custom-css">';
                echo $shortcodes_custom_css;
                echo '</style>';
            }
        }
    }
}
 /**
  * Disables the gateway under any of these conditions:
  * 1) If the cart does not contain a pre-order
  * 2) If the pre-order amount is charged upfront
  * 3) On the pay page
  *
  * @since 1.0
  * @return bool
  */
 public function is_available()
 {
     $is_available = true;
     // Backwards compatibility checking for payment page
     if (function_exists('is_checkout_pay_page')) {
         $pay_page = is_checkout_pay_page();
     } else {
         $pay_page = is_page(woocommerce_get_page_id('pay'));
     }
     // on checkout page
     if (!$pay_page || defined('WOOCOMMERCE_CHECKOUT') && WOOCOMMERCE_CHECKOUT) {
         // not available if the cart does not contain a pre-order
         if (WC_Pre_Orders_Cart::cart_contains_pre_order()) {
             // not available when the pre-order amount is charged upfront
             if (WC_Pre_Orders_Product::product_is_charged_upfront(WC_Pre_Orders_Cart::get_pre_order_product())) {
                 $is_available = false;
             }
         } else {
             $is_available = false;
         }
     } else {
         // not available on the pay page (for now)
         $is_available = false;
     }
     return $is_available;
 }
 /**
  * Output the shortcode.
  *
  * @access public
  * @param array $atts
  * @return void
  */
 public static function output($atts)
 {
     global $woocommerce;
     // Check checkout is configured correctly
     if (current_user_can('manage_options')) {
         $pay_page_id = woocommerce_get_page_id('pay');
         $thanks_page_id = woocommerce_get_page_id('thanks');
         $pay_page = get_permalink($pay_page_id);
         $thanks_page = get_permalink($thanks_page_id);
         if (!$pay_page_id || !$thanks_page_id || empty($pay_page) || empty($thanks_page)) {
             $woocommerce->add_error(sprintf(__('WooCommerce Config Error: The checkout thanks/pay pages are missing - these pages are required for the checkout to function correctly. Please configure the pages <a href="%s">here</a>.', 'woocommerce'), admin_url('admin.php?page=woocommerce_settings&tab=pages')));
         }
     }
     // Show non-cart errors
     $woocommerce->show_messages();
     // Check cart has contents
     if (sizeof($woocommerce->cart->get_cart()) == 0) {
         return;
     }
     // Calc totals
     $woocommerce->cart->calculate_totals();
     // Check cart contents for errors
     do_action('woocommerce_check_cart_items');
     // Get checkout object
     $checkout = $woocommerce->checkout();
     if (empty($_POST) && $woocommerce->error_count() > 0) {
         woocommerce_get_template('checkout/cart-errors.php', array('checkout' => $checkout));
     } else {
         $non_js_checkout = !empty($_POST['woocommerce_checkout_update_totals']) ? true : false;
         if ($woocommerce->error_count() == 0 && $non_js_checkout) {
             $woocommerce->add_message(__('The order totals have been updated. Please confirm your order by pressing the Place Order button at the bottom of the page.', 'woocommerce'));
         }
         woocommerce_get_template('checkout/form-checkout.php', array('checkout' => $checkout));
     }
 }
Esempio n. 23
0
 function members_only_price($price)
 {
     if (is_user_logged_in()) {
         return $price;
     } else {
         return '<p style="color:' . get_option('yith_hide_price_change_color') . '"><a style="display:inline; color:' . get_option('yith_hide_price_change_color') . '" href="' . get_permalink(function_exists('wc_get_page_id') ? wc_get_page_id('myaccount') : woocommerce_get_page_id('myaccount')) . '">' . get_option('yith_hide_price_link_text') . '</a> ' . get_option('yith_hide_price_text') . '</p>';
     }
 }
Esempio n. 24
0
 /**
  * init_taxonomy function.
  *
  * @access public
  */
 function init_taxonomy()
 {
     global $woocommerce;
     $shop_page_id = woocommerce_get_page_id('shop');
     $base_slug = $shop_page_id > 0 && get_page($shop_page_id) ? get_page_uri($shop_page_id) : 'shop';
     $category_base = get_option('woocommerce_prepend_shop_page_to_urls') == "yes" ? trailingslashit($base_slug) : '';
     register_taxonomy('product_brand', array('product'), apply_filters('register_taxonomy_product_brand', array('hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'label' => __('Brands', 'wc_brands'), 'labels' => array('name' => __('Brands', 'wc_brands'), 'singular_name' => __('Brand', 'wc_brands'), 'search_items' => __('Search Brands', 'wc_brands'), 'all_items' => __('All Brands', 'wc_brands'), 'parent_item' => __('Parent Brand', 'wc_brands'), 'parent_item_colon' => __('Parent Brand:', 'wc_brands'), 'edit_item' => __('Edit Brand', 'wc_brands'), 'update_item' => __('Update Brand', 'wc_brands'), 'add_new_item' => __('Add New Brand', 'wc_brands'), 'new_item_name' => __('New Brand Name', 'wc_brands')), 'show_ui' => true, 'show_in_nav_menus' => true, 'capabilities' => array('manage_terms' => 'manage_woocommerce_products', 'edit_terms' => 'manage_woocommerce_products', 'delete_terms' => 'manage_woocommerce_products', 'assign_terms' => 'manage_woocommerce_products'), 'rewrite' => array('slug' => $category_base . __('brand', 'wc_brands'), 'with_front' => false, 'hierarchical' => true))));
 }
Esempio n. 25
0
function wpgrade_custom_breadrumb_home_url()
{
    $shop_page_url = get_permalink(woocommerce_get_page_id('shop'));
    if (!empty($shop_page_url)) {
        return $shop_page_url;
    }
    return get_home_url();
}
Esempio n. 26
0
 function __construct()
 {
     parent::__construct();
     if (parent::useWoo()) {
         print '<script>window.location.href = "' . get_permalink(woocommerce_get_page_id('myaccount')) . '";</script>';
         exit;
     }
 }
Esempio n. 27
0
    public function widget($args, $instance)
    {
        echo apply_filters('kt_wg_before_widget', $args['before_widget']);
        $title = isset($instance['title']) && $instance['title'] ? esc_html($instance['title']) : '';
        $orderby = isset($instance['orderby']) && $instance['orderby'] ? esc_attr($instance['orderby']) : 'date';
        $order = isset($instance['order']) && $instance['order'] ? esc_attr($instance['order']) : 'desc';
        $posts_per_page = isset($instance['posts_per_page']) && $instance['posts_per_page'] ? intval($instance['posts_per_page']) : '3';
        $meta_query = WC()->query->get_meta_query();
        $params = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $posts_per_page, 'meta_query' => $meta_query, 'suppress_filter' => true, 'orderby' => $orderby, 'order' => $order);
        if ($title) {
            echo apply_filters('kt_wg_before_title', $args['before_title']);
            echo esc_html($title);
            echo apply_filters('kt_wg_after_title', $args['after_title']);
        }
        $product = new WP_Query($params);
        ?>
        <!-- SPECIAL -->
        <div class="block left-module">
            <div class="block_content">
                <ul class="products-block">
                    <?php 
        if ($product->have_posts()) {
            ?>
                            <?php 
            while ($product->have_posts()) {
                $product->the_post();
                ?>
                                <?php 
                wc_get_template_part('content', 'special-product-sidebar');
                ?>
                            <?php 
            }
            ?>
                    <?php 
        }
        wp_reset_query();
        wp_reset_postdata();
        $shop_page_url = get_permalink(woocommerce_get_page_id('shop'));
        ?>
                </ul>
                <div class="products-block">
                    <div class="products-block-bottom">
                        <a class="link-all" href="<?php 
        echo esc_url($shop_page_url);
        ?>
"><?php 
        esc_html_e('All Products', 'kutetheme');
        ?>
</a>
                    </div>
                </div>
            </div>                            
        </div>
        <!-- ./SPECIAL -->
        <?php 
        echo apply_filters('kt_wg_after_widget', $args['after_widget']);
    }
    /**
     * Output the shortcode.
     *
     * @access public
     * @param array $atts
     * @return void
     */
    public static function output($atts)
    {
        global $woocommerce;
        $woocommerce->nocache();
        if (!is_user_logged_in()) {
            return;
        }
        extract(shortcode_atts(array('order_count' => 10), $atts));
        $user_id = get_current_user_id();
        $order_id = isset($_GET['order']) ? $_GET['order'] : 0;
        $order = new WC_Order($order_id);
        if ($order_id == 0) {
            woocommerce_get_template('myaccount/my-orders.php', array('order_count' => 'all' == $order_count ? -1 : $order_count));
            return;
        }
        if ($order->user_id != $user_id) {
            echo '<div class="woocommerce-error">' . __('Invalid order.', 'woocommerce') . ' <a href="' . get_permalink(woocommerce_get_page_id('myaccount')) . '">' . __('My Account &rarr;', 'woocommerce') . '</a>' . '</div>';
            return;
        }
        $status = get_term_by('slug', $order->status, 'shop_order_status');
        echo '<p class="order-info">' . sprintf(__('Order <mark class="order-number">%s</mark> made on <mark class="order-date">%s</mark>', 'woocommerce'), $order->get_order_number(), date_i18n(get_option('date_format'), strtotime($order->order_date))) . '. ' . sprintf(__('Order status: <mark class="order-status">%s</mark>', 'woocommerce'), __($status->name, 'woocommerce')) . '.</p>';
        $notes = $order->get_customer_order_notes();
        if ($notes) {
            ?>
			<h2><?php 
            _e('Order Updates', 'woocommerce');
            ?>
</h2>
			<ol class="commentlist notes">
				<?php 
            foreach ($notes as $note) {
                ?>
				<li class="comment note">
					<div class="comment_container">
						<div class="comment-text">
							<p class="meta"><?php 
                echo date_i18n(__('l jS \\of F Y, h:ia', 'woocommerce'), strtotime($note->comment_date));
                ?>
</p>
							<div class="description">
								<?php 
                echo wpautop(wptexturize($note->comment_content));
                ?>
							</div>
			  				<div class="clear"></div>
			  			</div>
						<div class="clear"></div>
					</div>
				</li>
				<?php 
            }
            ?>
			</ol>
			<?php 
        }
        do_action('woocommerce_view_order', $order_id);
    }
 /**
  *
  */
 public function check_access()
 {
     $vendor_dashboard_page = Product_Vendor::$pv_options->get_option('vendor_dashboard_page');
     $shop_settings_page = Product_Vendor::$pv_options->get_option('shop_settings_page');
     if ((is_page($vendor_dashboard_page) || is_page($shop_settings_page)) && !is_user_logged_in()) {
         wp_redirect(get_permalink(woocommerce_get_page_id('myaccount')));
         exit;
     }
 }
Esempio n. 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 
    }