/**
 * Handle redirects before content is output - hooked into template_redirect so is_page works.
 */
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')) && WC()->cart->is_empty() && empty($wp->query_vars['order-pay']) && !isset($wp->query_vars['order-received'])) {
        wp_redirect(wc_get_page_permalink('cart'));
        exit;
    } elseif (isset($wp->query_vars['customer-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 === $wp_query->found_posts) {
        $product = wc_get_product($wp_query->post);
        if ($product && $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();
    }
}
/**
 * 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();
    }
}
 /**
  * Backports wc_checkout_is_https() to 2.4.x
  *
  * @since  4.3.0-beta
  * @return bool
  */
 public static function wc_checkout_is_https()
 {
     if (self::is_wc_version_gte_2_5()) {
         return wc_checkout_is_https();
     } else {
         return wc_site_is_https() || 'yes' === get_option('woocommerce_force_ssl_checkout') || class_exists('WordPressHTTPS') || strstr(wc_get_page_permalink('checkout'), 'https:');
     }
 }
 /**
  * @param $page
  */
 function get_url($page)
 {
     switch ($page) {
         case 'sign_out':
             return wc_get_endpoint_url('customer-logout', '', wc_get_page_permalink('myaccount'));
         case 'edit_account_url':
             return wc_customer_edit_account_url();
     }
 }
示例#5
0
 /**
  * Test get_remove_url
  *
  * @since 2.3
  */
 public function test_get_remove_url()
 {
     // Get the cart page id
     $cart_page_url = wc_get_page_permalink('cart');
     // Test cart item key
     $cart_item_key = 'test';
     // Do the check
     $this->assertEquals(apply_filters('woocommerce_get_remove_url', $cart_page_url ? wp_nonce_url(add_query_arg('remove_item', $cart_item_key, $cart_page_url), 'woocommerce-cart') : ''), WC()->cart->get_remove_url($cart_item_key));
 }
 /**
  * Get the page permalink
  *
  * Backports wc_page_page_permalink to WC 2.3.3 and lower
  *
  * @link https://github.com/woothemes/woocommerce/pull/7438
  *
  * @since 4.0.0
  * @param string $page page - myaccount, edit_address, shop, cart, checkout, pay, view_order, terms
  * @return string
  */
 public static function wc_get_page_permalink($page)
 {
     if (self::is_wc_version_gt('2.3.3')) {
         return wc_get_page_permalink($page);
     } else {
         $permalink = get_permalink(wc_get_page_id($page));
         return apply_filters('woocommerce_get_' . $page . '_page_permalink', $permalink);
     }
 }
 /**
  * Process the remove or re-add a line item from a subscription request.
  *
  * @since 2.0
  */
 public static function maybe_remove_or_add_item_to_subscription()
 {
     if (isset($_GET['subscription_id']) && (isset($_GET['remove_item']) || isset($_GET['undo_remove_item'])) && isset($_GET['_wpnonce'])) {
         $subscription = wcs_is_subscription($_GET['subscription_id']) ? wcs_get_subscription($_GET['subscription_id']) : false;
         $undo_request = isset($_GET['undo_remove_item']) ? true : false;
         $item_id = $undo_request ? $_GET['undo_remove_item'] : $_GET['remove_item'];
         if (false === $subscription) {
             wc_add_notice(sprintf(_x('Subscription #%d does not exist.', 'hash before subscription ID', 'woocommerce-subscriptions'), $_GET['subscription_id']), 'error');
             wp_safe_redirect(wc_get_page_permalink('myaccount'));
             exit;
         }
         if (self::validate_remove_items_request($subscription, $item_id, $undo_request)) {
             if ($undo_request) {
                 // handle undo request
                 $removed_item = WC()->session->get('removed_subscription_items', array());
                 if (!empty($removed_item[$item_id]) && $subscription->id == $removed_item[$item_id]) {
                     // restore the item
                     wc_update_order_item($item_id, array('order_item_type' => 'line_item'));
                     unset($removed_item[$item_id]);
                     WC()->session->set('removed_subscription_items', $removed_item);
                     // restore download permissions for this item
                     $line_items = $subscription->get_items();
                     $line_item = $line_items[$item_id];
                     $_product = $subscription->get_product_from_item($line_item);
                     $product_id = wcs_get_canonical_product_id($line_item);
                     if ($_product && $_product->exists() && $_product->is_downloadable()) {
                         $downloads = $_product->get_files();
                         foreach (array_keys($downloads) as $download_id) {
                             wc_downloadable_file_permission($download_id, $product_id, $subscription, $line_item['qty']);
                         }
                     }
                     // translators: 1$: product name, 2$: product id
                     $subscription->add_order_note(sprintf(_x('Customer added "%1$s" (Product ID: #%2$d) via the My Account page.', 'used in order note', 'woocommerce-subscriptions'), wcs_get_line_item_name($line_item), $product_id));
                 } else {
                     wc_add_notice(__('Your request to undo your previous action was unsuccessful.', 'woocommerce-subscriptions'));
                 }
             } else {
                 // handle remove item requests
                 WC()->session->set('removed_subscription_items', array($item_id => $subscription->id));
                 // remove download access for the item
                 $line_items = $subscription->get_items();
                 $line_item = $line_items[$item_id];
                 $product_id = wcs_get_canonical_product_id($line_item);
                 WCS_Download_Handler::revoke_downloadable_file_permission($product_id, $subscription->id, $subscription->get_user_id());
                 // remove the line item from subscription but preserve its data in the DB
                 wc_update_order_item($item_id, array('order_item_type' => 'line_item_removed'));
                 // translators: 1$: product name, 2$: product id
                 $subscription->add_order_note(sprintf(_x('Customer removed "%1$s" (Product ID: #%2$d) via the My Account page.', 'used in order note', 'woocommerce-subscriptions'), wcs_get_line_item_name($line_item), $product_id));
                 // translators: placeholders are 1$: item name, and, 2$: opening and, 3$: closing link tags
                 wc_add_notice(sprintf(__('You have successfully removed "%1$s" from your subscription. %2$sUndo?%3$s', 'woocommerce-subscriptions'), $line_item['name'], '<a href="' . esc_url(self::get_undo_remove_url($subscription->id, $item_id, $subscription->get_view_order_url())) . '" >', '</a>'));
             }
         }
         $subscription->calculate_totals();
         wp_safe_redirect($subscription->get_view_order_url());
         exit;
     }
 }
 /**
  * Get the return url (thank you page).
  *
  * @param WC_Order $order
  * @return string
  */
 public function get_return_url($order = null)
 {
     if ($order) {
         $return_url = $order->get_checkout_order_received_url();
     } else {
         $return_url = wc_get_endpoint_url('order-received', '', wc_get_page_permalink('checkout'));
     }
     if (is_ssl() || get_option('woocommerce_force_ssl_checkout') == 'yes') {
         $return_url = str_replace('http:', 'https:', $return_url);
     }
     return apply_filters('woocommerce_get_return_url', $return_url, $order);
 }
    function flatsome_continue_shopping()
    {
        ?>
 
     <a class="button-continue-shopping button alt-button small"  href="<?php 
        echo wc_get_page_permalink('shop');
        ?>
">
        &#8592; <?php 
        echo __('Continue Shopping', 'woocommerce');
        ?>
</a> 
     <?php 
    }
示例#10
0
function user_autologout()
{
    if (is_user_logged_in()) {
        $current_user = wp_get_current_user();
        $user_id = $current_user->ID;
        $approved_status = get_user_meta($user_id, 'wp-approve-user', true);
        //if the user hasn't been approved yet by WP Approve User plugin, destroy the cookie to kill the session and log them out
        if ($approved_status == 1) {
            return wc_get_page_permalink('myaccount');
            //return $redirect_url;
        } else {
            return get_edit_billing_address_url();
            // wp_logout();
            // return get_permalink( wc_get_page_id( 'myaccount' ) ) . "?approved=false";
        }
    }
}
示例#11
0
/**
 * Add to cart messages.
 *
 * @access public
 * @param int|array $product_id
 */
function wc_add_to_cart_message($product_id)
{
    if (is_array($product_id)) {
        $titles = array();
        foreach ($product_id as $id) {
            $titles[] = get_the_title($id);
        }
        $added_text = sprintf(__('Added %s to your cart.', 'woocommerce'), wc_format_list_of_items($titles));
    } else {
        $added_text = sprintf(__('&quot;%s&quot; was successfully added to your cart.', 'woocommerce'), get_the_title($product_id));
    }
    // Output success messages
    if (get_option('woocommerce_cart_redirect_after_add') == 'yes') {
        $return_to = apply_filters('woocommerce_continue_shopping_redirect', wp_get_referer() ? wp_get_referer() : home_url());
        $message = sprintf('<p class="[ text-center ]"> %3$s <br /><br /><a href="%s" class="[ button button--primary ][ no-margin ][ pull-none ][ wc-forward ]">%s</a></p>', $return_to, __('Continue Shopping', 'woocommerce'), $added_text);
    } else {
        $message = sprintf('<p class="[ text-center ]"> %3$s <br /><br /><a href="%s" class="[ button button--primary ][ no-margin ][ pull-none ][ wc-forward ]">%s</a></p>', wc_get_page_permalink('cart'), __('View Cart', 'woocommerce'), $added_text);
    }
    wc_add_notice(apply_filters('wc_add_to_cart_message', $message, $product_id));
}
 /**
  * Pluggable function to render social login "link your account" buttons
  *
  * @since 1.1.0
  * @param string $return_url Return url, defaults my account page
  */
 function woocommerce_social_login_link_account_buttons($return_url = null)
 {
     if (!is_user_logged_in()) {
         return;
     }
     // If no return_url, use the my account page
     if (!$return_url) {
         $return_url = wc_get_page_permalink('myaccount');
     }
     // Enqueue styles and scripts
     wc_social_login()->frontend->load_styles_scripts();
     $available_providers = array();
     // determine available providers for user
     foreach (wc_social_login()->get_available_providers() as $provider) {
         if (!get_user_meta(get_current_user_id(), '_wc_social_login_' . $provider->get_id() . '_profile', true)) {
             $available_providers[] = $provider;
         }
     }
     // load the template
     wc_get_template('global/social-login-link-account.php', array('available_providers' => $available_providers, 'return_url' => $return_url), '', wc_social_login()->get_plugin_path() . '/templates/');
 }
/**
 * Add to cart messages.
 *
 * @access public
 * @param int|array $product_id
 */
function wc_add_to_cart_message($product_id)
{
    $titles = array();
    if (is_array($product_id)) {
        foreach ($product_id as $id) {
            $titles[] = get_the_title($id);
        }
    } else {
        $titles[] = get_the_title($product_id);
    }
    $titles = array_filter($titles);
    $added_text = sprintf(_n('%s has been added to your cart.', '%s have been added to your cart.', sizeof($titles), 'woocommerce'), wc_format_list_of_items($titles));
    // Output success messages
    if ('yes' === get_option('woocommerce_cart_redirect_after_add')) {
        $return_to = apply_filters('woocommerce_continue_shopping_redirect', wp_get_referer() ? wp_get_referer() : home_url());
        $message = sprintf('<a href="%s" class="button wc-forward">%s</a> %s', esc_url($return_to), esc_html__('Continue Shopping', 'woocommerce'), esc_html($added_text));
    } else {
        $message = sprintf('<a href="%s" class="button wc-forward">%s</a> %s', esc_url(wc_get_page_permalink('cart')), esc_html__('View Cart', 'woocommerce'), esc_html($added_text));
    }
    wc_add_notice(apply_filters('wc_add_to_cart_message', $message, $product_id));
}
        ?>
</p>

		<p>
			<a href="<?php 
        echo esc_url($order->get_checkout_payment_url());
        ?>
" class="button pay"><?php 
        _e('Pay', WC_QD_TXT);
        ?>
</a>
			<?php 
        if (is_user_logged_in()) {
            ?>
			<a href="<?php 
            echo esc_url(wc_get_page_permalink('myaccount'));
            ?>
" class="button pay"><?php 
            _e('My Account', WC_QD_TXT);
            ?>
</a>
			<?php 
        }
        ?>
		</p>

	<?php 
    } else {
        ?>

		<p><?php 
 /**
  * Show the add payment method page
  */
 private static function add_payment_method()
 {
     if (!is_user_logged_in()) {
         wp_safe_redirect(wc_get_page_permalink('myaccount'));
         exit;
     } else {
         do_action('before_woocommerce_add_payment_method');
         wc_add_notice(__('Add a new payment method.', 'woocommerce'), 'notice');
         wc_print_notices();
         // Add payment method form
         wc_get_template('myaccount/form-add-payment-method.php');
         wc_print_notices();
         do_action('after_woocommerce_add_payment_method');
     }
 }
示例#16
0
 /**
  * Prevent any user who cannot 'edit_posts' (subscribers, customers etc) from accessing admin.
  */
 public function prevent_admin_access()
 {
     $prevent_access = false;
     if ('yes' === get_option('woocommerce_lock_down_admin', 'yes') && !is_ajax() && basename($_SERVER["SCRIPT_FILENAME"]) !== 'admin-post.php') {
         $has_cap = false;
         $access_caps = array('edit_posts', 'manage_woocommerce', 'view_admin_dashboard');
         foreach ($access_caps as $access_cap) {
             if (current_user_can($access_cap)) {
                 $has_cap = true;
                 break;
             }
         }
         if (!$has_cap) {
             $prevent_access = true;
         }
     }
     if (apply_filters('woocommerce_prevent_admin_access', $prevent_access)) {
         wp_safe_redirect(wc_get_page_permalink('myaccount'));
         exit;
     }
 }
示例#17
0
/**
 * Disable author archives for customers.
 *
 * @since 2.5.0
 */
function wc_disable_author_archives_for_customers()
{
    global $wp_query, $author;
    if (is_author()) {
        $user = get_user_by('id', $author);
        if (isset($user->roles[0]) && 'customer' === $user->roles[0]) {
            wp_redirect(wc_get_page_permalink('shop'));
        }
    }
}
/**
 * Gets the url to the checkout page.
 *
 * @since  2.5.0
 *
 * @return string Url to checkout page
 */
function wc_get_checkout_url()
{
    $checkout_url = wc_get_page_permalink('checkout');
    if ($checkout_url) {
        // Force SSL if needed
        if (is_ssl() || 'yes' === get_option('woocommerce_force_ssl_checkout')) {
            $checkout_url = str_replace('http:', 'https:', $checkout_url);
        }
    }
    return apply_filters('woocommerce_get_checkout_url', $checkout_url);
}
 /**
  * Return handler for Hosted Payments.
  */
 public function return_handler()
 {
     @ob_clean();
     header('HTTP/1.1 200 OK');
     if (isset($_REQUEST['reference']) && isset($_REQUEST['paymentId']) && isset($_REQUEST['signature'])) {
         $signature = strtoupper(md5($_REQUEST['amount'] . $_REQUEST['reference'] . $_REQUEST['paymentId'] . $_REQUEST['paymentDate'] . $_REQUEST['paymentStatus'] . $this->private_key));
         $order_id = absint($_REQUEST['reference']);
         $order = wc_get_order($order_id);
         if ($signature === $_REQUEST['signature']) {
             $order_complete = $this->process_order_status($order, $_REQUEST['paymentId'], $_REQUEST['paymentStatus'], $_REQUEST['paymentDate']);
             if (!$order_complete) {
                 $order->update_status('failed', __('Payment was declined by Simplify Commerce.', 'woocommerce'));
             }
             wp_redirect($this->get_return_url($order));
             exit;
         }
     }
     wp_redirect(wc_get_page_permalink('cart'));
     exit;
 }
示例#20
0
					<td class="order-total" data-title="<?php 
        _e('Total', 'woocommerce');
        ?>
">
						<?php 
        echo sprintf(_n('%s for %s item', '%s for %s items', $item_count, 'woocommerce'), $order->get_formatted_order_total(), $item_count);
        ?>
					</td>
					<td class="order-actions">
						<?php 
        $actions = array();
        if (in_array($order->get_status(), apply_filters('woocommerce_valid_order_statuses_for_payment', array('pending', 'failed'), $order))) {
            $actions['pay'] = array('url' => $order->get_checkout_payment_url(), 'name' => __('Pay', 'woocommerce'));
        }
        if (in_array($order->get_status(), apply_filters('woocommerce_valid_order_statuses_for_cancel', array('pending', 'failed'), $order))) {
            $actions['cancel'] = array('url' => $order->get_cancel_order_url(wc_get_page_permalink('myaccount')), 'name' => __('Cancel', 'woocommerce'));
        }
        $actions['view'] = array('url' => $order->get_view_order_url(), 'name' => __('View', 'woocommerce'));
        $actions = apply_filters('woocommerce_my_account_my_orders_actions', $actions, $order);
        if ($actions) {
            foreach ($actions as $key => $action) {
                echo '<a href="' . esc_url($action['url']) . '" class="button ' . sanitize_html_class($key) . '">' . esc_html($action['name']) . '</a>';
            }
        }
        ?>
					</td>
				</tr><?php 
    }
    ?>
</tbody>
示例#21
0
/**
 * Empty cart page
 *
 * @author  WooThemes
 * @package WooCommerce/Templates
 * @version 2.0.0
 */
if (!defined('ABSPATH')) {
    exit;
    // Exit if accessed directly
}
//wc_print_notices();
?>

<p class="cart-empty"><?php 
_e('Your cart is currently empty.', 'woocommerce');
?>
</p>

<?php 
do_action('woocommerce_cart_is_empty');
?>

<p class="return-to-shop"><a class="button wc-backward" href="<?php 
echo esc_url(apply_filters('woocommerce_return_to_shop_redirect', wc_get_page_permalink('shop')));
?>
"><?php 
_e('Return To Shop', 'woocommerce');
?>
</a></p>
/**
 * Get the link to the edit account details page.
 *
 * @return string
 */
function wc_customer_edit_account_url()
{
    $edit_account_url = wc_get_endpoint_url('edit-account', '', wc_get_page_permalink('myaccount'));
    return apply_filters('woocommerce_customer_edit_account_url', $edit_account_url);
}
 /**
  * Frontend scripts
  */
 public function enqueue_scripts()
 {
     $settings = wc_gateway_ppec()->settings;
     $client = wc_gateway_ppec()->client;
     if (!$client->get_payer_id()) {
         return;
     }
     wp_enqueue_style('wc-gateway-ppec-frontend-cart', wc_gateway_ppec()->plugin_url . 'assets/css/wc-gateway-ppec-frontend-cart.css');
     if (is_cart()) {
         wp_enqueue_script('paypal-checkout-js', 'https://www.paypalobjects.com/api/checkout.js', array(), '1.0', true);
         wp_enqueue_script('wc-gateway-ppec-frontend-in-context-checkout', wc_gateway_ppec()->plugin_url . 'assets/js/wc-gateway-ppec-frontend-in-context-checkout.js', array('jquery'), wc_gateway_ppec()->version, true);
         wp_localize_script('wc-gateway-ppec-frontend-in-context-checkout', 'wc_ppec_context', array('payer_id' => $client->get_payer_id(), 'environment' => $settings->get_environment(), 'locale' => $settings->get_paypal_locale(), 'start_flow' => esc_url(add_query_arg(array('startcheckout' => 'true'), wc_get_page_permalink('cart')))));
     }
 }
 /**
  * Checks data is correctly set when returning from PayPal Express Checkout
  */
 public function maybe_return_from_paypal()
 {
     if (empty($_GET['woo-paypal-return']) || empty($_GET['token']) || empty($_GET['PayerID'])) {
         return;
     }
     $token = $_GET['token'];
     $payer_id = $_GET['PayerID'];
     $session = WC()->session->get('paypal');
     if (empty($session) || $this->session_has_expired($token)) {
         wc_add_notice(__('Your PayPal checkout session has expired. Please check out again.', 'woocommerce-gateway-paypal-express-checkout'), 'error');
         return;
     }
     // Store values in session
     $session->checkout_completed = true;
     $session->payerID = $payer_id;
     WC()->session->set('paypal', $session);
     try {
         $checkout_details = $this->getCheckoutDetails($token);
         // If commit was true, take payment right now
         if ('order' === $session->source && $session->order_id) {
             // Get order
             $order = wc_get_order($session->order_id);
             // Store address given by PayPal
             $order->set_address($this->get_mapped_shipping_address($checkout_details), 'shipping');
             // Complete the payment now.
             $this->do_payment($order, $session->token, $session->payerID);
             // Clear Cart
             WC()->cart->empty_cart();
             // Redirect
             wp_redirect($order->get_checkout_order_received_url());
             exit;
         }
     } catch (PayPal_API_Exception $e) {
         wc_add_notice(__('Sorry, an error occurred while trying to retrieve your information from PayPal. Please try again.', 'woocommerce-gateway-paypal-express-checkout'), 'error');
         $this->maybe_clear_session_data();
         wp_safe_redirect(wc_get_page_permalink('cart'));
         exit;
     } catch (PayPal_Missing_Session_Exception $e) {
         wc_add_notice(__('Your PayPal checkout session has expired. Please check out again.', 'woocommerce-gateway-paypal-express-checkout'), 'error');
         $this->maybe_clear_session_data();
         wp_safe_redirect(wc_get_page_permalink('cart'));
         exit;
     }
 }
示例#25
0
 /**
  * Gets the url to re-add an item into the cart.
  *
  * @param  string $cart_item_key
  * @return string url to page
  */
 public function get_undo_url($cart_item_key)
 {
     $cart_page_url = wc_get_page_permalink('cart');
     $query_args = array('undo_item' => $cart_item_key);
     return apply_filters('woocommerce_get_undo_url', $cart_page_url ? wp_nonce_url(add_query_arg($query_args, $cart_page_url), 'woocommerce-cart') : '', $cart_item_key);
 }
示例#26
0
文件: form-login.php 项目: Bebeau/hwa
<?php

/**
 * Checkout login form
 *
 * @author 		WooThemes
 * @package 	WooCommerce/Templates
 * @version     2.0.0
 */
if (!defined('ABSPATH')) {
    exit;
    // Exit if accessed directly
}
if (is_user_logged_in() || 'no' === get_option('woocommerce_enable_checkout_login_reminder')) {
    return;
}
$info_message = apply_filters('woocommerce_checkout_login_message', esc_html__('Returning customer?', 'jakiro'));
$info_message .= ' <a href="#" class="showlogin">' . esc_html__('Click here to login', 'jakiro') . '</a>';
?>
<div class="col-sm-7">
	<div class="woocommerce-info woocommerce-info-login"><?php 
echo dh_print_string($info_message);
?>
</div>
	<?php 
woocommerce_login_form(array('message' => esc_html__('If you have shopped with us before, please enter your details in the boxes below. If you are a new customer please proceed to the Billing &amp; Shipping section.', 'jakiro'), 'redirect' => wc_get_page_permalink('checkout'), 'hidden' => true));
?>
</div>
 /**
  * Process the registration form.
  */
 public static function process_registration()
 {
     $nonce_value = isset($_POST['_wpnonce']) ? $_POST['_wpnonce'] : '';
     $nonce_value = isset($_POST['woocommerce-register-nonce']) ? $_POST['woocommerce-register-nonce'] : $nonce_value;
     if (!empty($_POST['register']) && wp_verify_nonce($nonce_value, 'woocommerce-register')) {
         $username = '******' === get_option('woocommerce_registration_generate_username') ? $_POST['username'] : '';
         $password = '******' === get_option('woocommerce_registration_generate_password') ? $_POST['password'] : '';
         $email = $_POST['email'];
         try {
             $validation_error = new WP_Error();
             $validation_error = apply_filters('woocommerce_process_registration_errors', $validation_error, $username, $password, $email);
             if ($validation_error->get_error_code()) {
                 throw new Exception($validation_error->get_error_message());
             }
             // Anti-spam trap
             if (!empty($_POST['email_2'])) {
                 throw new Exception(__('Anti-spam field was filled in.', 'woocommerce'));
             }
             $new_customer = wc_create_new_customer(sanitize_email($email), wc_clean($username), $password);
             if (is_wp_error($new_customer)) {
                 throw new Exception($new_customer->get_error_message());
             }
             if (apply_filters('woocommerce_registration_auth_new_customer', true, $new_customer)) {
                 wc_set_customer_auth_cookie($new_customer);
             }
             wp_safe_redirect(apply_filters('woocommerce_registration_redirect', wp_get_referer() ? wp_get_referer() : wc_get_page_permalink('myaccount')));
             exit;
         } catch (Exception $e) {
             wc_add_notice('<strong>' . __('Error:', 'woocommerce') . '</strong> ' . $e->getMessage(), 'error');
         }
     }
 }
?>

		<?php 
do_action('woocommerce_review_order_before_submit');
?>

		<?php 
echo apply_filters('woocommerce_order_button_html', '<input type="submit" class="button alt" name="woocommerce_checkout_place_order" id="place_order" value="' . esc_attr($order_button_text) . '" data-value="' . esc_attr($order_button_text) . '" />');
?>

		<?php 
if (wc_get_page_id('terms') > 0 && apply_filters('woocommerce_checkout_show_terms', true)) {
    ?>
			<p class="form-row terms">
				<label for="terms" class="checkbox"><?php 
    printf(__('I&rsquo;ve read and accept the <a href="%s" target="_blank">terms &amp; conditions</a>', 'woocommerce'), esc_url(wc_get_page_permalink('terms')));
    ?>
</label>
				<input type="checkbox" class="input-checkbox" name="terms" <?php 
    checked(apply_filters('woocommerce_terms_is_checked_default', isset($_POST['terms'])), true);
    ?>
 id="terms" />
			</p>
		<?php 
}
?>

		<?php 
do_action('woocommerce_review_order_after_submit');
?>
 /**
  * Generates a URL to view an order from the my account page
  *
  * @return string
  */
 public function get_view_order_url()
 {
     $view_order_url = wc_get_endpoint_url('view-order', $this->id, wc_get_page_permalink('myaccount'));
     return apply_filters('woocommerce_get_view_order_url', $view_order_url, $this);
 }
示例#30
0
 /**
  * Prevent any user who cannot 'edit_posts' (subscribers, customers etc) from accessing admin
  */
 public function prevent_admin_access()
 {
     $prevent_access = false;
     if ('yes' == get_option('woocommerce_lock_down_admin') && !is_ajax() && !(current_user_can('edit_posts') || current_user_can('manage_woocommerce')) && basename($_SERVER["SCRIPT_FILENAME"]) !== 'admin-post.php') {
         $prevent_access = true;
     }
     $prevent_access = apply_filters('woocommerce_prevent_admin_access', $prevent_access);
     if ($prevent_access) {
         wp_safe_redirect(wc_get_page_permalink('myaccount'));
         exit;
     }
 }