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; }
/** * When using geolocation via ajax, to bust cache, redirect if the location hash does not equal the querystring. * * This prevents caching of the wrong data for this request. */ public static function geolocation_ajax_redirect() { if ('geolocation_ajax' === get_option('woocommerce_default_customer_address') && !is_checkout() && !is_cart() && !is_account_page() && !is_ajax() && empty($_POST)) { $location_hash = self::geolocation_ajax_get_location_hash(); $current_hash = isset($_GET['v']) ? wc_clean($_GET['v']) : ''; if (empty($current_hash) || $current_hash !== $location_hash) { global $wp; $redirect_url = trailingslashit(home_url($wp->request)); if (!get_option('permalink_structure')) { $redirect_url = add_query_arg($wp->query_string, '', $redirect_url); } $redirect_url = add_query_arg('v', $location_hash, remove_query_arg('v', $redirect_url)); wp_safe_redirect(esc_url_raw($redirect_url), 307); exit; } } }
function flatsome_admin_bar_helper() { global $wp_admin_bar; $optionUrl = get_admin_url() . 'themes.php?page=optionsframework'; $adminUrl = get_admin_url(); if (is_category() || is_home()) { $wp_admin_bar->add_menu(array('parent' => false, 'id' => 'admin_bar_helper', 'title' => 'Blog Layout', 'href' => $optionUrl . '&tab=of-option-blog')); } if (ux_is_woocommerce_active()) { if (is_checkout() || is_cart()) { $wp_admin_bar->add_menu(array('parent' => false, 'id' => 'admin_bar_helper', 'title' => 'Checkout Settings', 'href' => $adminUrl . 'admin.php?page=wc-settings&tab=checkout')); } if (is_product()) { $wp_admin_bar->add_menu(array('parent' => false, 'id' => 'admin_bar_helper', 'title' => 'Product Page Layout', 'href' => $optionUrl . '&tab=of-option-productpage')); } if (is_account_page()) { $wp_admin_bar->add_menu(array('parent' => false, 'id' => 'admin_bar_helper', 'title' => 'My Account Page', 'href' => $adminUrl . 'admin.php?page=wc-settings&tab=account')); } if (is_shop() || is_product_category()) { $wp_admin_bar->add_menu(array('parent' => false, 'id' => 'admin_bar_helper', 'title' => 'Shop Settings')); $wp_admin_bar->add_menu(array('parent' => 'admin_bar_helper', 'id' => 'admin_bar_helper_flatsome', 'title' => 'Category Page Layout', 'href' => $optionUrl . '&tab=of-option-categorypage')); $wp_admin_bar->add_menu(array('parent' => 'admin_bar_helper', 'id' => 'admin_bar_helper_woocommerce', 'title' => 'Shop Page Display', 'href' => $adminUrl . 'admin.php?page=wc-settings&tab=products§ion=display')); } } }
/** * Add the scripts */ public function add_scripts() { if (is_account_page() || is_order_received_page() || $this->is_woocommerce_tracking_page()) { wp_enqueue_script('woocommerce-delivery-notes-print-link', WooCommerce_Delivery_Notes::$plugin_url . 'js/jquery.print-link.js', array('jquery')); wp_enqueue_script('woocommerce-delivery-notes-theme', WooCommerce_Delivery_Notes::$plugin_url . 'js/theme.js', array('jquery', 'woocommerce-delivery-notes-print-link')); } }
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; }
function woodrobe_body_class($classes) { if (is_woocommerce() || is_cart() || is_checkout() || is_account_page()) { $classes[] = 'woodrobe'; } return $classes; }
/** * Remove key and login from querystring, set cookie, and redirect to account page to show the form. */ public static function redirect_reset_password_link() { if (is_account_page() && !empty($_GET['key']) && !empty($_GET['login'])) { $value = sprintf('%s:%s', wp_unslash($_GET['login']), wp_unslash($_GET['key'])); WC_Shortcode_My_Account::set_reset_password_cookie($value); wp_safe_redirect(add_query_arg('show-reset-form', 'true', wc_lostpassword_url())); exit; } }
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; }
function kadence_sidebar_id() { if (is_front_page()) { global $virtue; if (!empty($virtue['home_sidebar'])) { $sidebar = $virtue['home_sidebar']; } else { $sidebar = 'sidebar-primary'; } } else { if (class_exists('woocommerce') and is_shop() || is_product_category() || is_product_tag()) { global $virtue; if (!empty($virtue['shop_sidebar'])) { $sidebar = $virtue['shop_sidebar']; } else { $sidebar = 'sidebar-primary'; } } elseif (class_exists('woocommerce') and is_account_page()) { get_template_part('templates/account', 'sidebar'); $sidebar = ""; } elseif (is_page_template('page-blog.php') || is_page_template('page-sidebar.php') || is_page_template('page-feature-sidebar.php') || get_post_type() == 'post') { global $post; $sidebar_name = get_post_meta($post->ID, '_kad_sidebar_choice', true); if (!empty($sidebar_name)) { $sidebar = $sidebar_name; } else { $sidebar = 'sidebar-primary'; } } else { if (is_archive()) { $sidebar = 'sidebar-primary'; } else { if (is_category()) { $sidebar = 'sidebar-primary'; } elseif (is_tag()) { $sidebar = 'sidebar-primary'; } elseif (is_post_type_archive()) { $sidebar = 'sidebar-primary'; } elseif (is_day()) { $sidebar = 'sidebar-primary'; } elseif (is_month()) { $sidebar = 'sidebar-primary'; } elseif (is_year()) { $sidebar = 'sidebar-primary'; } elseif (is_author()) { $sidebar = 'sidebar-primary'; } elseif (is_search()) { $sidebar = 'sidebar-primary'; } else { $sidebar = 'sidebar-primary'; } } } } return apply_filters('kadence_sidebar_id', $sidebar); }
function kt_wc_print_notices() { if (class_exists('woocommerce')) { if (!is_shop() and !is_woocommerce() and !is_cart() and !is_checkout() and !is_account_page()) { echo '<div class="container">'; echo do_shortcode('[woocommerce_messages]'); echo '</div>'; } } }
/** * Front end styles and scripts. * * @since 1.0.0 * @access public * @return void */ public static function frontend_scripts() { $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; // My Account Page if (is_account_page()) { //wp_register_style( 'wcso-css', WCSO_PLUGIN_URL . '/assets/css/wcso-style' . $suffix . '.css', false, WCSO_VERSION, 'all' ); wp_register_style('wcso-css', WCSO_PLUGIN_URL . '/assets/css/wcso-style.css', false, WCSO_VERSION, 'all'); wp_enqueue_style('wcso-css'); } }
/** * Changes page title on view subscription page * * @param string $title original title * @return string changed title */ public function change_endpoint_title($title) { if (in_the_loop() && is_account_page()) { foreach ($this->query_vars as $key => $query_var) { if ($this->is_query($query_var)) { $title = $this->get_endpoint_title($key); } } } return $title; }
function change_my_products_endpoint_title($title) { global $wp_query; $is_endpoint = isset($wp_query->query_vars['wcj-my-products']); if ($is_endpoint && !is_admin() && is_main_query() && in_the_loop() && is_account_page()) { // New page title. $title = __('Products', 'woocommerce-jetpack'); remove_filter('the_title', array($this, 'change_my_products_endpoint_title')); } return $title; }
function cuttz_woo_pages_customization() { if (is_product() || is_checkout() || is_account_page()) { add_filter('genesis_pre_get_option_site_layout', '__genesis_return_full_width_content'); } // Disable the custom widget areas on certain pages if (is_woocommerce() || is_cart() || is_checkout() || is_account_page()) { remove_action('genesis_before_header', 'cuttz_sidebar_before_header'); remove_action('genesis_after_header', 'cuttz_sidebar_after_header'); remove_action('genesis_before_footer', 'cuttz_sidebar_above_footer', 5); } }
/** * Register and enqueues public-facing style sheet and JavaScript files. */ public function enqueue_scripts() { // Load scripts only in checkout. if (is_checkout() || is_account_page()) { // Get plugin settings. $settings = get_option('wcbcf_settings'); // Call jQuery. wp_enqueue_script('jquery'); // Fix checkout fields. wp_enqueue_script('woocommerce-extra-checkout-fields-for-brazil-front', plugins_url('assets/js/frontend/frontend.min.js', plugin_dir_path(__FILE__)), array('jquery'), Extra_Checkout_Fields_For_Brazil::VERSION, true); wp_localize_script('woocommerce-extra-checkout-fields-for-brazil-front', 'wcbcf_public_params', array('state' => __('State', 'woocommerce-extra-checkout-fields-for-brazil'), 'required' => __('required', 'woocommerce-extra-checkout-fields-for-brazil'), 'mailcheck' => isset($settings['mailcheck']) ? 'yes' : 'no', 'maskedinput' => isset($settings['maskedinput']) ? 'yes' : 'no', 'addresscomplete' => isset($settings['addresscomplete']) ? 'yes' : 'no', 'person_type' => $settings['person_type'], 'only_brazil' => isset($settings['only_brazil']) ? 'yes' : 'no')); } }
/** * Get sidebar settings based on the page type * * @return array */ public function sidebar_options() { if (is_home()) { $sidebars = array('global' => '1', 'sidebar_1' => Avada()->settings->get('blog_archive_sidebar'), 'sidebar_2' => Avada()->settings->get('blog_archive_sidebar_2'), 'position' => Avada()->settings->get('blog_sidebar_position')); } elseif (function_exists('is_bbpress') && is_bbpress()) { $sidebars = array('global' => Avada()->settings->get('bbpress_global_sidebar'), 'sidebar_1' => Avada()->settings->get('ppbress_sidebar'), 'sidebar_2' => Avada()->settings->get('ppbress_sidebar_2'), 'position' => Avada()->settings->get('bbpress_sidebar_position')); if (bbp_is_forum_archive() || bbp_is_topic_archive() || bbp_is_user_home() || bbp_is_search()) { $sidebars = array('global' => '1', 'sidebar_1' => Avada()->settings->get('ppbress_sidebar'), 'sidebar_2' => Avada()->settings->get('ppbress_sidebar_2'), 'position' => Avada()->settings->get('bbpress_sidebar_position')); } } elseif (function_exists('is_buddypress') && is_buddypress()) { $sidebars = array('global' => Avada()->settings->get('bbpress_global_sidebar'), 'sidebar_1' => Avada()->settings->get('ppbress_sidebar'), 'sidebar_2' => Avada()->settings->get('ppbress_sidebar_2'), 'position' => Avada()->settings->get('bbpress_sidebar_position')); } elseif (class_exists('WooCommerce') && (is_product() || is_shop())) { $sidebars = array('global' => Avada()->settings->get('woo_global_sidebar'), 'sidebar_1' => Avada()->settings->get('woo_sidebar'), 'sidebar_2' => Avada()->settings->get('woo_sidebar_2'), 'position' => Avada()->settings->get('woo_sidebar_position')); } elseif (class_exists('WooCommerce') && (is_product_category() || is_product_tag())) { $sidebars = array('global' => '1', 'sidebar_1' => Avada()->settings->get('woocommerce_archive_sidebar'), 'sidebar_2' => Avada()->settings->get('woocommerce_archive_sidebar_2'), 'position' => Avada()->settings->get('woo_sidebar_position')); } elseif (is_page()) { $sidebars = array('global' => Avada()->settings->get('pages_global_sidebar'), 'sidebar_1' => Avada()->settings->get('pages_sidebar'), 'sidebar_2' => Avada()->settings->get('pages_sidebar_2'), 'position' => Avada()->settings->get('default_sidebar_pos')); } elseif (is_single()) { $sidebars = array('global' => Avada()->settings->get('posts_global_sidebar'), 'sidebar_1' => Avada()->settings->get('posts_sidebar'), 'sidebar_2' => Avada()->settings->get('posts_sidebar_2'), 'position' => Avada()->settings->get('blog_sidebar_position')); if (is_singular('avada_portfolio')) { $sidebars = array('global' => Avada()->settings->get('portfolio_global_sidebar'), 'sidebar_1' => Avada()->settings->get('portfolio_sidebar'), 'sidebar_2' => Avada()->settings->get('portfolio_sidebar_2'), 'position' => Avada()->settings->get('portfolio_sidebar_position')); } else { if (is_singular('tribe_events') || is_singular('tribe_organizer') || is_singular('tribe_venue')) { $sidebars = array('global' => Avada()->settings->get('ec_global_sidebar'), 'sidebar_1' => Avada()->settings->get('ec_sidebar'), 'sidebar_2' => Avada()->settings->get('ec_sidebar_2'), 'position' => Avada()->settings->get('ec_sidebar_pos')); } } if (is_singular('tribe_organizer') || is_singular('tribe_venue')) { $sidebars['global'] = 1; } } elseif (is_archive()) { $sidebars = array('global' => '1', 'sidebar_1' => Avada()->settings->get('blog_archive_sidebar'), 'sidebar_2' => Avada()->settings->get('blog_archive_sidebar_2'), 'position' => Avada()->settings->get('blog_sidebar_position')); if (is_post_type_archive('avada_portfolio') || is_tax('portfolio_category') || is_tax('portfolio_skills') || is_tax('portfolio_tags')) { $sidebars = array('global' => '1', 'sidebar_1' => Avada()->settings->get('portfolio_archive_sidebar'), 'sidebar_2' => Avada()->settings->get('portfolio_archive_sidebar_2'), 'position' => Avada()->settings->get('portfolio_sidebar_position')); } } elseif (is_search()) { $sidebars = array('global' => '1', 'sidebar_1' => Avada()->settings->get('search_sidebar'), 'sidebar_2' => Avada()->settings->get('search_sidebar_2'), 'position' => Avada()->settings->get('search_sidebar_position')); } else { $sidebars = array('global' => Avada()->settings->get('pages_global_sidebar'), 'sidebar_1' => Avada()->settings->get('pages_sidebar'), 'sidebar_2' => Avada()->settings->get('pages_sidebar_2'), 'position' => Avada()->settings->get('default_sidebar_pos')); } if (class_exists('Tribe__Events__Main') && is_events_archive()) { $sidebars = array('global' => '1', 'sidebar_1' => Avada()->settings->get('ec_sidebar'), 'sidebar_2' => Avada()->settings->get('ec_sidebar_2'), 'position' => Avada()->settings->get('ec_sidebar_pos')); } // Remove sidebars from the certain woocommerce pages if (class_exists('WooCommerce')) { if (is_cart() || is_checkout() || is_account_page() || get_option('woocommerce_thanks_page_id') && is_page(get_option('woocommerce_thanks_page_id'))) { $sidebars = array(); } } return $sidebars; }
/** * Render social login buttons on frontend * * @since 1.0 */ public function render_social_login_buttons() { if (!is_checkout() && !is_account_page()) { return; } if (is_checkout() && !$this->is_displayed_on('checkout')) { return; } if (is_account_page() && !$this->is_displayed_on('my_account')) { return; } $return_url = is_checkout() ? WC()->cart->get_checkout_url() : wc_get_page_permalink('myaccount'); woocommerce_social_login_buttons($return_url); }
/** * Handle redirects before content is output - hooked into template_redirect so is_page works. * * @access public * @return void */ function woocommerce_template_redirect() { global $woocommerce, $wp_query; // When default permalinks are enabled, redirect shop page to post type archive url if (!empty($_GET['page_id']) && get_option('permalink_structure') == "" && $_GET['page_id'] == woocommerce_get_page_id('shop')) { wp_safe_redirect(get_post_type_archive_link('product')); exit; } elseif (is_page(woocommerce_get_page_id('checkout')) && sizeof($woocommerce->cart->get_cart()) == 0) { wp_redirect(get_permalink(woocommerce_get_page_id('cart'))); exit; } elseif (is_page(woocommerce_get_page_id('pay')) && !isset($_GET['order'])) { wp_redirect(get_permalink(woocommerce_get_page_id('checkout'))); exit; } elseif (!is_user_logged_in() && (is_page(woocommerce_get_page_id('edit_address')) || is_page(woocommerce_get_page_id('view_order')) || is_page(woocommerce_get_page_id('change_password')))) { wp_redirect(get_permalink(woocommerce_get_page_id('myaccount'))); exit; } elseif (is_page(woocommerce_get_page_id('logout'))) { wp_redirect(str_replace('&', '&', wp_logout_url(get_permalink(woocommerce_get_page_id('myaccount'))))); exit; } elseif (is_search() && is_post_type_archive('product')) { if ($wp_query->post_count == 1) { $product = get_product($wp_query->post); if ($product->is_visible()) { wp_safe_redirect(get_permalink($product->id), 302); } exit; } } elseif (get_option('woocommerce_force_ssl_checkout') == 'yes' && !is_ssl()) { if (is_checkout() || is_account_page() || apply_filters('woocommerce_force_ssl_checkout', false)) { if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) { wp_safe_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI'])); exit; } else { wp_safe_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); exit; } } } elseif (get_option('woocommerce_force_ssl_checkout') == 'yes' && get_option('woocommerce_unforce_ssl_checkout') == 'yes' && is_ssl() && $_SERVER['REQUEST_URI'] && !is_checkout() && !is_page(woocommerce_get_page_id('thanks')) && !is_ajax() && !is_account_page() && apply_filters('woocommerce_unforce_ssl_checkout', true)) { if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) { wp_safe_redirect(preg_replace('|^https://|', 'http://', $_SERVER['REQUEST_URI'])); exit; } else { wp_safe_redirect('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); exit; } } elseif (is_checkout()) { ob_start(); } }
/** * Delete card * @return [type] */ function woocommerce_stripe_handle_delete_card() { global $woocommerce; if (!isset($_POST['stripe_delete_card']) || !is_account_page()) { return; } if (!is_user_logged_in() || !wp_verify_nonce($_POST['_wpnonce'], "stripe_del_card")) { wp_die(__('Unable to verify deletion, please try again', 'wc_stripe')); } $credit_card = $credit_cards[(int) $_POST['stripe_delete_card']]; delete_user_meta(get_current_user_id(), '_stripe_customer_id', $credit_card); $woocommerce->add_message(__('Card deleted.', 'wc_stripe')); wp_safe_redirect(get_permalink(woocommerce_get_page_id('myaccount'))); exit; }
function shop_navigation() { if (is_woocommerce() || is_cart() || is_checkout() || is_account_page()) { ?> <div id="shop-nav"> <div class="left-sec"> <ul> <li><a href="#">FAQ's</a></li> <li><a href="/my-account">My Account</a></li> </ul> </div> <div class="right-sec"> <div class="cart"> <?php if (is_cart()) { ?> <a href="/shop"> <span class="glyphicon glyphicon-shopping-cart"></span> <small>Back to Shop</small> </a> <?php } else { ?> <a class="cart-contents" href="<?php echo !empty(WC()->cart->cart_contents) ? '/cart' : '/shop'; ?> "> <span class="glyphicon glyphicon-shopping-cart"></span> <?php if (!empty(WC()->cart->cart_contents)) { ?> <?php echo WC()->cart->get_cart_contents_count(); ?> <?php } ?> </a> <?php } ?> </div> </div> </div> <?php } }
/** * Make a card as default method */ public function default_card() { if (!isset($_POST['stripe_default_card']) || !is_account_page()) { return; } $stripe_customer = new WC_Stripe_Customer(get_current_user_id()); $stripe_customer_id = $stripe_customer->get_id(); $default_source = sanitize_text_field($_POST['stripe_default_card']); if (!is_user_logged_in() || !$stripe_customer_id || !wp_verify_nonce($_POST['_wpnonce'], "stripe_default_card")) { wp_die(__('Unable to make default card, please try again', 'woocommerce-gateway-stripe')); } if (!$stripe_customer->set_default_card($default_source)) { wc_add_notice(__('Unable to update default card.', 'woocommerce-gateway-stripe'), 'error'); } else { wc_add_notice(__('Default card updated.', 'woocommerce-gateway-stripe'), 'success'); } }
/** * Delete a card */ public function delete_card() { if (!isset($_POST['stripe_delete_card']) || !is_account_page()) { return; } $credit_cards = get_user_meta(get_current_user_id(), '_stripe_customer_id', false); if (empty($credit_cards)) { return; } if (isset($_POST['stripe_delete_card']) && wp_verify_nonce($_POST['_wpnonce'], "stripe_del_card")) { for ($i = 0; $i < count($credit_cards); $i++) { if ($credit_cards[$i]['customer_id'] == $_POST['stripe_delete_card']) { delete_user_meta(get_current_user_id(), '_stripe_customer_id', $credit_cards[$i]); } } } }
/** * Register the integration conditions with WooSidebars. * @since 1.1.0 * @param array $conditions The existing array of conditions. * @return array The modified array of conditions. */ public function register_conditions($conditions) { global $post; if (function_exists('is_woocommerce') && !is_woocommerce()) { return $conditions; } $integration = array(); if (function_exists('is_shop') && is_shop()) { $integration[] = 'wc-shop_page'; } if (function_exists('is_product_category') && is_product_category()) { $integration[] = 'wc-product_category'; } if (function_exists('is_product_tag') && is_product_tag()) { $integration[] = 'wc-product_tag'; } if (function_exists('is_cart') && is_cart()) { $integration[] = 'wc-cart'; } if (function_exists('is_checkout') && is_checkout()) { $integration[] = 'wc-checkout'; } if (function_exists('is_account_page') && is_account_page()) { $integration[] = 'wc-account'; } if (function_exists('is_product') && is_product()) { $integration[] = 'wc-product'; $categories = get_the_terms($post->ID, 'product_cat'); if (!is_wp_error($categories) && is_array($categories) && count($categories) > 0) { foreach ($categories as $k => $v) { $integration[] = 'in-term-' . esc_attr($v->term_id); } } $tags = get_the_terms($post->ID, 'product_tag'); if (!is_wp_error($tags) && is_array($tags) && count($tags) > 0) { foreach ($tags as $k => $v) { $integration[] = 'in-term-' . esc_attr($v->term_id); } } } $integration[] = $conditions[count($conditions) - 1]; array_splice($conditions, count($conditions), 0, $integration); return $conditions; }
function widget($args, $options) { if (!empty($args)) { extract($args); } $loggedin = ShoppCustomer()->loggedin(); // Hide login form on account page when not logged in to prevent duplicate forms if (is_account_page() && !$loggedin) { return ''; } $defaults = array('title' => $loggedin ? __('Your Account', 'Shopp') : __('Login', 'Shopp')); $options = array_merge($defaults, $options); extract($options); $title = $before_title . $title . $after_title; remove_filter('shopp_show_account_errors', array($this, 'showerrors')); $Page = new ShoppAccountPage(); $menu = $Page->content('', 'widget'); echo $before_widget . $title . $menu . $after_widget; }
/** * Delete a card */ public function delete_card() { if (!isset($_POST['stripe_delete_card']) || !is_account_page()) { return; } if (!is_user_logged_in() || !($customer_id = get_user_meta(get_current_user_id(), '_stripe_customer_id', true)) || !is_string($customer_id) || !wp_verify_nonce($_POST['_wpnonce'], "stripe_del_card")) { wp_die(__('Unable to verify deletion, please try again', 'woocommerce-gateway-stripe')); } $stripe = new WC_Gateway_Stripe(); $result = $stripe->stripe_request(array(), 'customers/' . $customer_id . '/cards/' . sanitize_text_field($_POST['stripe_delete_card']), 'DELETE'); delete_transient('stripe_cards_' . $customer_id); if (is_wp_error($result)) { wc_add_notice(__('Unable to delete card.', 'woocommerce-gateway-stripe'), 'error'); } else { wc_add_notice(__('Card deleted.', 'woocommerce-gateway-stripe'), 'success'); } wp_safe_redirect(apply_filters('wc_stripe_manage_saved_cards_url', get_permalink(woocommerce_get_page_id('myaccount')))); exit; }
/** * Return page details */ function get_page_details() { global $sa_smart_offers; if (is_home() || is_front_page()) { $where = "home"; $where_url = home_url(); } elseif (is_cart()) { $where = "cart"; $where_url = $sa_smart_offers->global_wc()->cart->get_cart_url(); } elseif (is_account_page()) { $where = "myaccount"; $where_url = get_permalink(woocommerce_get_page_id('myaccount')); } else { $where = "any"; } if ($sa_smart_offers->is_wc_gte_21()) { global $wp; if (is_checkout()) { if (isset($wp->query_vars['order-received'])) { $where = "thankyou"; } else { $where = "checkout"; $where_url = $sa_smart_offers->global_wc()->cart->get_checkout_url(); } } } else { if (is_checkout()) { $where = "checkout"; $where_url = $sa_smart_offers->global_wc()->cart->get_checkout_url(); } elseif (function_exists('is_order_received_page') && is_order_received_page() || is_page(woocommerce_get_page_id('thanks'))) { $where = "thankyou"; } } if ($where == "thankyou" || $where == "any") { $where_url = isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on" ? "https://" : "http://"; if ($_SERVER["SERVER_PORT"] != "80") { $where_url .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; } else { $where_url .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; } } return array($where, $where_url); }
function xt_woocommerce_login_redirect() { if (is_account_page() && !is_user_logged_in()) { global $wp; if (is_page(wc_get_page_id('myaccount')) && isset($wp->query_vars['lost-password'])) { return false; } $pages = get_posts(array('post_type' => 'page', 'meta_key' => '_wp_page_template', 'meta_value' => 'tpl-login.php')); if (!empty($pages)) { foreach ($pages as $page) { $login_url = get_permalink($page->ID); $myaccount_page_id = get_option('woocommerce_myaccount_page_id'); if ($myaccount_page_id) { $myaccount_page_url = get_permalink($myaccount_page_id); $login_url = add_query_arg(array('redirect' => urlencode($myaccount_page_url)), $login_url); } wp_redirect($login_url); exit; } } } }
/** * Set a default or selected sidebar for WooCommerce pages and archives */ public function set_sidebar() { if (!(is_woocommerce() || is_checkout() || is_cart() || is_account_page())) { return; } $layout = ''; // archives and single if (is_woocommerce() && !is_product()) { $layout = Bunyad::posts()->meta('layout_style', wc_get_page_id('shop')); } // checkout, cart, account and single product pages (not enabled atm) if (is_checkout() || is_cart() || is_account_page() || is_product()) { // set layout $layout = Bunyad::posts()->meta('layout_style'); } // have a layout setting? if ($layout) { Bunyad::core()->set_sidebar($layout == 'full' ? 'none' : $layout); } else { // use default sidebar setting for WooCommerce Bunyad::core()->set_sidebar(Bunyad::options()->woocommerce_sidebar); } }
/** * Register and enqueues public-facing style sheet and JavaScript files. */ public function enqueue_scripts() { $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; wp_register_script('jquery-maskedinput', plugins_url('assets/js/jquery-maskedinput/jquery.maskedinput' . $suffix . '.js', plugin_dir_path(__FILE__)), array('jquery'), '1.4.1', true); wp_register_script('mailcheck', plugins_url('assets/js/mailcheck/mailcheck' . $suffix . '.js', plugin_dir_path(__FILE__)), array('jquery'), '1.1.1', true); // Load scripts only in checkout. if (is_checkout() || is_account_page()) { // Get plugin settings. $settings = get_option('wcbcf_settings'); // Fix checkout fields. wp_enqueue_script('woocommerce-extra-checkout-fields-for-brazil-front', plugins_url('assets/js/frontend/frontend' . $suffix . '.js', plugin_dir_path(__FILE__)), array('jquery', 'jquery-maskedinput', 'mailcheck'), Extra_Checkout_Fields_For_Brazil::VERSION, true); wp_localize_script('woocommerce-extra-checkout-fields-for-brazil-front', 'wcbcf_public_params', array('state' => esc_js(__('State', 'woocommerce-extra-checkout-fields-for-brazil')), 'required' => esc_js(__('required', 'woocommerce-extra-checkout-fields-for-brazil')), 'mailcheck' => isset($settings['mailcheck']) ? 'yes' : 'no', 'maskedinput' => isset($settings['maskedinput']) ? 'yes' : 'no', 'addresscomplete' => isset($settings['addresscomplete']) ? 'yes' : 'no', 'person_type' => absint($settings['person_type']), 'only_brazil' => isset($settings['only_brazil']) ? 'yes' : 'no')); } }
/** * Modify the subtotal of order-items (order-details.php) depending on the bundles's pricing strategy. * * @param string $subtotal the item subtotal * @param array $item the items * @param WC_Order $order the order * @return string modified subtotal string. */ function woo_bundles_order_item_subtotal($subtotal, $item, $order) { global $woocommerce_bundles; // If it's a bundled item if (isset($item['bundled_by'])) { // find bundle parent $parent_item = $this->get_bundled_order_item_container($item, $order); $per_product_pricing = !empty($parent_item) && isset($parent_item['per_product_pricing']) ? $parent_item['per_product_pricing'] : get_post_meta($parent_item['product_id'], '_per_product_pricing_active', true); if ($per_product_pricing == 'no' || isset($parent_item['composite_parent'])) { return ''; } else { /*------------------------------------------------------------------------------------------------------------------------------------------*/ /* woocommerce_order_formatted_line_subtotal is filtered by WC_Subscriptions_Order::get_formatted_line_total. /* The filter is temporarily unhooked internally, when the function calls get_formatted_line_subtotal to fetch the recurring price string. /* Here, we check whether it's unhooked to avoid displaying the "Subtotal" string next to the recurring part. /*------------------------------------------------------------------------------------------------------------------------------------------*/ if (function_exists('is_account_page') && is_account_page() || function_exists('is_checkout') && is_checkout()) { $wrap_start = ''; $wrap_end = ''; } else { $wrap_start = '<small>'; $wrap_end = '</small>'; } if ($woocommerce_bundles->compatibility->is_item_subscription($order, $item) && !has_filter('woocommerce_order_formatted_line_subtotal', 'WC_Subscriptions_Order::get_formatted_line_total')) { return $subtotal; } else { return $wrap_start . __('Subtotal', 'woocommerce-product-bundles') . ': ' . $subtotal . $wrap_end; } } } // If it's a bundle (parent item) if (!isset($item['bundled_by']) && isset($item['stamp'])) { if (isset($item['subtotal_updated'])) { return $subtotal; } $contains_recurring_fees = false; foreach ($order->get_items() as $order_item_id => $order_item) { if (isset($order_item['bundle_cart_key'])) { $is_child = isset($item['bundled_items']) && in_array($order_item['bundle_cart_key'], maybe_unserialize($item['bundled_items'])) ? true : false; } else { $is_child = isset($order_item['stamp']) && $order_item['stamp'] == $item['stamp'] && isset($order_item['bundled_by']) ? true : false; } if ($is_child) { if ($woocommerce_bundles->compatibility->is_item_subscription($order, $order_item)) { if ($order_item['subscription_recurring_amount'] > 0) { $contains_recurring_fees = true; } } $item['line_subtotal'] += $order_item['line_subtotal']; $item['line_subtotal_tax'] += $order_item['line_subtotal_tax']; } } $item['subtotal_updated'] = 'yes'; $subtotal = $order->get_formatted_line_subtotal($item); if ($item['per_product_pricing'] === 'yes' && $contains_recurring_fees) { $subtotal .= __(' up front with recurring fees <small>(see below)</small>', 'woocommerce-product-bundles'); } } return $subtotal; }