/** * 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')); }
/** * 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; }
/** * Conditionally remove any gateways that don't support pre-orders on the checkout page when the pre-order is charged * upon release. This is done because payment info is not required in this case so displaying gateways/payment fields * is not needed. * * @since 1.0 * @param array $available_gateways * @return array */ public function maybe_remove_unsupported_gateways($available_gateways) { // 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 && WC_Pre_Orders_Cart::cart_contains_pre_order() && WC_Pre_Orders_Product::product_is_charged_upon_release(WC_Pre_Orders_Cart::get_pre_order_product()) || defined('WOOCOMMERCE_CHECKOUT') && WOOCOMMERCE_CHECKOUT && WC_Pre_Orders_Cart::cart_contains_pre_order() && WC_Pre_Orders_Product::product_is_charged_upon_release(WC_Pre_Orders_Cart::get_pre_order_product())) { // remove any non-supported payment gateways foreach ($available_gateways as $gateway_id => $gateway) { if (!method_exists($gateway, 'supports') || false === $gateway->supports('pre-orders')) { unset($available_gateways[$gateway_id]); } } } return $available_gateways; }
public function load_stripe_scripts() { wp_enqueue_script('stripe', 'https://js.stripe.com/v2/', false, '2.0', true); wp_enqueue_script('stripewoojs', plugins_url('assets/js/stripewoo.js', __FILE__), array('stripe', 'wc-credit-card-form'), '', true); $stripe_array = array('stripe_publishablekey' => $this->stripe_sandbox == 'yes' ? $this->stripe_testpublickey : $this->stripe_livepublickey); if (is_checkout_pay_page()) { $order_key = urldecode($_GET['key']); $order_id = absint(get_query_var('order-pay')); $order = new WC_Order($order_id); if ($order->id == $order_id && $order->order_key == $order_key) { $stripe_array['billing_name'] = $order->billing_first_name . ' ' . $order->billing_last_name; $stripe_array['billing_address_1'] = $order->billing_address_1; $stripe_array['billing_address_2'] = $order->billing_address_2; $stripe_array['billing_city'] = $order->billing_city; $stripe_array['billing_state'] = $order->billing_state; $stripe_array['billing_postcode'] = $order->billing_postcode; $stripe_array['billing_country'] = $order->billing_country; } } wp_localize_script('stripewoojs', 'stripe_array', $stripe_array); }
/** * Pluggable function to render the checkout page payment fields form * * @since 1.0 * @param WC_Gateway_Intuit_QBMS_Credit_Card $gateway gateway object */ function woocommerce_intuit_qbms_payment_fields($gateway) { // safely display the description, if there is one if ($gateway->get_description()) { echo '<p>' . wp_kses_post($gateway->get_description()) . '</p>'; } $payment_method_defaults = array('account-number' => '', 'exp-month' => '', 'exp-year' => '', 'csc' => ''); // for the demo environment, display a notice and supply a default test payment method if ($gateway->is_environment('test')) { echo '<p>' . __('TEST MODE ENABLED', 'woocommerce-gateway-intuit-qbms') . '</p>'; $payment_method_defaults = array('account-number' => '4111111111111111', 'exp-month' => '1', 'exp-year' => date('Y') + 1, 'csc' => '123'); // convenience for testing error conditions $test_conditions = array('10200_comm' => __('CC Processing Gateway comm error', 'woocommerce-gateway-intuit-qbms'), '10201_login' => __('Processing Gateway login error', 'woocommerce-gateway-intuit-qbms'), '10301_ccinvalid' => __('Invalid CC account number', 'woocommerce-gateway-intuit-qbms'), '10400_insufffunds' => __('Insufficient funds', 'woocommerce-gateway-intuit-qbms'), '10401_decline' => __('Transaction declined', 'woocommerce-gateway-intuit-qbms'), '10403_acctinvalid' => __('Invalid merchant account', 'woocommerce-gateway-intuit-qbms'), '10404_referral' => __('Declined pending voice auth', 'woocommerce-gateway-intuit-qbms'), '10406_capture' => __('Capture error', 'woocommerce-gateway-intuit-qbms'), '10500_general' => __('General error', 'woocommerce-gateway-intuit-qbms'), '10000_avscvdfail' => __('AVS Failure', 'woocommerce-gateway-intuit-qbms')); echo '<select name="wc-intuit-qbms-test-condition">'; echo '<option value="">' . __('Test an Error Condition:', 'woocommerce-gateway-intuit-qbms') . '</option>'; foreach ($test_conditions as $key => $value) { echo '<option value="' . $key . '">' . $value . '</option>'; } echo '</select>'; } // tokenization is allowed if tokenization is enabled on the gateway $tokenization_allowed = $gateway->tokenization_enabled(); // on the pay page there is no way of creating an account, so disallow tokenization for guest customers if ($tokenization_allowed && is_checkout_pay_page() && !is_user_logged_in()) { $tokenization_allowed = false; } $tokens = array(); $default_new_card = true; if ($tokenization_allowed && is_user_logged_in()) { $tokens = $gateway->get_payment_tokens(get_current_user_id()); foreach ($tokens as $token) { if ($token->is_default()) { $default_new_card = false; break; } } } // load the payment fields template file woocommerce_get_template('checkout/intuit-qbms-payment-fields.php', array('payment_method_defaults' => $payment_method_defaults, 'enable_csc' => $gateway->csc_enabled(), 'tokens' => $tokens, 'tokenization_allowed' => $tokenization_allowed, 'tokenization_forced' => $gateway->tokenization_forced(), 'default_new_card' => $default_new_card), '', $gateway->get_plugin()->get_plugin_path() . '/templates/'); }
/** * payment_scripts function. * * Outputs scripts used for stripe payment * * @access public */ public function payment_scripts() { $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; if ($this->stripe_checkout) { wp_enqueue_script('stripe', 'https://checkout.stripe.com/v2/checkout.js', '', '2.0', true); wp_enqueue_script('woocommerce_stripe', plugins_url('assets/js/stripe_checkout' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array('stripe'), WC_STRIPE_VERSION, true); } else { wp_enqueue_script('stripe', 'https://js.stripe.com/v2/', '', '1.0', true); wp_enqueue_script('woocommerce_stripe', plugins_url('assets/js/stripe' . $suffix . '.js', WC_STRIPE_MAIN_FILE), array('jquery-payment', 'stripe'), WC_STRIPE_VERSION, true); } $stripe_params = array('key' => $this->publishable_key, 'i18n_terms' => __('Please accept the terms and conditions first', 'woocommerce-gateway-stripe'), 'i18n_required_fields' => __('Please fill in required checkout fields first', 'woocommerce-gateway-stripe')); // If we're on the pay page we need to pass stripe.js the address of the order. if (is_checkout_pay_page() && isset($_GET['order']) && isset($_GET['order_id'])) { $order_key = urldecode($_GET['order']); $order_id = absint($_GET['order_id']); $order = wc_get_order($order_id); if ($order->id === $order_id && $order->order_key === $order_key) { $stripe_params['billing_first_name'] = $order->billing_first_name; $stripe_params['billing_last_name'] = $order->billing_last_name; $stripe_params['billing_address_1'] = $order->billing_address_1; $stripe_params['billing_address_2'] = $order->billing_address_2; $stripe_params['billing_state'] = $order->billing_state; $stripe_params['billing_city'] = $order->billing_city; $stripe_params['billing_postcode'] = $order->billing_postcode; $stripe_params['billing_country'] = $order->billing_country; } } $stripe_params['no_prepaid_card_msg'] = __('Sorry, we\'re not accepting prepaid cards at this time.', 'woocommerce-gateway-stripe'); $stripe_params['allow_prepaid_card'] = apply_filters('wc_stripe_allow_prepaid_card', true) ? 'yes' : 'no'; $stripe_params['stripe_checkout_require_billing_address'] = apply_filters('wc_stripe_checkout_require_billing_address', false) ? 'yes' : 'no'; // localize error messages from Stripe $stripe_params['invalid_number'] = __('The card number is not a valid credit card number.', 'woocommerce-gateway-stripe'); $stripe_params['invalid_expiry_month'] = __('The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe'); $stripe_params['invalid_expiry_year'] = __('The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe'); $stripe_params['invalid_cvc'] = __('The card\'s security code is invalid.', 'woocommerce-gateway-stripe'); $stripe_params['incorrect_number'] = __('The card number is incorrect.', 'woocommerce-gateway-stripe'); $stripe_params['expired_card'] = __('The card has expired.', 'woocommerce-gateway-stripe'); $stripe_params['incorrect_cvc'] = __('The card\'s security code is incorrect.', 'woocommerce-gateway-stripe'); $stripe_params['incorrect_zip'] = __('The card\'s zip code failed validation.', 'woocommerce-gateway-stripe'); $stripe_params['card_declined'] = __('The card was declined.', 'woocommerce-gateway-stripe'); $stripe_params['missing'] = __('There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe'); $stripe_params['processing_error'] = __('An error occurred while processing the card.', 'woocommerce-gateway-stripe'); $stripe_params['invalid_request_error'] = __('Could not find payment information.', 'woocommerce-gateway-stripe'); wp_localize_script('woocommerce_stripe', 'wc_stripe_params', apply_filters('wc_stripe_params', $stripe_params)); }
function woo_special_nav_class($classes, $item) { if ((is_woocommerce() || is_product_category() || is_checkout() || is_checkout_pay_page() || is_cart()) && get_post_meta($item->ID, '_menu_item_object_id', true) == SHOP_ID) { $classes[] = 'current-menu-item'; } return $classes; }
/** * Enqueue scripts on Checkout * * @access public * @return void */ public function enqueue_scripts_on_checkout() { // Scripts only needed on the Checkout page if (!is_page(wc_get_page_id('checkout'))) { return; } // Different scripts for different Checkout styles if ($this->checkout_style == 'inline') { // External Stripe script wp_register_script('subscriptio_stripe_js', 'https://js.stripe.com/v2/'); // jQuery Payment Plugin if (!wp_script_is('jquery-payment', 'registered')) { wp_register_script('jquery-payment', SUBSCRIPTIO_PLUGIN_URL . '/assets/gateways/stripe/js/jquery.payment.min.js', array('jquery'), '1.1.2'); } // Plugin's script wp_register_script('subscriptio_stripe_inline', SUBSCRIPTIO_PLUGIN_URL . '/assets/gateways/stripe/js/frontend_inline.js', array('jquery'), SUBSCRIPTIO_VERSION); // Pass Stripe config to frontend $this->add_stripe_config('subscriptio_stripe_inline'); // Add billing details if payment is being made if (function_exists('is_checkout_pay_page') ? is_checkout_pay_page() : is_page(woocommerce_get_page_id('pay'))) { $this->add_billing_details('subscriptio_stripe_inline'); } // Enqueue scripts wp_enqueue_script('subscriptio_stripe_js'); wp_enqueue_script('jquery-payment'); wp_enqueue_script('subscriptio_stripe_inline'); } else { // External Stripe script wp_register_script('subscriptio_stripe_checkout_js', 'https://checkout.stripe.com/checkout.js'); // Plugin's script wp_register_script('subscriptio_stripe_modal', SUBSCRIPTIO_PLUGIN_URL . '/assets/gateways/stripe/js/frontend_modal.js', array('jquery'), SUBSCRIPTIO_VERSION); // Pass Stripe config to frontend $this->add_stripe_config('subscriptio_stripe_modal'); // Add billing details if payment is being made if (function_exists('is_checkout_pay_page') ? is_checkout_pay_page() : is_page(woocommerce_get_page_id('pay'))) { $this->add_billing_details('subscriptio_stripe_modal'); } // Enqueue scripts wp_enqueue_script('subscriptio_stripe_checkout_js'); wp_enqueue_script('subscriptio_stripe_modal'); } }
/** * Add scripts */ public function scripts() { $enqueue_scripts = is_cart() || is_checkout() || is_checkout_pay_page(); if (!apply_filters('woocommerce_amazon_pa_enqueue_scripts', $enqueue_scripts)) { return; } $type = 'yes' == $this->settings['enable_login_app'] ? 'app' : 'standard'; wp_enqueue_style('amazon_payments_advanced', plugins_url('assets/css/style.css', __FILE__)); wp_enqueue_script('amazon_payments_advanced_widgets', WC_Amazon_Payments_Advanced_API::get_widgets_url(), array(), '1.0', true); wp_enqueue_script('amazon_payments_advanced', plugins_url('assets/js/amazon-' . $type . '-widgets.js', __FILE__), array(), '1.0', true); $redirect_page = is_cart() ? add_query_arg('amazon_payments_advanced', 'true', get_permalink(woocommerce_get_page_id('checkout'))) : add_query_arg('amazon_payments_advanced', 'true'); $params = array('seller_id' => $this->settings['seller_id'], 'reference_id' => $this->reference_id, 'redirect' => esc_url_raw($redirect_page), 'is_checkout_pay_page' => is_checkout_pay_page(), 'is_checkout' => is_checkout(), 'access_token' => $this->access_token); if ('yes' == $this->settings['enable_login_app']) { $params['button_type'] = 'LwA'; $params['button_color'] = 'Gold'; $params['button_size'] = 'small'; $params['checkout_url'] = esc_url_raw(get_permalink(woocommerce_get_page_id('checkout'))); } if (class_exists('WC_Subscriptions_Cart')) { $cart_contains_subscription = WC_Subscriptions_Cart::cart_contains_subscription() || wcs_cart_contains_renewal(); $change_payment_for_subscription = isset($_GET['change_payment_method']) && wcs_is_subscription(absint($_GET['change_payment_method'])); $params['is_recurring'] = $cart_contains_subscription || $change_payment_for_subscription; } $params = array_map('esc_js', apply_filters('woocommerce_amazon_pa_widgets_params', $params)); wp_localize_script('amazon_payments_advanced', 'amazon_payments_advanced_params', $params); }
/** * Payment fields for Realex. * * @see WC_Payment_Gateway::payment_fields() */ public function payment_fields() { if ($this->threedsecure->is_3dsecure_available() && (!is_checkout_pay_page() || isset($_GET['pay_for_order']))) { parent::payment_fields(); ?> <style type="text/css">#payment ul.payment_methods li label[for='payment_method_realex'] img:nth-child(n+2) { margin-left:1px; }</style> <?php return; } // default to new card $card_ref = 'new'; if ($this->vault_available()) { // get the credit card tokens for the user $current_user = wp_get_current_user(); $credit_cards = array(); if ($current_user->ID) { $credit_cards = get_user_meta($current_user->ID, 'woocommerce_realex_cc', true); } // if there are saved cards, and one hasn't been selected, default to the first if ($credit_cards) { $card_ref = (object) current($credit_cards); $card_ref = $card_ref->ref; } } ?> <style type="text/css">#payment ul.payment_methods li label[for='payment_method_realex'] img:nth-child(n+2) { margin-left:1px; }</style> <fieldset> <?php if ($this->description) { ?> <p><?php echo esc_html($this->description); ?> <?php if ($this->is_test_mode()) { esc_html_e('TEST MODE ENABLED', 'woocommerce-gateway-realex'); } ?> </p><?php } ?> <?php if ($this->vault_available() && $credit_cards) { ?> <div> <p class="form-row form-row-first" style="width:65%;"> <?php foreach ($credit_cards as $credit_card) { $credit_card = (object) $credit_card; ?> <input type="radio" id="<?php echo esc_attr($credit_card->ref); ?> " name="realex_card_ref" style="width:auto;" value="<?php echo esc_attr($credit_card->ref); ?> " <?php checked($credit_card->ref, $card_ref); ?> /> <label style="display:inline;" for="<?php echo esc_attr($credit_card->ref); ?> "> <?php /* translators: Placeholders: %1$s - credit card type, %2$s - credit card last 4, %3$s - credit card expiration MM/YY */ printf(esc_html__('%1$s ending in %2$s (%3$s)', 'woocommerce-gateway-realex'), $this->card_type_options[$credit_card->type], $credit_card->last4, $credit_card->expiration_month . '/' . $credit_card->expiration_year); ?> </label><br /> <?php } ?> <input type="radio" id="realex_new" name="realex_card_ref" style="width:auto;" <?php checked('new', $card_ref); ?> value="0" /> <label style="display:inline;" for="realex_new"><?php esc_html_e('Use Another Credit Card', 'woocommerce-gateway-realex'); ?> </label> </p> <p class="form-row form-row-last" style="width:30%;"><a class="button" href="<?php echo esc_url(wc_get_page_permalink('myaccount')); ?> #saved-cards"><?php echo esc_html($this->managecards); ?> </a></p> <div style="clear:both;"></div> </div> <div class="clear"></div> <?php } ?> <div class="realex_vault_new" style="<?php echo $card_ref == 'new' ? '' : 'display:none;'; ?> "> <p class="form-row form-row-first"> <label for="realex_accountNumber"><?php echo __("Credit Card number", 'woocommerce-gateway-realex'); ?> <span class="required">*</span></label> <input type="text" class="input-text" id="realex_accountNumber" name="realex_accountNumber" maxlength="19" autocomplete="off" /> </p> <p class="form-row form-row-last"> <label for="realex_cardType"><?php _e('Card Type', 'woocommerce-gateway-realex'); ?> <span class="required">*</span></label> <select name="realex_cardType" id="realex_cardType" style="width:auto;"><br /> <option value=""> <?php foreach ($this->cardtypes as $type) { if (isset($this->card_type_options[$type])) { ?> <option value="<?php echo esc_attr(preg_replace('/-.*$/', '', $type)); ?> " rel="<?php echo esc_attr($type); ?> "><?php esc_html_e($this->card_type_options[$type], 'woocommerce-gateway-realex'); ?> </option> <?php } } ?> </select> </p> <div class="clear"></div> <p class="form-row form-row-first"> <label for="realex_expirationMonth"><?php esc_html_e('Expiration date', 'woocommerce-gateway-realex'); ?> <span class="required">*</span></label> <select name="realex_expirationMonth" id="realex_expirationMonth" class="woocommerce-select woocommerce-cc-month" style="width:auto;"> <option value=""><?php esc_attr_e('Month', 'woocommerce-gateway-realex'); ?> </option> <?php foreach (range(1, 12) as $month) { ?> <option value="<?php echo sprintf('%02d', $month); ?> "><?php echo sprintf('%02d', $month); ?> </option> <?php } ?> </select> <select name="realex_expirationYear" id="realex_expirationYear" class="woocommerce-select woocommerce-cc-year" style="width:auto;"> <option value=""><?php esc_attr_e('Year', 'woocommerce-gateway-realex'); ?> </option> <?php foreach (range(date('Y'), date('Y') + 20) as $year) { ?> <option value="<?php echo $year; ?> "><?php echo $year; ?> </option> <?php } ?> </select> </p> <?php if ($this->cvv == 'yes') { ?> <p class="form-row form-row-last"> <label for="realex_cvNumber"><?php esc_html_e('Card security code', 'woocommerce-gateway-realex'); ?> <span class="required">*</span></label> <input type="text" class="input-text" id="realex_cvNumber" name="realex_cvNumber" maxlength="4" style="width:60px" autocomplete="off" /> </p> <?php } ?> <?php if (in_array('SWITCH', $this->get_real_cardtypes())) { ?> <?php if ($this->cvv == 'no') { ?> <p class="form-row form-row-last" style="display:none;"> <?php } else { ?> <div class="clear"></div> <p class="form-row form-row-first" style="display:none;"> <?php } ?> <label for="realex_issueNumber"><?php esc_html_e('Issue Number', 'woocommerce-gateway-realex'); ?> </label> <input type="text" class="input-text" id="realex_issueNumber" name="realex_issueNumber" maxlength="3" style="width:60px" autocomplete="off" /> </p> <?php } ?> <div class="clear"></div> <?php if ($this->vault_available()) { ?> <?php if (wc_realex()->is_subscriptions_active() && WC_Subscriptions_Cart::cart_contains_subscription() && in_array('subscriptions', $this->supports)) { ?> <input name="realex_vault_new" type="hidden" value="1" /> <?php } else { /* Normal behavior */ ?> <div class="realex_create-account"> <p class="form-row"> <input id="realex_vault_new" name="realex_vault_new" type="checkbox" value="1" style="width:auto;" /> <label for="realex_vault_new" style="display:inline;"><?php echo esc_html($this->vaulttext); ?> </label> </p> </div> <div class="clear"></div> <?php } ?> <?php } ?> </div> </fieldset> <?php }
wp_head(); ?> </head> <?php $class_name = 'header--sticky'; if (wpgrade::option('nav_always_show')) { $class_name .= ' nav-scroll-show'; } else { $class_name .= ' nav-scroll-hide'; } $data_smoothscrolling = wpgrade::option('use_smooth_scroll') == 1 ? 'data-smoothscrolling' : ''; $data_main_color = wpgrade::option('main_color') ? 'data-color="' . wpgrade::option('main_color') . '"' : ''; //first let's test if we are in woocommerce if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) { //we need to setup post data if (is_shop() || is_cart() || is_checkout() || is_checkout_pay_page() || is_account_page() || is_order_received_page()) { $shop_page_id = wc_get_page_id('shop'); if (!empty($shop_page_id) && $shop_page_id != 0) { global $post; $post = get_post($shop_page_id); setup_postdata($post); $make_transparent_menu_bar = get_post_meta(wpgrade::lang_page_id(get_the_ID()), wpgrade::prefix() . 'header_transparent_menu_bar', true); if ($make_transparent_menu_bar == 'on') { $class_name .= ' header--transparent'; } } } } //make the header menu bar transparent //only for static pages if (is_page()) {
/** * Add scripts */ public function scripts() { wp_enqueue_style('amazon_payments_advanced', plugins_url('assets/css/style.css', __FILE__)); wp_enqueue_script('amazon_payments_advanced_widgets', WC_AMAZON_PA_WIDGETS_URL, '', '1.0', true); wp_enqueue_script('amazon_payments_advanced', plugins_url('assets/js/amazon-checkout.js', __FILE__), array('amazon_payments_advanced_widgets'), '1.0', true); $redirect_page = is_cart() ? add_query_arg('amazon_payments_advanced', 'true', get_permalink(woocommerce_get_page_id('checkout'))) : esc_url_raw(add_query_arg('amazon_payments_advanced', 'true')); $is_pay_page = function_exists('is_checkout_pay_page') ? is_checkout_pay_page() : is_page(woocommerce_get_page_id('pay')); wp_localize_script('amazon_payments_advanced', 'amazon_payments_advanced_params', array('seller_id' => $this->settings['seller_id'], 'reference_id' => $this->reference_id, 'redirect' => $redirect_page, 'is_checkout_pay_page' => $is_pay_page)); }
/** * Returns true if tokenization is allowed for the payment form. This is true * if both the gateway supports tokenization and it is enabled. * * Note that tokenization is not allowed on the pay page for guest customers, * as there is no way to create an account there. * * @since 4.0.0 * @return bool true if tokenization is allowed */ public function tokenization_allowed() { // tokenization is allowed if tokenization is enabled on the gateway $tokenization_allowed = $this->get_gateway()->supports_tokenization() && $this->get_gateway()->tokenization_enabled(); // on the pay page there is no way of creating an account, so disallow tokenization for guest customers if ($tokenization_allowed && is_checkout_pay_page() && !is_user_logged_in()) { $tokenization_allowed = false; } /** * Payment Gateway Payment Form Tokenization Allowed. * * Filters whether tokenization is allowed for the payment form. * * @since 4.0.0 * @param bool $tokenization_allowed * @param \SV_WC_Payment_Gateway_Payment_Form $this payment form instance */ return apply_filters('wc_' . $this->get_gateway()->get_id() . '_payment_form_tokenization_allowed', $tokenization_allowed, $this); }
/** * Replace a page title with the endpoint title * * @param string $title * @return string * @since 2.0 */ public static function change_payment_method_page_title($title) { if (is_main_query() && in_the_loop() && is_page() && is_checkout_pay_page() && self::$is_request_to_change_payment) { $title = __('Change Payment Method', 'woocommerce-subscriptions'); } return $title; }
/** * payment_scripts function. * * Outputs scripts used for stripe payment * * @access public */ public function payment_scripts() { if (!is_checkout()) { return; } if ($this->stripe_checkout) { wp_enqueue_script('stripe', 'https://checkout.stripe.com/v2/checkout.js', '', '2.0', true); wp_enqueue_script('woocommerce_stripe', plugins_url('assets/js/stripe_checkout.js', dirname(__FILE__)), array('stripe'), WC_STRIPE_VERSION, true); } else { wp_enqueue_script('stripe', 'https://js.stripe.com/v2/', '', '1.0', true); wp_enqueue_script('woocommerce_stripe', plugins_url('assets/js/stripe.js', dirname(__FILE__)), array('stripe'), WC_STRIPE_VERSION, true); } $stripe_params = array('key' => $this->publishable_key, 'i18n_terms' => __('Please accept the terms and conditions first', 'woocommerce-gateway-stripe'), 'i18n_required_fields' => __('Please fill in required checkout fields first', 'woocommerce-gateway-stripe')); // If we're on the pay page we need to pass stripe.js the address of the order. if (is_checkout_pay_page() && isset($_GET['order']) && isset($_GET['order_id'])) { $order_key = urldecode($_GET['order']); $order_id = absint($_GET['order_id']); $order = new WC_Order($order_id); if ($order->id == $order_id && $order->order_key == $order_key) { $stripe_params['billing_first_name'] = $order->billing_first_name; $stripe_params['billing_last_name'] = $order->billing_last_name; $stripe_params['billing_address_1'] = $order->billing_address_1; $stripe_params['billing_address_2'] = $order->billing_address_2; $stripe_params['billing_state'] = $order->billing_state; $stripe_params['billing_city'] = $order->billing_city; $stripe_params['billing_postcode'] = $order->billing_postcode; $stripe_params['billing_country'] = $order->billing_country; } } wp_localize_script('woocommerce_stripe', 'wc_stripe_params', $stripe_params); }
public static function is_checkout_pay_page() { return self::exists() && is_checkout_pay_page(); }
<?php if (function_exists('is_woocommerce') && (is_account_page() || is_shop() || is_product_taxonomy() || is_product() || is_cart() || is_checkout() || is_checkout_pay_page() || is_order_received_page() || is_wc_endpoint_url('order-pay') || is_wc_endpoint_url('order-received') || is_wc_endpoint_url('view-order') || is_wc_endpoint_url('edit-account') || is_wc_endpoint_url('edit-address') || is_wc_endpoint_url('lost-password') || is_wc_endpoint_url('customer-logout') || is_wc_endpoint_url('add-payment-method'))) { get_template_part('template/template-nowrap'); } else { get_template_part('template/template-page-normal'); }
/** * Maybe disable the gateway in 2 situations: * * 1) when the admin has opted not to show it at checkout * 2) when on the checkout > pay page as PPE does not yet support this * * @since 3.0.0 * @return bool|true */ public function is_available() { $is_available = parent::is_available(); // don't show on checkout page if (!$this->is_express_checkout() && is_checkout() && !$this->show_on_checkout()) { $is_available = false; } // don't display when order review table is rendered via AJAX if (!$this->is_express_checkout() && defined('DOING_AJAX') && DOING_AJAX && isset($_POST['action']) && $_POST['action'] == 'woocommerce_update_order_review' && !$this->show_on_checkout()) { $is_available = false; } // don't show on checkout > pay page if (is_checkout_pay_page()) { $is_available = false; } // don't show if the cart contains a subscription and manual renewals are not enabled if ($this->get_plugin()->is_subscriptions_active() && WC_Subscriptions_Cart::cart_contains_subscription() && 'no' === get_option(WC_Subscriptions_Admin::$option_prefix . '_accept_manual_renewals', 'no')) { $is_available = false; } return $is_available; }
/** * Has fields. * * @return bool */ public function has_fields() { return is_checkout_pay_page(); }
/** * payment_scripts function. * * Outputs scripts used for stripe payment * * @access public */ function payment_scripts() { if (!is_checkout()) { return; } if ($this->stripe_checkout) { wp_enqueue_script('stripe', 'https://checkout.stripe.com/v2/checkout.js', '', '2.0', true); wp_enqueue_script('woocommerce_stripe', plugins_url('assets/js/stripe_checkout.js', dirname(__FILE__)), array('stripe'), '2.0', true); } else { wp_enqueue_script('stripe', 'https://js.stripe.com/v1/', '', '1.0', true); wp_enqueue_script('woocommerce_stripe', plugins_url('assets/js/stripe.js', dirname(__FILE__)), array('stripe'), '1.0', true); } $stripe_params = array('key' => $this->publishable_key); // If we're on the pay page we need to pass stripe.js the address of the order. if (function_exists('is_checkout_pay_page') && is_checkout_pay_page() || !function_exists('is_checkout_pay_page') && is_page(woocommerce_get_page_id('pay'))) { $order_key = urldecode($_GET['order']); $order_id = (int) $_GET['order_id']; $order = new WC_Order($order_id); if ($order->id == $order_id && $order->order_key == $order_key) { $stripe_params['billing_first_name'] = $order->billing_first_name; $stripe_params['billing_last_name'] = $order->billing_last_name; $stripe_params['billing_address_1'] = $order->billing_address_1; $stripe_params['billing_address_2'] = $order->billing_address_2; $stripe_params['billing_state'] = $order->billing_state; $stripe_params['billing_city'] = $order->billing_city; $stripe_params['billing_postcode'] = $order->billing_postcode; $stripe_params['billing_country'] = $order->billing_country; } } wp_localize_script('woocommerce_stripe', 'wc_stripe_params', $stripe_params); }
public function wp_head() { //*** if the site is visited for the first time lets execute geo ip conditions $this->init_geo_currency(); //*** wp_enqueue_script('jquery'); wp_enqueue_script('wc-price-slider'); $currencies = $this->get_currencies(); ?> <script type="text/javascript"> var woocs_is_mobile = <?php echo (int) wp_is_mobile(); ?> ; var woocs_drop_down_view = "<?php echo $this->get_drop_down_view(); ?> "; var woocs_current_currency = <?php echo json_encode(isset($currencies[$this->current_currency]) ? $currencies[$this->current_currency] : $currencies[$this->default_currency]); ?> ; var woocs_default_currency = <?php echo json_encode($currencies[$this->default_currency]); ?> ; var woocs_array_of_get = '{}'; <?php if (!empty($_GET)) { ?> <?php //sanitization of $_GET array $sanitized_get_array = array(); foreach ($_GET as $key => $value) { $sanitized_get_array[$this->escape($key)] = $this->escape($value); } ?> woocs_array_of_get = '<?php echo str_replace("'", "", json_encode($sanitized_get_array)); ?> '; <?php } ?> woocs_array_no_cents = '<?php echo json_encode($this->no_cents); ?> '; var woocs_ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?> "; var woocs_lang_loading = "<?php _e('loading', 'woocommerce-currency-switcher'); ?> "; var woocs_shop_is_cached =<?php echo (int) $this->shop_is_cached; ?> ; </script> <?php if ($this->get_drop_down_view() == 'ddslick') { wp_enqueue_script('jquery.ddslick.min', WOOCS_LINK . 'js/jquery.ddslick.min.js', array('jquery')); } if ($this->get_drop_down_view() == 'chosen' or $this->get_drop_down_view() == 'chosen_dark') { wp_enqueue_script('chosen-drop-down', WOOCS_LINK . 'js/chosen/chosen.jquery.min.js', array('jquery')); wp_enqueue_style('chosen-drop-down', WOOCS_LINK . 'js/chosen/chosen.min.css'); //dark chosen if ($this->get_drop_down_view() == 'chosen_dark') { wp_enqueue_style('chosen-drop-down-dark', WOOCS_LINK . 'js/chosen/chosen-dark.css'); } } if ($this->get_drop_down_view() == 'wselect') { wp_enqueue_script('woocs_wselect', WOOCS_LINK . 'js/wselect/wSelect.min.js', array('jquery')); wp_enqueue_style('woocs_wselect', WOOCS_LINK . 'js/wselect/wSelect.css'); } //+++ wp_enqueue_style('woocommerce-currency-switcher', WOOCS_LINK . 'css/front.css'); wp_enqueue_script('woocommerce-currency-switcher', WOOCS_LINK . 'js/front.js', array('jquery')); //+++ //trick for refreshing header cart after currency changing - code left just for history if (isset($_GET['currency'])) { //wp-content\plugins\woocommerce\includes\class-wc-cart.php //apply_filters('woocommerce_update_cart_action_cart_updated', true); //$this->current_currency = $_GET['currency']; //$_POST['update_cart'] = 1; //WC_Form_Handler::update_cart_action(); //private function set_cart_cookies //wc_setcookie('woocommerce_items_in_cart', 0, time() - HOUR_IN_SECONDS); //wc_setcookie('woocommerce_cart_hash', '', time() - HOUR_IN_SECONDS); //do_action('woocommerce_cart_reset', WC()->cart, true); //do_action('woocommerce_calculate_totals', WC()->cart); } //if customer paying pending order from the front //checkout/order-pay/1044/?pay_for_order=true&key=order_55b764a4b7990 if (isset($_GET['pay_for_order']) and is_checkout_pay_page()) { if ($_GET['pay_for_order'] == 'true' and isset($_GET['key'])) { $order_id = wc_get_order_id_by_order_key($_GET['key']); $currency = get_post_meta($order_id, '_order_currency', TRUE); $this->current_currency = $currency; $this->storage->set_val('woocs_current_currency', $currency); } } //+++ //if we want to be paid in the basic currency - not multiple mode if (!$this->is_multiple_allowed) { if (is_checkout() or is_checkout_pay_page()) { $this->reset_currency(); } } //logic hack for some cases when shipping for example is wrong in //non multiple mode but customer doesn work allow pay in user selected currency if ($this->is_multiple_allowed) { if ((is_checkout() or is_checkout_pay_page()) and $this->bones['reset_in_multiple']) { $this->reset_currency(); } } }
/** * Returns true if on the pay page and this is the currently selected gateway * * @since 1.0.0 * @return mixed true if on pay page and is currently selected gateways, false if on pay page and not the selected gateway, null otherwise */ public function is_pay_page_gateway() { if (is_checkout_pay_page()) { $order_id = $this->get_checkout_pay_page_order_id(); if ($order_id) { $order = wc_get_order($order_id); return $order->payment_method == $this->get_id(); } } return null; }
/** * payment_scripts function. * * Outputs scripts used for openpay payment * * @access public */ public function payment_scripts() { if (!is_checkout()) { return; } global $woocommerce; wp_enqueue_script('openpay_js', 'https://openpay.s3.amazonaws.com/openpay.v1.min.js', '', '', true); wp_enqueue_script('openpay_fraud_js', 'https://openpay.s3.amazonaws.com/openpay-data.v1.min.js', '', '', true); wp_enqueue_script('payment', WP_PLUGIN_URL . "/" . plugin_basename(dirname(__FILE__)) . '/assets/js/jquery.payment.js', '', '', true); wp_enqueue_script('openpay', WP_PLUGIN_URL . "/" . plugin_basename(dirname(__FILE__)) . '/assets/js/openpay.js', '', '1.0', true); $openpay_params = array('merchant_id' => $this->merchant_id, 'public_key' => $this->publishable_key, 'sandbox_mode' => $this->is_sandbox, 'total' => $woocommerce->cart->total, 'currency' => get_woocommerce_currency()); // If we're on the pay page we need to pass openpay.js the address of the order. if (is_checkout_pay_page() && isset($_GET['order']) && isset($_GET['order_id'])) { $order_key = urldecode($_GET['order']); $order_id = absint($_GET['order_id']); $order = new WC_Order($order_id); if ($order->id == $order_id && $order->order_key == $order_key) { $openpay_params['billing_first_name'] = $order->billing_first_name; $openpay_params['billing_last_name'] = $order->billing_last_name; $openpay_params['billing_address_1'] = $order->billing_address_1; $openpay_params['billing_address_2'] = $order->billing_address_2; $openpay_params['billing_state'] = $order->billing_state; $openpay_params['billing_city'] = $order->billing_city; $openpay_params['billing_postcode'] = $order->billing_postcode; $openpay_params['billing_country'] = $order->billing_country; } } wp_localize_script('openpay', 'wc_openpay_params', $openpay_params); }
public function wp_head() { wp_enqueue_script('jquery'); $currencies = $this->get_currencies(); ?> <script type="text/javascript"> var woocs_drop_down_view = "<?php echo $this->get_drop_down_view(); ?> "; var woocs_current_currency = <?php echo json_encode(isset($currencies[$this->current_currency]) ? $currencies[$this->current_currency] : $currencies[$this->default_currency]); ?> ; var woocs_default_currency = <?php echo json_encode($currencies[$this->default_currency]); ?> ; var woocs_array_of_get = '{}'; <?php if (!empty($_GET)) { ?> woocs_array_of_get = '<?php echo json_encode($_GET); ?> '; <?php } ?> woocs_array_no_cents = '<?php echo json_encode($this->no_cents); ?> '; var woocs_ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?> "; var woocs_lang_loading = "<?php _e('loading', 'woocommerce-currency-switcher'); ?> "; </script> <?php if ($this->get_drop_down_view() == 'ddslick') { wp_enqueue_script('jquery.ddslick.min', WOOCS_LINK . 'js/jquery.ddslick.min.js', array('jquery')); } if ($this->get_drop_down_view() == 'chosen' or $this->get_drop_down_view() == 'chosen_dark') { wp_enqueue_script('chosen-drop-down', WOOCS_LINK . 'js/chosen/chosen.jquery.min.js', array('jquery')); wp_enqueue_style('chosen-drop-down', WOOCS_LINK . 'js/chosen/chosen.min.css'); //dark chosen if ($this->get_drop_down_view() == 'chosen_dark') { wp_enqueue_style('chosen-drop-down-dark', WOOCS_LINK . 'js/chosen/chosen-dark.css'); } } if ($this->get_drop_down_view() == 'wselect') { wp_enqueue_script('woocs_wselect', WOOCS_LINK . 'js/wselect/wSelect.min.js', array('jquery')); wp_enqueue_style('woocs_wselect', WOOCS_LINK . 'js/wselect/wSelect.css'); } //+++ wp_enqueue_style('woocommerce-currency-switcher', WOOCS_LINK . 'css/front.css'); wp_enqueue_script('woocommerce-currency-switcher', WOOCS_LINK . 'js/front.js', array('jquery')); //+++ //trick for refreshing header cart after currency changing - code left just for history if (isset($_GET['currency'])) { //wp-content\plugins\woocommerce\includes\class-wc-cart.php //apply_filters('woocommerce_update_cart_action_cart_updated', true); //$this->current_currency = $_GET['currency']; //$_POST['update_cart'] = 1; //WC_Form_Handler::update_cart_action(); //private function set_cart_cookies //wc_setcookie('woocommerce_items_in_cart', 0, time() - HOUR_IN_SECONDS); //wc_setcookie('woocommerce_cart_hash', '', time() - HOUR_IN_SECONDS); //do_action('woocommerce_cart_reset', WC()->cart, true); //do_action('woocommerce_calculate_totals', WC()->cart); } //if customer paying pending order from the front //checkout/order-pay/1044/?pay_for_order=true&key=order_55b764a4b7990 if (isset($_GET['pay_for_order']) and is_checkout_pay_page()) { if ($_GET['pay_for_order'] == 'true' and isset($_GET['key'])) { $order_id = wc_get_order_id_by_order_key($_GET['key']); $currency = get_post_meta($order_id, '_order_currency', TRUE); $this->current_currency = $currency; $this->storage->set_val('woocs_current_currency', $currency); } } //+++ //if we want to be paid in the basic currency - not multiple mode if (!$this->is_multiple_allowed) { if (is_checkout() or is_checkout_pay_page()) { $this->reset_currency(); } } }
/** * Load dependent scripts * - stripe.js from the stripe servers * - s4wc.js for handling the data to submit to stripe * * @access public * @return void */ public function load_scripts() { global $s4wc; // Main stripe js wp_enqueue_script('stripe', 'https://js.stripe.com/v2/', false, '2.0', true); // Plugin js wp_enqueue_script('s4wc_js', plugins_url('assets/js/s4wc.min.js', dirname(__FILE__)), array('stripe', 'wc-credit-card-form'), '1.36', true); // Add data that s4wc.js needs $s4wc_info = array('publishableKey' => $s4wc->settings['publishable_key'], 'savedCardsEnabled' => $s4wc->settings['saved_cards'] === 'yes' ? true : false, 'hasCard' => $this->stripe_customer_info && count($this->stripe_customer_info['cards']) ? true : false); // If we're on the pay page, Stripe needs the address if (is_checkout_pay_page()) { $order_key = urldecode($_GET['key']); $order_id = absint(get_query_var('order-pay')); $order = new WC_Order($order_id); if ($order->id == $order_id && $order->order_key == $order_key) { $s4wc_info['billing_name'] = $order->billing_first_name . ' ' . $order->billing_last_name; $s4wc_info['billing_address_1'] = $order->billing_address_1; $s4wc_info['billing_address_2'] = $order->billing_address_2; $s4wc_info['billing_city'] = $order->billing_city; $s4wc_info['billing_state'] = $order->billing_state; $s4wc_info['billing_postcode'] = $order->billing_postcode; $s4wc_info['billing_country'] = $order->billing_country; } } wp_localize_script('s4wc_js', 's4wc_info', $s4wc_info); }
/** * Sets up theme defaults and registers support for various WordPress features. */ function get_woocommerce_page_id() { if (is_shop()) { return get_option('woocommerce_shop_page_id'); } elseif (is_cart()) { return get_option('woocommerce_cart_page_id'); } elseif (is_checkout()) { return get_option('woocommerce_checkout_page_id'); } elseif (is_checkout_pay_page()) { return get_option('woocommerce_pay_page_id'); } elseif (is_account_page()) { return get_option('woocommerce_myaccount_page_id'); } return false; }
function reset_cart_front() { global $woocommerce; if (is_checkout_pay_page()) { $woocommerce->cart->empty_cart(); } }
public function load_scripts() { global $securionpay4wc; wp_enqueue_script('securionpay', 'https://securionpay.com/js/securionpay.js', false, false, true); wp_enqueue_script('securionpay4wc_js', plugins_url('assets/js/securionpay4wc.js', dirname(__FILE__)), array('securionpay', 'wc-credit-card-form'), false, true); $data = array('publicKey' => $this->api->getPublicKey()); if (is_checkout_pay_page()) { $order_key = urldecode($_GET['key']); $order_id = absint(get_query_var('order-pay')); $order = new WC_Order($order_id); if ($order->id == $order_id && $order->order_key == $order_key) { $data['billing_name'] = $order->billing_first_name . ' ' . $order->billing_last_name; $data['billing_address_1'] = $order->billing_address_1; $data['billing_address_2'] = $order->billing_address_2; $data['billing_city'] = $order->billing_city; $data['billing_state'] = $order->billing_state; $data['billing_postcode'] = $order->billing_postcode; $data['billing_country'] = $order->billing_country; } } wp_localize_script('securionpay4wc_js', 'securionpay4wc_data', $data); }
/** * Returns true if on the pay page, false otherwise * * @since 1.0 * @return boolean true if on the pay page, false otherwise */ public static function is_checkout_pay_page() { if (self::is_wc_version_gte_2_1()) { return is_checkout_pay_page(); } else { return is_page(woocommerce_get_page_id('pay')); } }