PK DSÐ\óy}‡ ‡ class-wc-shortcode-cart.phpnu W+A„¶ shipping->reset_shipping();
$country = wc_clean( $_POST['calc_shipping_country'] );
$state = wc_clean( isset( $_POST['calc_shipping_state'] ) ? $_POST['calc_shipping_state'] : '' );
$postcode = apply_filters( 'woocommerce_shipping_calculator_enable_postcode', true ) ? wc_clean( $_POST['calc_shipping_postcode'] ) : '';
$city = apply_filters( 'woocommerce_shipping_calculator_enable_city', false ) ? wc_clean( $_POST['calc_shipping_city'] ) : '';
if ( $postcode && ! WC_Validation::is_postcode( $postcode, $country ) ) {
throw new Exception( __( 'Please enter a valid postcode/ZIP.', 'woocommerce' ) );
} elseif ( $postcode ) {
$postcode = wc_format_postcode( $postcode, $country );
}
if ( $country ) {
WC()->customer->set_location( $country, $state, $postcode, $city );
WC()->customer->set_shipping_location( $country, $state, $postcode, $city );
} else {
WC()->customer->set_to_base();
WC()->customer->set_shipping_to_base();
}
WC()->customer->calculated_shipping( true );
wc_add_notice( __( 'Shipping costs updated.', 'woocommerce' ), 'notice' );
do_action( 'woocommerce_calculated_shipping' );
} catch ( Exception $e ) {
if ( ! empty( $e ) ) {
wc_add_notice( $e->getMessage(), 'error' );
}
}
}
/**
* Output the cart shortcode.
*/
public static function output() {
// Constants
if ( ! defined( 'WOOCOMMERCE_CART' ) ) {
define( 'WOOCOMMERCE_CART', true );
}
// Update Shipping
if ( ! empty( $_POST['calc_shipping'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'woocommerce-cart' ) ) {
self::calculate_shipping();
// Also calc totals before we check items so subtotals etc are up to date
WC()->cart->calculate_totals();
}
// Check cart items are valid
do_action( 'woocommerce_check_cart_items' );
// Calc totals
WC()->cart->calculate_totals();
if ( WC()->cart->is_empty() ) {
wc_get_template( 'cart/cart-empty.php' );
} else {
wc_get_template( 'cart/cart.php' );
}
}
}
PK DSÐ\ní*Èõ õ % class-wc-shortcode-order-tracking.phpnu W+A„¶ cart ) ) {
return;
}
extract(shortcode_atts(array(
), $atts));
global $post;
if ( ! empty( $_REQUEST['orderid'] ) && isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'woocommerce-order_tracking' ) ) {
$order_id = empty( $_REQUEST['orderid'] ) ? 0 : esc_attr( $_REQUEST['orderid'] );
$order_email = empty( $_REQUEST['order_email'] ) ? '' : esc_attr( $_REQUEST['order_email']) ;
if ( ! $order_id ) {
echo '
' . __( 'Please enter a valid order ID', 'woocommerce' ) . '
';
} elseif ( ! $order_email ) {
echo '' . __( 'Please enter a valid order email', 'woocommerce' ) . '
';
} else {
$order = wc_get_order( apply_filters( 'woocommerce_shortcode_order_tracking_order_id', $order_id ) );
if ( $order && $order->id && $order_email ) {
if ( strtolower( $order->billing_email ) == strtolower( $order_email ) ) {
do_action( 'woocommerce_track_order', $order->id );
wc_get_template( 'order/tracking.php', array(
'order' => $order
) );
return;
}
} else {
echo '' . sprintf( __( 'Sorry, we could not find that order ID in our database.', 'woocommerce' ), get_permalink($post->ID ) ) . '
';
}
}
}
wc_get_template( 'order/form-tracking.php' );
}
}
PK DSÐ\Nn\,¡( ¡( ! class-wc-shortcode-my-account.phpnu W+A„¶ cart ) ) {
return;
}
if ( ! is_user_logged_in() ) {
$message = apply_filters( 'woocommerce_my_account_message', '' );
if ( ! empty( $message ) ) {
wc_add_notice( $message );
}
if ( isset( $wp->query_vars['lost-password'] ) ) {
self::lost_password();
} else {
wc_get_template( 'myaccount/form-login.php' );
}
} else {
// Start output buffer since the html may need discarding for BW compatibility
ob_start();
// Collect notices before output
$notices = wc_get_notices();
// Output the new account page
self::my_account( $atts );
/**
* Deprecated my-account.php template handling. This code should be
* removed in a future release.
*
* If woocommerce_account_content did not run, this is an old template
* so we need to render the endpoint content again.
*/
if ( ! did_action( 'woocommerce_account_content' ) ) {
foreach ( $wp->query_vars as $key => $value ) {
if ( 'pagename' === $key ) {
continue;
}
if ( has_action( 'woocommerce_account_' . $key . '_endpoint' ) ) {
ob_clean(); // Clear previous buffer
wc_set_notices( $notices );
wc_print_notices();
do_action( 'woocommerce_account_' . $key . '_endpoint', $value );
break;
}
}
_deprecated_function( 'Your theme version of my-account.php template', '2.6', 'the latest version, which supports multiple account pages and navigation, from WC 2.6.0' );
}
// Send output buffer
ob_end_flush();
}
}
/**
* My account page.
*
* @param array $atts
*/
private static function my_account( $atts ) {
extract( shortcode_atts( array(
'order_count' => 15 // @deprecated 2.6.0. Keep for backward compatibility.
), $atts ) );
wc_get_template( 'myaccount/my-account.php', array(
'current_user' => get_user_by( 'id', get_current_user_id() ),
'order_count' => 'all' == $order_count ? -1 : $order_count,
) );
}
/**
* View order page.
*
* @param int $order_id
*/
public static function view_order( $order_id ) {
$order = wc_get_order( $order_id );
if ( ! current_user_can( 'view_order', $order_id ) ) {
echo '';
return;
}
// Backwards compatibility
$status = new stdClass();
$status->name = wc_get_order_status_name( $order->get_status() );
wc_get_template( 'myaccount/view-order.php', array(
'status' => $status, // @deprecated 2.2
'order' => wc_get_order( $order_id ),
'order_id' => $order_id
) );
}
/**
* Edit account details page.
*/
public static function edit_account() {
wc_get_template( 'myaccount/form-edit-account.php', array( 'user' => get_user_by( 'id', get_current_user_id() ) ) );
}
/**
* Edit address page.
*
* @param string $load_address
*/
public static function edit_address( $load_address = 'billing' ) {
$current_user = wp_get_current_user();
$load_address = sanitize_key( $load_address );
$address = WC()->countries->get_address_fields( get_user_meta( get_current_user_id(), $load_address . '_country', true ), $load_address . '_' );
// Enqueue scripts
wp_enqueue_script( 'wc-country-select' );
wp_enqueue_script( 'wc-address-i18n' );
// Prepare values
foreach ( $address as $key => $field ) {
$value = get_user_meta( get_current_user_id(), $key, true );
if ( ! $value ) {
switch( $key ) {
case 'billing_email' :
case 'shipping_email' :
$value = $current_user->user_email;
break;
case 'billing_country' :
case 'shipping_country' :
$value = WC()->countries->get_base_country();
break;
case 'billing_state' :
case 'shipping_state' :
$value = WC()->countries->get_base_state();
break;
}
}
$address[ $key ]['value'] = apply_filters( 'woocommerce_my_account_edit_address_field_value', $value, $key, $load_address );
}
wc_get_template( 'myaccount/form-edit-address.php', array(
'load_address' => $load_address,
'address' => apply_filters( 'woocommerce_address_to_edit', $address )
) );
}
/**
* Lost password page handling.
*/
public static function lost_password() {
/**
* After sending the reset link, don't show the form again.
*/
if ( ! empty( $_GET['reset-link-sent'] ) ) {
return wc_get_template( 'myaccount/lost-password-confirmation.php' );
/**
* After reset, show confirmation message.
*/
} elseif ( ! empty( $_GET['reset'] ) ) {
wc_add_notice( __( 'Your password has been reset.', 'woocommerce' ) . ' ' . __( 'Log in', 'woocommerce' ) . '' );
/**
* Process reset key / login from email confirmation link
*/
} elseif ( ! empty( $_GET['show-reset-form'] ) ) {
if ( isset( $_COOKIE[ 'wp-resetpass-' . COOKIEHASH ] ) && 0 < strpos( $_COOKIE[ 'wp-resetpass-' . COOKIEHASH ], ':' ) ) {
list( $rp_login, $rp_key ) = array_map( 'wc_clean', explode( ':', wp_unslash( $_COOKIE[ 'wp-resetpass-' . COOKIEHASH ] ), 2 ) );
$user = self::check_password_reset_key( $rp_key, $rp_login );
// reset key / login is correct, display reset password form with hidden key / login values
if ( is_object( $user ) ) {
return wc_get_template( 'myaccount/form-reset-password.php', array(
'key' => $rp_key,
'login' => $rp_login,
) );
} else {
self::set_reset_password_cookie();
}
}
}
// Show lost password form by default
wc_get_template( 'myaccount/form-lost-password.php', array(
'form' => 'lost_password',
) );
}
/**
* Handles sending password retrieval email to customer.
*
* Based on retrieve_password() in core wp-login.php.
*
* @uses $wpdb WordPress Database object
* @return bool True: when finish. False: on error
*/
public static function retrieve_password() {
global $wpdb, $wp_hasher;
$login = trim( $_POST['user_login'] );
if ( empty( $login ) ) {
wc_add_notice( __( 'Enter a username or e-mail address.', 'woocommerce' ), 'error' );
return false;
} else {
// Check on username first, as customers can use emails as usernames.
$user_data = get_user_by( 'login', $login );
}
// If no user found, check if it login is email and lookup user based on email.
if ( ! $user_data && is_email( $login ) && apply_filters( 'woocommerce_get_username_from_email', true ) ) {
$user_data = get_user_by( 'email', $login );
}
do_action( 'lostpassword_post' );
if ( ! $user_data ) {
wc_add_notice( __( 'Invalid username or e-mail.', 'woocommerce' ), 'error' );
return false;
}
if ( is_multisite() && ! is_user_member_of_blog( $user_data->ID, get_current_blog_id() ) ) {
wc_add_notice( __( 'Invalid username or e-mail.', 'woocommerce' ), 'error' );
return false;
}
// redefining user_login ensures we return the right case in the email
$user_login = $user_data->user_login;
do_action( 'retrieve_password', $user_login );
$allow = apply_filters( 'allow_password_reset', true, $user_data->ID );
if ( ! $allow ) {
wc_add_notice( __( 'Password reset is not allowed for this user', 'woocommerce' ), 'error' );
return false;
} elseif ( is_wp_error( $allow ) ) {
wc_add_notice( $allow->get_error_message(), 'error' );
return false;
}
// Get password reset key (function introduced in WordPress 4.4).
$key = get_password_reset_key( $user_data );
// Send email notification
WC()->mailer(); // load email classes
do_action( 'woocommerce_reset_password_notification', $user_login, $key );
return true;
}
/**
* Retrieves a user row based on password reset key and login.
*
* @uses $wpdb WordPress Database object
*
* @param string $key Hash to validate sending user's password
* @param string $login The user login
* @return WP_User|bool User's database row on success, false for invalid keys
*/
public static function check_password_reset_key( $key, $login ) {
// Check for the password reset key.
// Get user data or an error message in case of invalid or expired key.
$user = check_password_reset_key( $key, $login );
if ( is_wp_error( $user ) ) {
wc_add_notice( $user->get_error_message(), 'error' );
return false;
}
return $user;
}
/**
* Handles resetting the user's password.
*
* @param object $user The user
* @param string $new_pass New password for the user in plaintext
*/
public static function reset_password( $user, $new_pass ) {
do_action( 'password_reset', $user, $new_pass );
wp_set_password( $new_pass, $user->ID );
self::set_reset_password_cookie();
wp_password_change_notification( $user );
}
/**
* Set or unset the cookie.
*/
public static function set_reset_password_cookie( $value = '' ) {
$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
$rp_path = current( explode( '?', wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
if ( $value ) {
setcookie( $rp_cookie, $value, 0, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
} else {
setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
}
}
/**
* Show the add payment method page.
*/
public 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_print_notices();
wc_get_template( 'myaccount/form-add-payment-method.php' );
do_action( 'after_woocommerce_add_payment_method' );
}
}
}
PK DSÐ\N/¨ïH H class-wc-shortcode-checkout.phpnu W+A„¶ cart ) ) {
return;
}
// Backwards compat with old pay and thanks link arguments
if ( isset( $_GET['order'] ) && isset( $_GET['key'] ) ) {
_deprecated_argument( __CLASS__ . '->' . __FUNCTION__, '2.1', '"order" is no longer used to pass an order ID. Use the order-pay or order-received endpoint instead.' );
// Get the order to work out what we are showing
$order_id = absint( $_GET['order'] );
$order = wc_get_order( $order_id );
if ( $order && $order->has_status( 'pending' ) ) {
$wp->query_vars['order-pay'] = absint( $_GET['order'] );
} else {
$wp->query_vars['order-received'] = absint( $_GET['order'] );
}
}
// Handle checkout actions
if ( ! empty( $wp->query_vars['order-pay'] ) ) {
self::order_pay( $wp->query_vars['order-pay'] );
} elseif ( isset( $wp->query_vars['order-received'] ) ) {
self::order_received( $wp->query_vars['order-received'] );
} else {
self::checkout();
}
}
/**
* Show the pay page.
*
* @param int $order_id
*/
private static function order_pay( $order_id ) {
do_action( 'before_woocommerce_pay' );
wc_print_notices();
$order_id = absint( $order_id );
// Handle payment
if ( isset( $_GET['pay_for_order'] ) && isset( $_GET['key'] ) && $order_id ) {
// Pay for existing order
$order_key = $_GET[ 'key' ];
$order = wc_get_order( $order_id );
if ( ! current_user_can( 'pay_for_order', $order_id ) ) {
echo '';
return;
}
if ( $order->id == $order_id && $order->order_key == $order_key ) {
if ( $order->needs_payment() ) {
// Set customer location to order location
if ( $order->billing_country ) {
WC()->customer->set_country( $order->billing_country );
}
if ( $order->billing_state ) {
WC()->customer->set_state( $order->billing_state );
}
if ( $order->billing_postcode ) {
WC()->customer->set_postcode( $order->billing_postcode );
}
$available_gateways = WC()->payment_gateways->get_available_payment_gateways();
if ( sizeof( $available_gateways ) ) {
current( $available_gateways )->set_current();
}
wc_get_template( 'checkout/form-pay.php', array(
'order' => $order,
'available_gateways' => $available_gateways,
'order_button_text' => apply_filters( 'woocommerce_pay_order_button_text', __( 'Pay for order', 'woocommerce' ) )
) );
} else {
wc_add_notice( sprintf( __( 'This order’s status is “%s”—it cannot be paid for. Please contact us if you need assistance.', 'woocommerce' ), wc_get_order_status_name( $order->get_status() ) ), 'error' );
}
} else {
wc_add_notice( __( 'Sorry, this order is invalid and cannot be paid for.', 'woocommerce' ), 'error' );
}
} elseif ( $order_id ) {
// Pay for order after checkout step
$order_key = isset( $_GET['key'] ) ? wc_clean( $_GET['key'] ) : '';
$order = wc_get_order( $order_id );
if ( $order->id == $order_id && $order->order_key == $order_key ) {
if ( $order->needs_payment() ) {
?>
-
get_order_number(); ?>
-
order_date)); ?>
-
get_formatted_order_total(); ?>
payment_method_title) : ?>
-
payment_method_title;
?>
payment_method, $order_id ); ?>
get_status() ) ), 'error' );
}
} else {
wc_add_notice( __( 'Sorry, this order is invalid and cannot be paid for.', 'woocommerce' ), 'error' );
}
} else {
wc_add_notice( __( 'Invalid order.', 'woocommerce' ), 'error' );
}
wc_print_notices();
do_action( 'after_woocommerce_pay' );
}
/**
* Show the thanks page.
*
* @param int $order_id
*/
private static function order_received( $order_id = 0 ) {
wc_print_notices();
$order = false;
// Get the order
$order_id = apply_filters( 'woocommerce_thankyou_order_id', absint( $order_id ) );
$order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['key'] ) ? '' : wc_clean( $_GET['key'] ) );
if ( $order_id > 0 ) {
$order = wc_get_order( $order_id );
if ( $order->order_key != $order_key ) {
$order = false;
}
}
// Empty awaiting payment session
unset( WC()->session->order_awaiting_payment );
// Empty current cart
wc_empty_cart();
wc_get_template( 'checkout/thankyou.php', array( 'order' => $order ) );
}
/**
* Show the checkout.
*/
private static function checkout() {
// Show non-cart errors
wc_print_notices();
// Check cart has contents
if ( WC()->cart->is_empty() ) {
return;
}
// Check cart contents for errors
do_action( 'woocommerce_check_cart_items' );
// Calc totals
WC()->cart->calculate_totals();
// Get checkout object
$checkout = WC()->checkout();
if ( empty( $_POST ) && wc_notice_count( 'error' ) > 0 ) {
wc_get_template( 'checkout/cart-errors.php', array( 'checkout' => $checkout ) );
} else {
$non_js_checkout = ! empty( $_POST['woocommerce_checkout_update_totals'] ) ? true : false;
if ( wc_notice_count( 'error' ) == 0 && $non_js_checkout )
wc_add_notice( __( 'The order totals have been updated. Please confirm your order by pressing the Place Order button at the bottom of the page.', 'woocommerce' ) );
wc_get_template( 'checkout/form-checkout.php', array( 'checkout' => $checkout ) );
}
}
}
PK DSÐ\óy}‡ ‡ class-wc-shortcode-cart.phpnu W+A„¶ PK DSÐ\ní*Èõ õ % Ò class-wc-shortcode-order-tracking.phpnu W+A„¶ PK DSÐ\Nn\,¡( ¡( ! class-wc-shortcode-my-account.phpnu W+A„¶ PK DSÐ\N/¨ïH H ; class-wc-shortcode-checkout.phpnu W+A„¶ PK € ¥W