get_woocommerce_currency_symbol(), 'countries' => json_encode(woocommerce_countries::$states), 'select_state_text' => __('Select a state…', 'woothemes'), 'state_text' => __('state', 'woothemes'), 'variation_not_available_text' => __('This variation is not available.', 'woothemes'), 'plugin_url' => woocommerce::plugin_url(), 'ajax_url' => admin_url('admin-ajax.php'), 'get_variation_nonce' => wp_create_nonce("get-variation"), 'add_to_cart_nonce' => wp_create_nonce("add-to-cart"), 'update_order_review_nonce' => wp_create_nonce("update-order-review"), 'option_guest_checkout' => get_option('woocommerce_enable_guest_checkout'), 'checkout_url' => admin_url('admin-ajax.php?action=woocommerce-checkout') ); if (isset($_SESSION['min_price'])) : $params['min_price'] = $_SESSION['min_price']; endif; if (isset($_SESSION['max_price'])) : $params['max_price'] = $_SESSION['max_price']; endif; if ( is_page(get_option('woocommerce_checkout_page_id')) || is_page(get_option('woocommerce_pay_page_id')) ) : $params['is_checkout'] = 1; else : $params['is_checkout'] = 0; endif; wp_localize_script( 'woocommerce', 'params', $params ); } add_action('template_redirect', 'woocommerce_frontend_scripts'); /** * Demo Banner * * Adds a demo store banner to the site if enabled **/ function woocommerce_demo_store() { if (get_option('woocommerce_demo_store')=='yes') : echo '
'.__('This is a demo store for testing purposes — no orders shall be fulfilled.', 'woothemes').'
'; endif; } /** * Sharethis * * Adds social sharing code **/ function woocommerce_sharethis() { if (is_single() && get_option('woocommerce_sharethis')) : if (is_ssl()) : $sharethis = 'https://ws.sharethis.com/button/buttons.js'; else : $sharethis = 'http://w.sharethis.com/button/buttons.js'; endif; echo ''; endif; } /** * WooCommerce conditionals **/ function is_cart() { if (is_page(get_option('woocommerce_cart_page_id'))) return true; return false; } function is_checkout() { if ( is_page(get_option('woocommerce_checkout_page_id')) ) return true; return false; } if (!function_exists('is_ajax')) { function is_ajax() { if ( isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ) return true; return false; } } /** * Force SSL (if enabled) **/ function woocommerce_force_ssl() { if (is_checkout() && !is_ssl()) : wp_redirect( str_replace('http:', 'https:', get_permalink(get_option('woocommerce_checkout_page_id'))), 301 ); exit; endif; } function woocommerce_force_ssl_images( $content ) { if (is_ssl()) : if (is_array($content)) : $content = array_map('woocommerce_force_ssl_images', $content); else : $content = str_replace('http:', 'https:', $content); endif; endif; return $content; } add_filter('post_thumbnail_html', 'woocommerce_force_ssl_images'); add_filter('widget_text', 'woocommerce_force_ssl_images'); add_filter('wp_get_attachment_url', 'woocommerce_force_ssl_images'); add_filter('wp_get_attachment_image_attributes', 'woocommerce_force_ssl_images'); add_filter('wp_get_attachment_url', 'woocommerce_force_ssl_images'); /** * Currency **/ function get_woocommerce_currency_symbol() { $currency = get_option('woocommerce_currency'); $currency_symbol = ''; switch ($currency) : case 'AUD' : case 'BRL' : case 'CAD' : case 'MXN' : case 'NZD' : case 'HKD' : case 'SGD' : case 'USD' : $currency_symbol = '$'; break; case 'EUR' : $currency_symbol = '€'; break; case 'JPY' : $currency_symbol = '¥'; break; case 'CZK' : case 'DKK' : case 'HUF' : case 'ILS' : case 'MYR' : case 'NOK' : case 'PHP' : case 'PLN' : case 'SEK' : case 'CHF' : case 'TWD' : case 'THB' : $currency_symbol = $currency; break; case 'GBP' : default : $currency_symbol = '£'; break; endswitch; return apply_filters('woocommerce_currency_symbol', $currency_symbol, $currency); } /** * Price Formatting **/ function woocommerce_price( $price, $args = array() ) { extract(shortcode_atts(array( 'ex_tax_label' => '0' ), $args)); $return = ''; $num_decimals = (int) get_option('woocommerce_price_num_decimals'); $currency_pos = get_option('woocommerce_currency_pos'); $currency_symbol = get_woocommerce_currency_symbol(); $price = number_format( (double) $price, $num_decimals, get_option('woocommerce_price_decimal_sep'), get_option('woocommerce_price_thousand_sep') ); switch ($currency_pos) : case 'left' : $return = $currency_symbol . $price; break; case 'right' : $return = $price . $currency_symbol; break; case 'left_space' : $return = $currency_symbol . ' ' . $price; break; case 'right_space' : $return = $price . ' ' . $currency_symbol; break; endswitch; if ($ex_tax_label && get_option('woocommerce_calc_taxes')=='yes') $return .= __(' (ex. tax)', 'woothemes'); return $return; } /** * Variation Formatting **/ function woocommerce_get_formatted_variation( $variation = '', $flat = false ) { if ($variation && is_array($variation)) : $return = ''; if (!$flat) : $return = '
: