/**
 * Handle redirects before content is output - hooked into template_redirect so is_page works.
 */
function wc_template_redirect()
{
    global $wp_query, $wp;
    if (!empty($_GET['page_id']) && '' === get_option('permalink_structure') && wc_get_page_id('shop') == $_GET['page_id']) {
        // When default permalinks are enabled, redirect shop page to post type archive url
        wp_safe_redirect(get_post_type_archive_link('product'));
        exit;
    } elseif (is_page(wc_get_page_id('checkout')) && wc_get_page_id('checkout') !== wc_get_page_id('cart') && WC()->cart->is_empty() && empty($wp->query_vars['order-pay']) && !isset($wp->query_vars['order-received'])) {
        // When on the checkout with an empty cart, redirect to cart page
        wc_add_notice(__('Checkout is not available whilst your cart is empty.', 'woocommerce'), 'notice');
        wp_redirect(wc_get_page_permalink('cart'));
        exit;
    } elseif (isset($wp->query_vars['customer-logout'])) {
        // Logout
        wp_redirect(str_replace('&', '&', wp_logout_url(wc_get_page_permalink('myaccount'))));
        exit;
    } elseif (is_search() && is_post_type_archive('product') && apply_filters('woocommerce_redirect_single_search_result', true) && 1 === absint($wp_query->found_posts)) {
        // Redirect to the product page if we have a single product
        $product = wc_get_product($wp_query->post);
        if ($product && $product->is_visible()) {
            wp_safe_redirect(get_permalink($product->get_id()), 302);
            exit;
        }
    } elseif (is_add_payment_method_page()) {
        // Ensure payment gateways are loaded early
        WC()->payment_gateways();
    } elseif (is_checkout()) {
        // Checkout pages handling
        // Buffer the checkout page
        ob_start();
        // Ensure gateways and shipping methods are loaded early
        WC()->payment_gateways();
        WC()->shipping();
    }
}
/**
 * Handle redirects before content is output - hooked into template_redirect so is_page works.
 *
 * @return void
 */
function wc_template_redirect()
{
    global $wp_query, $wp;
    // 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'] == wc_get_page_id('shop')) {
        wp_safe_redirect(get_post_type_archive_link('product'));
        exit;
    } elseif (is_page(wc_get_page_id('checkout')) && sizeof(WC()->cart->get_cart()) == 0 && empty($wp->query_vars['order-pay']) && !isset($wp->query_vars['order-received'])) {
        wp_redirect(get_permalink(wc_get_page_id('cart')));
        exit;
    } elseif (isset($wp->query_vars['customer-logout'])) {
        wp_redirect(str_replace('&', '&', wp_logout_url(get_permalink(wc_get_page_id('myaccount')))));
        exit;
    } elseif (is_search() && is_post_type_archive('product') && apply_filters('woocommerce_redirect_single_search_result', true) && $wp_query->found_posts == 1) {
        $product = wc_get_product($wp_query->post);
        if ($product->is_visible()) {
            wp_safe_redirect(get_permalink($product->id), 302);
            exit;
        }
    } elseif (is_add_payment_method_page()) {
        WC()->payment_gateways();
    } elseif (is_checkout()) {
        // Buffer the checkout page
        ob_start();
        // Ensure gateways and shipping methods are loaded early
        WC()->payment_gateways();
        WC()->shipping();
    }
}
 /**
  * Register/queue frontend scripts.
  *
  * @access public
  * @return void
  */
 public static function load_scripts()
 {
     global $post;
     $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     $lightbox_en = get_option('woocommerce_enable_lightbox') == 'yes' ? true : false;
     $ajax_cart_en = get_option('woocommerce_enable_ajax_add_to_cart') == 'yes' ? true : false;
     $assets_path = str_replace(array('http:', 'https:'), '', WC()->plugin_url()) . '/assets/';
     $frontend_script_path = $assets_path . 'js/frontend/';
     // Register any scripts for later use, or used as dependencies
     wp_register_script('chosen', $assets_path . 'js/chosen/chosen.jquery' . $suffix . '.js', array('jquery'), '1.0.0', true);
     wp_register_script('jquery-blockui', $assets_path . 'js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array('jquery'), '2.60', true);
     wp_register_script('jquery-payment', $assets_path . 'js/jquery-payment/jquery.payment' . $suffix . '.js', array('jquery'), '1.0.2', true);
     wp_register_script('wc-credit-card-form', $assets_path . 'js/frontend/credit-card-form' . $suffix . '.js', array('jquery', 'jquery-payment'), WC_VERSION, true);
     wp_register_script('wc-add-to-cart-variation', $frontend_script_path . 'add-to-cart-variation' . $suffix . '.js', array('jquery'), WC_VERSION, true);
     wp_register_script('wc-single-product', $frontend_script_path . 'single-product' . $suffix . '.js', array('jquery'), WC_VERSION, true);
     wp_register_script('wc-country-select', $frontend_script_path . 'country-select' . $suffix . '.js', array('jquery'), WC_VERSION, true);
     wp_register_script('wc-address-i18n', $frontend_script_path . 'address-i18n' . $suffix . '.js', array('jquery'), WC_VERSION, true);
     wp_register_script('jquery-cookie', $assets_path . 'js/jquery-cookie/jquery.cookie' . $suffix . '.js', array('jquery'), '1.3.1', true);
     // Queue frontend scripts conditionally
     if ($ajax_cart_en) {
         wp_enqueue_script('wc-add-to-cart', $frontend_script_path . 'add-to-cart' . $suffix . '.js', array('jquery'), WC_VERSION, true);
     }
     if (is_cart()) {
         wp_enqueue_script('wc-cart', $frontend_script_path . 'cart' . $suffix . '.js', array('jquery', 'wc-country-select'), WC_VERSION, true);
     }
     if (is_checkout()) {
         if (get_option('woocommerce_enable_chosen') == 'yes') {
             wp_enqueue_script('wc-chosen', $frontend_script_path . 'chosen-frontend' . $suffix . '.js', array('chosen'), WC_VERSION, true);
             wp_enqueue_style('woocommerce_chosen_styles', $assets_path . 'css/chosen.css');
         }
         wp_enqueue_script('wc-checkout', $frontend_script_path . 'checkout' . $suffix . '.js', array('jquery', 'woocommerce', 'wc-country-select', 'wc-address-i18n'), WC_VERSION, true);
     }
     if (is_page(get_option('woocommerce_myaccount_page_id'))) {
         if (get_option('woocommerce_enable_chosen') == 'yes') {
             wp_enqueue_script('wc-chosen', $frontend_script_path . 'chosen-frontend' . $suffix . '.js', array('chosen'), WC_VERSION, true);
             wp_enqueue_style('woocommerce_chosen_styles', $assets_path . 'css/chosen.css');
         }
     }
     if (is_add_payment_method_page()) {
         wp_enqueue_script('wc-add-payment-method', $frontend_script_path . 'add-payment-method' . $suffix . '.js', array('jquery', 'woocommerce'), WC_VERSION, true);
     }
     if ($lightbox_en && (is_product() || !empty($post->post_content) && strstr($post->post_content, '[product_page'))) {
         wp_enqueue_script('prettyPhoto', $assets_path . 'js/prettyPhoto/jquery.prettyPhoto' . $suffix . '.js', array('jquery'), '3.1.5', true);
         wp_enqueue_script('prettyPhoto-init', $assets_path . 'js/prettyPhoto/jquery.prettyPhoto.init' . $suffix . '.js', array('jquery', 'prettyPhoto'), WC_VERSION, true);
         wp_enqueue_style('woocommerce_prettyPhoto_css', $assets_path . 'css/prettyPhoto.css');
     }
     if (is_product()) {
         wp_enqueue_script('wc-single-product');
     }
     // Global frontend scripts
     wp_enqueue_script('woocommerce', $frontend_script_path . 'woocommerce' . $suffix . '.js', array('jquery', 'jquery-blockui'), WC_VERSION, true);
     wp_enqueue_script('wc-cart-fragments', $frontend_script_path . 'cart-fragments' . $suffix . '.js', array('jquery', 'jquery-cookie'), WC_VERSION, true);
     // CSS Styles
     $enqueue_styles = self::get_styles();
     if ($enqueue_styles) {
         foreach ($enqueue_styles as $handle => $args) {
             wp_enqueue_style($handle, $args['src'], $args['deps'], $args['version'], $args['media']);
         }
     }
 }
 /**
  * Initialize the gateway
  *
  * @since 2.0.0
  */
 public function __construct()
 {
     parent::__construct(WC_Authorize_Net_CIM::ECHECK_GATEWAY_ID, wc_authorize_net_cim(), array('method_title' => __('Authorize.Net CIM eCheck', 'woocommerce-gateway-authorize-net-cim'), 'method_description' => __('Allow customers to securely pay using their checking/savings accounts with Authorize.Net CIM.', 'woocommerce-gateway-authorize-net-cim'), 'supports' => array(self::FEATURE_PRODUCTS, self::FEATURE_PAYMENT_FORM, self::FEATURE_TOKENIZATION, self::FEATURE_TOKEN_EDITOR, self::FEATURE_DETAILED_CUSTOMER_DECLINE_MESSAGES, self::FEATURE_CUSTOMER_ID, self::FEATURE_ADD_PAYMENT_METHOD), 'payment_type' => self::PAYMENT_TYPE_ECHECK, 'environments' => array('production' => __('Production', 'woocommerce-gateway-authorize-net-cim'), 'test' => __('Test', 'woocommerce-gateway-authorize-net-cim')), 'shared_settings' => $this->shared_settings_names));
     // display the authorization message at checkout
     if ($this->is_authorization_message_enabled() && !is_add_payment_method_page()) {
         add_action('wc_' . $this->get_id() . '_payment_form_end', array($this, 'display_authorization_message'));
     }
     // adjust the recurring authorization message placeholders for subscriptions
     add_filter('wc_' . $this->get_id() . '_authorization_message_placeholders', array($this, 'adjust_subscriptions_placeholders'), 10, 2);
 }
Пример #5
0
 function get_available_payment_gateways()
 {
     $this->init();
     $_available_gateways = array();
     foreach ($this->payment_gateways as $slug => $gateway) {
         // let custom addon can define how is enable/disable
         if (apply_filters('learn_press_payment_gateway_available_' . $slug, true, $gateway)) {
             $_available_gateways[$slug] = $gateway;
         }
         continue;
         if ($gateway->is_available()) {
             if (!is_add_payment_method_page()) {
                 $_available_gateways[$gateway->id] = $gateway;
             } elseif ($gateway->supports('add_payment_method')) {
                 $_available_gateways[$gateway->id] = $gateway;
             }
         }
     }
     return apply_filters('learn_press_available_payment_gateways', $_available_gateways);
 }
Пример #6
0
function dh_get_post_meta($meta = '', $post_id = '', $default = null)
{
    $post_id = empty($post_id) ? get_the_ID() : $post_id;
    if (defined('WOOCOMMERCE_VERSION')) {
        if (is_shop()) {
            $post_id = wc_get_page_id('shop');
        } elseif (is_cart()) {
            $post_id = wc_get_page_id('cart');
        } elseif (is_checkout()) {
            $post_id = wc_get_page_id('checkout');
        } elseif (is_account_page()) {
            $post_id = wc_get_page_id('myaccount');
        } elseif (is_order_received_page()) {
            $post_id = wc_get_page_id('checkout');
        } elseif (is_add_payment_method_page()) {
            $post_id = wc_get_page_id('myaccount');
        }
    }
    if (is_search()) {
        $post_id = 0;
    }
    if (empty($meta)) {
        return false;
    }
    $value = get_post_meta($post_id, '_dh_' . $meta, true);
    if ($value !== '' && $value !== null && $value !== array() && $value !== false) {
        return apply_filters('dh_get_post_meta', $value, $meta, $post_id);
    }
    return $default;
}
 /**
  * Get available gateways.
  *
  * @access public
  * @return array
  */
 public function get_available_payment_gateways()
 {
     $_available_gateways = array();
     foreach ($this->payment_gateways as $gateway) {
         if ($gateway->is_available()) {
             if (!is_add_payment_method_page()) {
                 $_available_gateways[$gateway->id] = $gateway;
             } elseif ($gateway->supports('add_payment_method')) {
                 $_available_gateways[$gateway->id] = $gateway;
             }
         }
     }
     return apply_filters('woocommerce_available_payment_gateways', $_available_gateways);
 }
 /**
  * Register/queue frontend scripts.
  */
 public static function load_scripts()
 {
     global $post;
     if (!did_action('before_woocommerce_init')) {
         return;
     }
     $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     $lightbox_en = 'yes' === get_option('woocommerce_enable_lightbox');
     $ajax_cart_en = 'yes' === get_option('woocommerce_enable_ajax_add_to_cart');
     $assets_path = str_replace(array('http:', 'https:'), '', WC()->plugin_url()) . '/assets/';
     $frontend_script_path = $assets_path . 'js/frontend/';
     // Register any scripts for later use, or used as dependencies
     self::register_script('select2', $assets_path . 'js/select2/select2' . $suffix . '.js', array('jquery'), '3.5.4');
     self::register_script('jquery-blockui', $assets_path . 'js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array('jquery'), '2.70');
     self::register_script('jquery-payment', $assets_path . 'js/jquery-payment/jquery.payment' . $suffix . '.js', array('jquery'), '1.4.1');
     self::register_script('jquery-cookie', $assets_path . 'js/jquery-cookie/jquery.cookie' . $suffix . '.js', array('jquery'), '1.4.1');
     self::register_script('wc-credit-card-form', $frontend_script_path . 'credit-card-form' . $suffix . '.js', array('jquery', 'jquery-payment'));
     self::register_script('wc-add-to-cart-variation', $frontend_script_path . 'add-to-cart-variation' . $suffix . '.js', array('jquery', 'wp-util'));
     self::register_script('wc-single-product', $frontend_script_path . 'single-product' . $suffix . '.js', array('jquery'));
     self::register_script('wc-country-select', $frontend_script_path . 'country-select' . $suffix . '.js', array('jquery'));
     self::register_script('wc-address-i18n', $frontend_script_path . 'address-i18n' . $suffix . '.js', array('jquery'));
     self::register_script('wc-password-strength-meter', $frontend_script_path . 'password-strength-meter' . $suffix . '.js', array('jquery', 'password-strength-meter'));
     // Register frontend scripts conditionally
     if ($ajax_cart_en) {
         self::enqueue_script('wc-add-to-cart', $frontend_script_path . 'add-to-cart' . $suffix . '.js');
     }
     if (is_cart()) {
         self::enqueue_script('wc-cart', $frontend_script_path . 'cart' . $suffix . '.js', array('jquery', 'wc-country-select', 'wc-address-i18n'));
     }
     if (is_checkout() || is_account_page()) {
         self::enqueue_script('select2');
         self::enqueue_style('select2', $assets_path . 'css/select2.css');
         // Password strength meter.
         // Load in checkout, account login and edit account page.
         if ('no' === get_option('woocommerce_registration_generate_password') && !is_user_logged_in() || is_edit_account_page()) {
             self::enqueue_script('wc-password-strength-meter');
         }
     }
     if (is_checkout()) {
         self::enqueue_script('wc-checkout', $frontend_script_path . 'checkout' . $suffix . '.js', array('jquery', 'woocommerce', 'wc-country-select', 'wc-address-i18n'));
     }
     if (is_add_payment_method_page()) {
         self::enqueue_script('wc-add-payment-method', $frontend_script_path . 'add-payment-method' . $suffix . '.js', array('jquery', 'woocommerce'));
     }
     if (is_lost_password_page()) {
         self::enqueue_script('wc-lost-password', $frontend_script_path . 'lost-password' . $suffix . '.js', array('jquery', 'woocommerce'));
     }
     if ($lightbox_en && (is_product() || !empty($post->post_content) && strstr($post->post_content, '[product_page'))) {
         self::enqueue_script('prettyPhoto', $assets_path . 'js/prettyPhoto/jquery.prettyPhoto' . $suffix . '.js', array('jquery'), '3.1.6', true);
         self::enqueue_script('prettyPhoto-init', $assets_path . 'js/prettyPhoto/jquery.prettyPhoto.init' . $suffix . '.js', array('jquery', 'prettyPhoto'));
         self::enqueue_style('woocommerce_prettyPhoto_css', $assets_path . 'css/prettyPhoto.css');
     }
     if (is_product()) {
         self::enqueue_script('wc-single-product');
     }
     if ('geolocation_ajax' === get_option('woocommerce_default_customer_address')) {
         // Exclude common bots from geolocation by user agent.
         $ua = wc_get_user_agent();
         if (!strstr($ua, 'bot') && !strstr($ua, 'spider') && !strstr($ua, 'crawl')) {
             self::enqueue_script('wc-geolocation', $frontend_script_path . 'geolocation' . $suffix . '.js', array('jquery'));
         }
     }
     // Global frontend scripts
     self::enqueue_script('woocommerce', $frontend_script_path . 'woocommerce' . $suffix . '.js', array('jquery', 'jquery-blockui'));
     self::enqueue_script('wc-cart-fragments', $frontend_script_path . 'cart-fragments' . $suffix . '.js', array('jquery', 'jquery-cookie'));
     // CSS Styles
     if ($enqueue_styles = self::get_styles()) {
         foreach ($enqueue_styles as $handle => $args) {
             self::enqueue_style($handle, $args['src'], $args['deps'], $args['version'], $args['media']);
         }
     }
 }
 /**
  * Enqueue the payment form JS, CSS, and localized
  * JS params
  *
  * @since 4.3.0
  */
 protected function enqueue_payment_form_assets()
 {
     // bail if on my account page and *not* on add payment method page
     if (is_account_page() && !is_add_payment_method_page()) {
         return;
     }
     $handle = 'sv-wc-payment-gateway-payment-form';
     // Frontend JS
     wp_enqueue_script($handle, $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/js/frontend/' . $handle . '.min.js', array('jquery-payment'), SV_WC_Plugin::VERSION, true);
     // Frontend CSS
     wp_enqueue_style($handle, $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/css/frontend/' . $handle . '.min.css', array(), SV_WC_Plugin::VERSION);
     // localized JS params
     $this->localize_script($handle, $this->get_payment_form_js_localized_script_params());
 }
 /**
  * Render the saved payment methods
  *
  * @hooked wc_{gateway ID}_payment_form_start @ priority 20
  *
  * @since 4.0.0
  */
 public function render_saved_payment_methods()
 {
     $is_add_new_payment_method_page = $this->get_gateway()->supports_add_payment_method() && is_add_payment_method_page();
     // tokenization forced check to prevent rendering this on the "add new payment method" screen
     if ($this->has_tokens() && !$is_add_new_payment_method_page) {
         echo $this->get_saved_payment_methods_html();
     }
 }
 /**
  * Register/queue frontend scripts.
  *
  * @access public
  * @return void
  */
 public function load_scripts()
 {
     global $post, $wp;
     $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     $lightbox_en = get_option('woocommerce_enable_lightbox') == 'yes' ? true : false;
     $ajax_cart_en = get_option('woocommerce_enable_ajax_add_to_cart') == 'yes' ? true : false;
     $assets_path = str_replace(array('http:', 'https:'), '', WC()->plugin_url()) . '/assets/';
     $frontend_script_path = $assets_path . 'js/frontend/';
     // Register any scripts for later use, or used as dependencies
     wp_register_script('chosen', $assets_path . 'js/chosen/chosen.jquery' . $suffix . '.js', array('jquery'), '1.0.0', true);
     wp_register_script('jquery-blockui', $assets_path . 'js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array('jquery'), '2.60', true);
     wp_register_script('jquery-payment', $assets_path . 'js/jquery-payment/jquery.payment' . $suffix . '.js', array('jquery'), '1.0.2', true);
     wp_register_script('wc-credit-card-form', $assets_path . 'js/frontend/credit-card-form' . $suffix . '.js', array('jquery', 'jquery-payment'), WC_VERSION, true);
     wp_register_script('wc-add-to-cart-variation', $frontend_script_path . 'add-to-cart-variation' . $suffix . '.js', array('jquery'), WC_VERSION, true);
     wp_register_script('wc-single-product', $frontend_script_path . 'single-product' . $suffix . '.js', array('jquery'), WC_VERSION, true);
     wp_register_script('wc-country-select', $frontend_script_path . 'country-select' . $suffix . '.js', array('jquery'), WC_VERSION, true);
     wp_register_script('wc-address-i18n', $frontend_script_path . 'address-i18n' . $suffix . '.js', array('jquery'), WC_VERSION, true);
     wp_register_script('jquery-cookie', $assets_path . 'js/jquery-cookie/jquery.cookie' . $suffix . '.js', array('jquery'), '1.3.1', true);
     // Queue frontend scripts conditionally
     if ($ajax_cart_en) {
         wp_enqueue_script('wc-add-to-cart', $frontend_script_path . 'add-to-cart' . $suffix . '.js', array('jquery'), WC_VERSION, true);
     }
     if (is_cart()) {
         wp_enqueue_script('wc-cart', $frontend_script_path . 'cart' . $suffix . '.js', array('jquery', 'wc-country-select'), WC_VERSION, true);
     }
     if (is_checkout()) {
         if (get_option('woocommerce_enable_chosen') == 'yes') {
             wp_enqueue_script('wc-chosen', $frontend_script_path . 'chosen-frontend' . $suffix . '.js', array('chosen'), WC_VERSION, true);
             wp_enqueue_style('woocommerce_chosen_styles', $assets_path . 'css/chosen.css');
         }
         wp_enqueue_script('wc-checkout', $frontend_script_path . 'checkout' . $suffix . '.js', array('jquery', 'woocommerce', 'wc-country-select', 'wc-address-i18n'), WC_VERSION, true);
     }
     if (is_page(get_option('woocommerce_myaccount_page_id'))) {
         if (get_option('woocommerce_enable_chosen') == 'yes') {
             wp_enqueue_script('wc-chosen', $frontend_script_path . 'chosen-frontend' . $suffix . '.js', array('chosen'), WC_VERSION, true);
             wp_enqueue_style('woocommerce_chosen_styles', $assets_path . 'css/chosen.css');
         }
     }
     if (is_add_payment_method_page()) {
         wp_enqueue_script('wc-add-payment-method', $frontend_script_path . 'add-payment-method' . $suffix . '.js', array('jquery', 'woocommerce'), WC_VERSION, true);
     }
     //PRETTY PHOTO PESTE TOT use data-rel
     if ($lightbox_en && is_singular()) {
         wp_enqueue_script('prettyPhoto', $assets_path . 'js/prettyPhoto/jquery.prettyPhoto' . $suffix . '.js', array('jquery'), '3.1.5', true);
         wp_enqueue_script('prettyPhoto-init', $assets_path . 'js/prettyPhoto/jquery.prettyPhoto.init' . $suffix . '.js', array('jquery'), WC_VERSION, true);
         wp_enqueue_style('woocommerce_prettyPhoto_css', $assets_path . 'css/prettyPhoto.css');
     }
     //MODIFICARE prettyPhoto
     // if ( $lightbox_en && ( is_product() || ( ! empty( $post->post_content ) && strstr( $post->post_content, '[product_page' ) ) ) ) {
     // 	wp_enqueue_script( 'prettyPhoto', $assets_path . 'js/prettyPhoto/jquery.prettyPhoto' . $suffix . '.js', array( 'jquery' ), '3.1.5', true );
     // 	wp_enqueue_script( 'prettyPhoto-init', $assets_path . 'js/prettyPhoto/jquery.prettyPhoto.init' . $suffix . '.js', array( 'jquery' ), WC_VERSION, true );
     // 	wp_enqueue_style( 'woocommerce_prettyPhoto_css', $assets_path . 'css/prettyPhoto.css' );
     // }
     if (is_product()) {
         wp_enqueue_script('wc-single-product');
     }
     // Global frontend scripts
     wp_enqueue_script('woocommerce', $frontend_script_path . 'woocommerce' . $suffix . '.js', array('jquery', 'jquery-blockui'), WC_VERSION, true);
     wp_enqueue_script('wc-cart-fragments', $frontend_script_path . 'cart-fragments' . $suffix . '.js', array('jquery', 'jquery-cookie'), WC_VERSION, true);
     // Variables for JS scripts
     wp_localize_script('woocommerce', 'woocommerce_params', apply_filters('woocommerce_params', array('ajax_url' => WC()->ajax_url(), 'ajax_loader_url' => apply_filters('woocommerce_ajax_loader_url', $assets_path . 'images/ajax-loader@2x.gif'))));
     wp_localize_script('wc-single-product', 'wc_single_product_params', apply_filters('wc_single_product_params', array('i18n_required_rating_text' => esc_attr__('Please select a rating', 'woocommerce'), 'review_rating_required' => get_option('woocommerce_review_rating_required'))));
     wp_localize_script('wc-checkout', 'wc_checkout_params', apply_filters('wc_checkout_params', array('ajax_url' => WC()->ajax_url(), 'ajax_loader_url' => apply_filters('woocommerce_ajax_loader_url', $assets_path . 'images/ajax-loader@2x.gif'), 'update_order_review_nonce' => wp_create_nonce("update-order-review"), 'apply_coupon_nonce' => wp_create_nonce("apply-coupon"), 'option_guest_checkout' => get_option('woocommerce_enable_guest_checkout'), 'checkout_url' => add_query_arg('action', 'woocommerce_checkout', WC()->ajax_url()), 'is_checkout' => is_page(wc_get_page_id('checkout')) && empty($wp->query_vars['order-pay']) && !isset($wp->query_vars['order-received']) ? 1 : 0)));
     wp_localize_script('wc-address-i18n', 'wc_address_i18n_params', apply_filters('wc_address_i18n_params', array('locale' => json_encode(WC()->countries->get_country_locale()), 'locale_fields' => json_encode(WC()->countries->get_country_locale_field_selectors()), 'i18n_required_text' => esc_attr__('required', 'woocommerce'))));
     wp_localize_script('wc-cart', 'wc_cart_params', apply_filters('wc_cart_params', array('ajax_url' => WC()->ajax_url(), 'ajax_loader_url' => apply_filters('woocommerce_ajax_loader_url', $assets_path . 'images/ajax-loader@2x.gif'), 'update_shipping_method_nonce' => wp_create_nonce("update-shipping-method"))));
     wp_localize_script('wc-cart-fragments', 'wc_cart_fragments_params', apply_filters('wc_cart_fragments_params', array('ajax_url' => WC()->ajax_url(), 'fragment_name' => apply_filters('woocommerce_cart_fragment_name', 'wc_fragments'))));
     wp_localize_script('wc-add-to-cart', 'wc_add_to_cart_params', apply_filters('wc_add_to_cart_params', array('ajax_url' => WC()->ajax_url(), 'ajax_loader_url' => apply_filters('woocommerce_ajax_loader_url', $assets_path . 'images/ajax-loader@2x.gif'), 'i18n_view_cart' => esc_attr__('View Cart', 'woocommerce'), 'cart_url' => get_permalink(wc_get_page_id('cart')), 'is_cart' => is_cart(), 'cart_redirect_after_add' => get_option('woocommerce_cart_redirect_after_add'))));
     wp_localize_script('wc-add-to-cart-variation', 'wc_add_to_cart_variation_params', apply_filters('wc_add_to_cart_variation_params', array('i18n_no_matching_variations_text' => esc_attr__('Sorry, no products matched your selection. Please choose a different combination.', 'woocommerce'), 'i18n_unavailable_text' => esc_attr__('Sorry, this product is unavailable. Please choose a different combination.', 'woocommerce'))));
     wp_localize_script('wc-country-select', 'wc_country_select_params', apply_filters('wc_country_select_params', array('countries' => json_encode(array_merge(WC()->countries->get_allowed_country_states(), WC()->countries->get_shipping_country_states())), 'i18n_select_state_text' => esc_attr__('Select an option…', 'woocommerce'))));
     // CSS Styles
     $enqueue_styles = $this->get_styles();
     if ($enqueue_styles) {
         foreach ($enqueue_styles as $handle => $args) {
             wp_enqueue_style($handle, $args['src'], $args['deps'], $args['version'], $args['media']);
         }
     }
 }
    /**
     * Payment form on checkout page
     */
    public function payment_fields()
    {
        $user = wp_get_current_user();
        $display_tokenization = $this->supports('tokenization') && is_checkout() && $this->saved_cards;
        if ($user->ID) {
            $user_email = get_user_meta($user->ID, 'billing_email', true);
            $user_email = $user_email ? $user_email : $user->user_email;
        } else {
            $user_email = '';
        }
        if (is_add_payment_method_page()) {
            $pay_button_text = __('Add Card', 'woocommerce-gateway-stripe');
        } else {
            $pay_button_text = '';
        }
        echo '<div
			id="stripe-payment-data"
			data-panel-label="' . esc_attr($pay_button_text) . '"
			data-description=""
			data-email="' . esc_attr($user_email) . '"
			data-amount="' . esc_attr($this->get_stripe_amount(WC()->cart->total)) . '"
			data-name="' . esc_attr(sprintf(__('%s', 'woocommerce-gateway-stripe'), get_bloginfo('name', 'display'))) . '"
			data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '"
			data-image="' . esc_attr($this->stripe_checkout_image) . '"
			data-bitcoin="' . esc_attr($this->bitcoin ? 'true' : 'false') . '"
			data-locale="' . esc_attr($this->stripe_checkout_locale ? $this->stripe_checkout_locale : 'en') . '">';
        if ($this->description) {
            echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($this->description)));
        }
        if ($display_tokenization) {
            $this->tokenization_script();
            $this->saved_payment_methods();
        }
        if (!$this->stripe_checkout) {
            $this->form();
            if ($display_tokenization) {
                $this->save_payment_method_checkbox();
            }
        }
        echo '</div>';
    }
Пример #13
0
 /**
  * Register/queue frontend scripts.
  */
 public static function load_scripts()
 {
     global $post;
     $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     $lightbox_en = 'yes' === get_option('woocommerce_enable_lightbox');
     $ajax_cart_en = 'yes' === get_option('woocommerce_enable_ajax_add_to_cart');
     $assets_path = str_replace(array('http:', 'https:'), '', WC()->plugin_url()) . '/assets/';
     $frontend_script_path = $assets_path . 'js/frontend/';
     // Chosen is @deprecated as of 2.3 in favour of 2.3. Here for backwards compatibility.
     self::register_script('chosen', $assets_path . 'js/chosen/chosen.jquery' . $suffix . '.js', array('jquery'), '1.0.0');
     self::register_script('select2', $assets_path . 'js/select2/select2' . $suffix . '.js', array('jquery'), '3.5.2');
     wp_localize_script('select2', 'wc_select_params', array('i18n_matches_1' => _x('One result is available, press enter to select it.', 'enhanced select', 'woocommerce'), 'i18n_matches_n' => _x('%qty% results are available, use up and down arrow keys to navigate.', 'enhanced select', 'woocommerce'), 'i18n_no_matches' => _x('No matches found', 'enhanced select', 'woocommerce'), 'i18n_ajax_error' => _x('Loading failed', 'enhanced select', 'woocommerce'), 'i18n_input_too_short_1' => _x('Please enter 1 or more characters', 'enhanced select', 'woocommerce'), 'i18n_input_too_short_n' => _x('Please enter %qty% or more characters', 'enhanced select', 'woocommerce'), 'i18n_input_too_long_1' => _x('Please delete 1 character', 'enhanced select', 'woocommerce'), 'i18n_input_too_long_n' => _x('Please delete %qty% characters', 'enhanced select', 'woocommerce'), 'i18n_selection_too_long_1' => _x('You can only select 1 item', 'enhanced select', 'woocommerce'), 'i18n_selection_too_long_n' => _x('You can only select %qty% items', 'enhanced select', 'woocommerce'), 'i18n_load_more' => _x('Loading more results&hellip;', 'enhanced select', 'woocommerce'), 'i18n_searching' => _x('Searching&hellip;', 'enhanced select', 'woocommerce')));
     // Register any scripts for later use, or used as dependencies
     self::register_script('jquery-blockui', $assets_path . 'js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array('jquery'), '2.60');
     self::register_script('jquery-payment', $assets_path . 'js/jquery-payment/jquery.payment' . $suffix . '.js', array('jquery'), '1.2.1');
     self::register_script('jquery-cookie', $assets_path . 'js/jquery-cookie/jquery.cookie' . $suffix . '.js', array('jquery'), '1.4.1');
     self::register_script('wc-credit-card-form', $frontend_script_path . 'credit-card-form' . $suffix . '.js', array('jquery', 'jquery-payment'));
     self::register_script('wc-add-to-cart-variation', $frontend_script_path . 'add-to-cart-variation' . $suffix . '.js');
     self::register_script('wc-single-product', $frontend_script_path . 'single-product' . $suffix . '.js');
     self::register_script('wc-country-select', $frontend_script_path . 'country-select' . $suffix . '.js');
     self::register_script('wc-address-i18n', $frontend_script_path . 'address-i18n' . $suffix . '.js');
     // Register frontend scripts conditionally
     if ($ajax_cart_en) {
         self::enqueue_script('wc-add-to-cart', $frontend_script_path . 'add-to-cart' . $suffix . '.js');
     }
     if (is_cart()) {
         self::enqueue_script('wc-cart', $frontend_script_path . 'cart' . $suffix . '.js', array('jquery', 'wc-country-select'));
     }
     if (is_checkout() || is_page(get_option('woocommerce_myaccount_page_id'))) {
         self::enqueue_script('select2');
         wp_enqueue_style('select2', $assets_path . 'css/select2.css');
     }
     if (is_checkout()) {
         self::enqueue_script('wc-checkout', $frontend_script_path . 'checkout' . $suffix . '.js', array('jquery', 'woocommerce', 'wc-country-select', 'wc-address-i18n'));
     }
     if (is_add_payment_method_page()) {
         self::enqueue_script('wc-add-payment-method', $frontend_script_path . 'add-payment-method' . $suffix . '.js', array('jquery', 'woocommerce'));
     }
     if (is_lost_password_page()) {
         self::enqueue_script('wc-lost-password', $frontend_script_path . 'lost-password' . $suffix . '.js', array('jquery', 'woocommerce'));
     }
     if ($lightbox_en && (is_product() || !empty($post->post_content) && strstr($post->post_content, '[product_page'))) {
         self::enqueue_script('prettyPhoto', $assets_path . 'js/prettyPhoto/jquery.prettyPhoto' . $suffix . '.js', array('jquery'), '3.1.5', true);
         self::enqueue_script('prettyPhoto-init', $assets_path . 'js/prettyPhoto/jquery.prettyPhoto.init' . $suffix . '.js', array('jquery', 'prettyPhoto'));
         wp_enqueue_style('woocommerce_prettyPhoto_css', $assets_path . 'css/prettyPhoto.css');
     }
     if (is_product()) {
         self::enqueue_script('wc-single-product');
     }
     // Global frontend scripts
     self::enqueue_script('woocommerce', $frontend_script_path . 'woocommerce' . $suffix . '.js', array('jquery', 'jquery-blockui'));
     self::enqueue_script('wc-cart-fragments', $frontend_script_path . 'cart-fragments' . $suffix . '.js', array('jquery', 'jquery-cookie'));
     // CSS Styles
     if ($enqueue_styles = self::get_styles()) {
         foreach ($enqueue_styles as $handle => $args) {
             wp_enqueue_style($handle, $args['src'], $args['deps'], $args['version'], $args['media']);
         }
     }
 }
 /**
  * Adjust the available gateways in certain cases.
  *
  * @since 4.4.0
  * @param array $available_gateways the available payment gateways
  * @return array
  */
 public function adjust_available_gateways($available_gateways)
 {
     if (!is_add_payment_method_page()) {
         return $available_gateways;
     }
     foreach ($this->get_gateways() as $gateway) {
         if ($gateway->supports_tokenization() && !$gateway->supports_add_payment_method()) {
             unset($available_gateways[$gateway->id]);
         }
     }
     return $available_gateways;
 }
 /**
  * Register/queue frontend scripts.
  */
 public static function load_scripts()
 {
     global $post;
     if (!did_action('before_woocommerce_init')) {
         return;
     }
     $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     $ajax_cart_en = 'yes' === get_option('woocommerce_enable_ajax_add_to_cart');
     $assets_path = str_replace(array('http:', 'https:'), '', WC()->plugin_url()) . '/assets/';
     $frontend_script_path = $assets_path . 'js/frontend/';
     // Register any scripts for later use, or used as dependencies
     self::register_script('select2', $assets_path . 'js/select2/select2' . $suffix . '.js', array('jquery'), '3.5.4');
     self::register_script('jquery-blockui', $assets_path . 'js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array('jquery'), '2.70');
     self::register_script('jquery-payment', $assets_path . 'js/jquery-payment/jquery.payment' . $suffix . '.js', array('jquery'), '1.4.1');
     self::register_script('js-cookie', $assets_path . 'js/js-cookie/js.cookie' . $suffix . '.js', array(), '2.1.3');
     self::register_script('wc-credit-card-form', $frontend_script_path . 'credit-card-form' . $suffix . '.js', array('jquery', 'jquery-payment'));
     self::register_script('wc-add-to-cart-variation', $frontend_script_path . 'add-to-cart-variation' . $suffix . '.js', array('jquery', 'wp-util'));
     self::register_script('wc-single-product', $frontend_script_path . 'single-product' . $suffix . '.js', array('jquery'));
     self::register_script('wc-country-select', $frontend_script_path . 'country-select' . $suffix . '.js', array('jquery'));
     self::register_script('wc-address-i18n', $frontend_script_path . 'address-i18n' . $suffix . '.js', array('jquery'));
     self::register_script('wc-password-strength-meter', $frontend_script_path . 'password-strength-meter' . $suffix . '.js', array('jquery', 'password-strength-meter'));
     // Register frontend scripts conditionally
     if ($ajax_cart_en) {
         self::enqueue_script('wc-add-to-cart', $frontend_script_path . 'add-to-cart' . $suffix . '.js');
     }
     if (is_cart()) {
         self::enqueue_script('wc-cart', $frontend_script_path . 'cart' . $suffix . '.js', array('jquery', 'wc-country-select', 'wc-address-i18n'));
     }
     if (is_checkout() || is_account_page()) {
         self::enqueue_script('select2');
         self::enqueue_style('select2', $assets_path . 'css/select2.css');
         // Password strength meter.
         // Load in checkout, account login and edit account page.
         if ('no' === get_option('woocommerce_registration_generate_password') && !is_user_logged_in() || is_edit_account_page() || is_lost_password_page()) {
             self::enqueue_script('wc-password-strength-meter');
         }
     }
     if (is_checkout()) {
         self::enqueue_script('wc-checkout', $frontend_script_path . 'checkout' . $suffix . '.js', array('jquery', 'woocommerce', 'wc-country-select', 'wc-address-i18n'));
     }
     if (is_add_payment_method_page()) {
         self::enqueue_script('wc-add-payment-method', $frontend_script_path . 'add-payment-method' . $suffix . '.js', array('jquery', 'woocommerce'));
     }
     if (is_lost_password_page()) {
         self::enqueue_script('wc-lost-password', $frontend_script_path . 'lost-password' . $suffix . '.js', array('jquery', 'woocommerce'));
     }
     if (is_product() || !empty($post->post_content) && strstr($post->post_content, '[product_page')) {
         self::enqueue_script('flexslider', $assets_path . 'js/flexslider/jquery.flexslider' . $suffix . '.js', array('jquery'), '2.7.0', true);
         self::enqueue_script('photoswipe', $assets_path . 'js/photoswipe/photoswipe' . $suffix . '.js', '4.1.1', true);
         self::enqueue_script('photoswipe-ui-default', $assets_path . 'js/photoswipe/photoswipe-ui-default' . $suffix . '.js', array('photoswipe'), '4.1.1', true);
         self::enqueue_style('photoswipe', $assets_path . 'css/photoswipe/photoswipe.css');
         self::enqueue_style('photoswipe-default-skin', $assets_path . 'css/photoswipe/default-skin/default-skin.css');
         self::enqueue_script('zoom', $assets_path . 'js/zoom/jquery.zoom' . $suffix . '.js', array('jquery'), '1.7.15', true);
         self::enqueue_script('wc-single-product');
         wp_localize_script('wc-single-product', 'flexslider_options', apply_filters('woocommerce_single_product_carousel_options', array('rtl' => is_rtl(), 'animation' => 'slide', 'smoothHeight' => true, 'directionNav' => false, 'controlNav' => 'thumbnails', 'slideshow' => false, 'animationSpeed' => 500)));
     }
     if ('geolocation_ajax' === get_option('woocommerce_default_customer_address')) {
         // Exclude common bots from geolocation by user agent.
         $ua = wc_get_user_agent();
         if (!strstr($ua, 'bot') && !strstr($ua, 'spider') && !strstr($ua, 'crawl')) {
             self::enqueue_script('wc-geolocation', $frontend_script_path . 'geolocation' . $suffix . '.js', array('jquery'));
         }
     }
     // Global frontend scripts
     self::enqueue_script('woocommerce', $frontend_script_path . 'woocommerce' . $suffix . '.js', array('jquery', 'jquery-blockui', 'js-cookie'));
     self::enqueue_script('wc-cart-fragments', $frontend_script_path . 'cart-fragments' . $suffix . '.js', array('jquery', 'js-cookie'));
     // CSS Styles
     if ($enqueue_styles = self::get_styles()) {
         foreach ($enqueue_styles as $handle => $args) {
             self::enqueue_style($handle, $args['src'], $args['deps'], $args['version'], $args['media']);
         }
     }
     // These are deprecated scripts only included for BW compatibility. @todo remove in future version.
     self::register_script('jquery-cookie', $assets_path . 'js/jquery-cookie/jquery.cookie' . $suffix . '.js', array('jquery'), '1.4.1');
     self::register_script('prettyPhoto', $assets_path . 'js/prettyPhoto/jquery.prettyPhoto' . $suffix . '.js', array('jquery'), '3.1.6', true);
     self::register_script('prettyPhoto-init', $assets_path . 'js/prettyPhoto/jquery.prettyPhoto.init' . $suffix . '.js', array('jquery', 'prettyPhoto'));
     self::register_style('woocommerce_prettyPhoto_css', $assets_path . 'css/prettyPhoto.css');
 }
Пример #16
0
 public static function is_add_payment_method_page()
 {
     return self::exists() && is_add_payment_method_page();
 }
 /**
  * Register/queue frontend scripts.
  */
 public static function load_scripts()
 {
     global $post;
     if (!did_action('before_woocommerce_init')) {
         return;
     }
     $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     $lightbox_en = 'yes' === get_option('woocommerce_enable_lightbox');
     $ajax_cart_en = 'yes' === get_option('woocommerce_enable_ajax_add_to_cart');
     $assets_path = str_replace(array('http:', 'https:'), '', WC()->plugin_url()) . '/assets/';
     $frontend_script_path = $assets_path . 'js/frontend/';
     // Chosen is @deprecated as of 2.3 in favour of 2.3. Here for backwards compatibility.
     self::register_script('chosen', $assets_path . 'js/chosen/chosen.jquery' . $suffix . '.js', array('jquery'), '1.0.0');
     self::register_script('select2', $assets_path . 'js/select2/select2' . $suffix . '.js', array('jquery'), '3.5.2');
     // Register any scripts for later use, or used as dependencies
     self::register_script('jquery-blockui', $assets_path . 'js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array('jquery'), '2.70');
     self::register_script('jquery-payment', $assets_path . 'js/jquery-payment/jquery.payment' . $suffix . '.js', array('jquery'), '1.2.4');
     self::register_script('jquery-cookie', $assets_path . 'js/jquery-cookie/jquery.cookie' . $suffix . '.js', array('jquery'), '1.4.1');
     self::register_script('wc-credit-card-form', $frontend_script_path . 'credit-card-form' . $suffix . '.js', array('jquery', 'jquery-payment'));
     self::register_script('wc-add-to-cart-variation', $frontend_script_path . 'add-to-cart-variation' . $suffix . '.js');
     self::register_script('wc-single-product', $frontend_script_path . 'single-product' . $suffix . '.js');
     self::register_script('wc-country-select', $frontend_script_path . 'country-select' . $suffix . '.js');
     self::register_script('wc-address-i18n', $frontend_script_path . 'address-i18n' . $suffix . '.js');
     // Register frontend scripts conditionally
     if ($ajax_cart_en) {
         self::enqueue_script('wc-add-to-cart', $frontend_script_path . 'add-to-cart' . $suffix . '.js');
     }
     if (is_cart()) {
         self::enqueue_script('wc-cart', $frontend_script_path . 'cart' . $suffix . '.js', array('jquery', 'wc-country-select', 'wc-address-i18n'));
     }
     if (is_checkout() || is_page(get_option('woocommerce_myaccount_page_id'))) {
         self::enqueue_script('select2');
         wp_enqueue_style('select2', $assets_path . 'css/select2.css');
     }
     if (is_checkout()) {
         self::enqueue_script('wc-checkout', $frontend_script_path . 'checkout' . $suffix . '.js', array('jquery', 'woocommerce', 'wc-country-select', 'wc-address-i18n'));
     }
     if (is_add_payment_method_page()) {
         self::enqueue_script('wc-add-payment-method', $frontend_script_path . 'add-payment-method' . $suffix . '.js', array('jquery', 'woocommerce'));
     }
     if (is_lost_password_page()) {
         self::enqueue_script('wc-lost-password', $frontend_script_path . 'lost-password' . $suffix . '.js', array('jquery', 'woocommerce'));
     }
     if ($lightbox_en && (is_product() || !empty($post->post_content) && strstr($post->post_content, '[product_page'))) {
         self::enqueue_script('prettyPhoto', $assets_path . 'js/prettyPhoto/jquery.prettyPhoto' . $suffix . '.js', array('jquery'), '3.1.6', true);
         self::enqueue_script('prettyPhoto-init', $assets_path . 'js/prettyPhoto/jquery.prettyPhoto.init' . $suffix . '.js', array('jquery', 'prettyPhoto'));
         wp_enqueue_style('woocommerce_prettyPhoto_css', $assets_path . 'css/prettyPhoto.css');
     }
     if (is_product()) {
         self::enqueue_script('wc-single-product');
     }
     if ('geolocation_ajax' === get_option('woocommerce_default_customer_address')) {
         self::enqueue_script('wc-geolocation', $frontend_script_path . 'geolocation' . $suffix . '.js', array('jquery'));
     }
     // Global frontend scripts
     self::enqueue_script('woocommerce', $frontend_script_path . 'woocommerce' . $suffix . '.js', array('jquery', 'jquery-blockui'));
     self::enqueue_script('wc-cart-fragments', $frontend_script_path . 'cart-fragments' . $suffix . '.js', array('jquery', 'jquery-cookie'));
     // CSS Styles
     if ($enqueue_styles = self::get_styles()) {
         foreach ($enqueue_styles as $handle => $args) {
             wp_enqueue_style($handle, $args['src'], $args['deps'], $args['version'], $args['media']);
         }
     }
 }
 /**
  * Register/queue frontend scripts.
  */
 public static function load_scripts()
 {
     global $post;
     if (!did_action('before_woocommerce_init')) {
         return;
     }
     self::register_scripts();
     self::register_styles();
     if ('yes' === get_option('woocommerce_enable_ajax_add_to_cart')) {
         self::enqueue_script('wc-add-to-cart');
     }
     if (is_cart()) {
         self::enqueue_script('wc-cart');
     }
     if (is_checkout() || is_account_page()) {
         self::enqueue_script('select2');
         self::enqueue_style('select2');
         // Password strength meter. Load in checkout, account login and edit account page.
         if ('no' === get_option('woocommerce_registration_generate_password') && !is_user_logged_in() || is_edit_account_page() || is_lost_password_page()) {
             self::enqueue_script('wc-password-strength-meter');
         }
     }
     if (is_checkout()) {
         self::enqueue_script('wc-checkout');
     }
     if (is_add_payment_method_page()) {
         self::enqueue_script('wc-add-payment-method');
     }
     if (is_lost_password_page()) {
         self::enqueue_script('wc-lost-password');
     }
     if (is_product() || !empty($post->post_content) && strstr($post->post_content, '[product_page')) {
         self::enqueue_script('flexslider');
         self::enqueue_script('photoswipe-ui-default');
         self::enqueue_style('photoswipe-default-skin');
         self::enqueue_script('zoom');
         self::enqueue_script('wc-single-product');
     }
     if ('geolocation_ajax' === get_option('woocommerce_default_customer_address')) {
         $ua = wc_get_user_agent();
         // Exclude common bots from geolocation by user agent.
         if (!strstr($ua, 'bot') && !strstr($ua, 'spider') && !strstr($ua, 'crawl')) {
             self::enqueue_script('wc-geolocation');
         }
     }
     // Global frontend scripts
     self::enqueue_script('woocommerce');
     self::enqueue_script('wc-cart-fragments');
     // CSS Styles
     if ($enqueue_styles = self::get_styles()) {
         foreach ($enqueue_styles as $handle => $args) {
             self::enqueue_style($handle, $args['src'], $args['deps'], $args['version'], $args['media']);
         }
     }
 }