session -> transient WIP
This commit is contained in:
parent
87d897d657
commit
fdd34e5c0e
|
@ -105,7 +105,6 @@ if ( ! function_exists( 'woocommerce_settings' ) ) {
|
|||
|
||||
// Flush rules and clear any unwanted data
|
||||
flush_rewrite_rules( false );
|
||||
unset($_SESSION['orderby']);
|
||||
$woocommerce->clear_product_transients();
|
||||
|
||||
// Redirect back to the settings page
|
||||
|
|
|
@ -236,8 +236,8 @@ class WC_Cart {
|
|||
|
||||
$this->cart_contents = array();
|
||||
$this->reset();
|
||||
|
||||
unset( $_SESSION['coupons'], $_SESSION['cart'] );
|
||||
|
||||
unset( $woocommerce->session->order_awaiting_payment, $woocommerce->session->coupons, $woocommerce->session->cart );
|
||||
|
||||
if ( $clear_persistent_cart && get_current_user_id() )
|
||||
$this->persistent_cart_destroy();
|
||||
|
@ -847,20 +847,8 @@ class WC_Cart {
|
|||
* @return void
|
||||
*/
|
||||
private function reset() {
|
||||
$this->total = 0;
|
||||
$this->cart_contents_total = 0;
|
||||
$this->cart_contents_weight = 0;
|
||||
$this->cart_contents_count = 0;
|
||||
$this->cart_contents_tax = 0;
|
||||
$this->tax_total = 0;
|
||||
$this->shipping_tax_total = 0;
|
||||
$this->shipping_taxes = array();
|
||||
$this->subtotal = 0;
|
||||
$this->subtotal_ex_tax = 0;
|
||||
$this->discount_total = 0;
|
||||
$this->discount_cart = 0;
|
||||
$this->shipping_total = 0;
|
||||
$this->taxes = array();
|
||||
$this->total = $this->cart_contents_total = $this->cart_contents_weight = $this->cart_contents_count = $this->cart_contents_tax = $this->tax_total = $this->shipping_tax_total = $this->subtotal = $this->subtotal_ex_tax = $this->discount_total = $this->discount_cart = $this->shipping_total = 0;
|
||||
$this->shipping_taxes = $this->taxes = array();
|
||||
|
||||
unset( $_SESSION['cart_contents_total'], $_SESSION['cart_contents_weight'], $_SESSION['cart_contents_count'], $_SESSION['cart_contents_tax'], $_SESSION['total'], $_SESSION['subtotal'], $_SESSION['subtotal_ex_tax'], $_SESSION['tax_total'], $_SESSION['taxes'], $_SESSION['shipping_taxes'], $_SESSION['discount_cart'], $_SESSION['discount_total'], $_SESSION['shipping_total'], $_SESSION['shipping_tax_total'], $_SESSION['shipping_label'] );
|
||||
}
|
||||
|
|
|
@ -122,30 +122,32 @@ class WC_Checkout {
|
|||
function process_checkout() {
|
||||
global $wpdb, $woocommerce;
|
||||
|
||||
if ( ! defined( 'WOOCOMMERCE_CHECKOUT' ) ) define( 'WOOCOMMERCE_CHECKOUT', true );
|
||||
if ( ! defined( 'WOOCOMMERCE_CHECKOUT' ) )
|
||||
define( 'WOOCOMMERCE_CHECKOUT', true );
|
||||
|
||||
$woocommerce->verify_nonce('process_checkout');
|
||||
$woocommerce->verify_nonce( 'process_checkout' );
|
||||
|
||||
do_action('woocommerce_before_checkout_process');
|
||||
do_action( 'woocommerce_before_checkout_process' );
|
||||
|
||||
if ( sizeof( $woocommerce->cart->get_cart() ) == 0 )
|
||||
$woocommerce->add_error( sprintf(__('Sorry, your session has expired. <a href="%s">Return to homepage →</a>', 'woocommerce'), home_url()) );
|
||||
$woocommerce->add_error( sprintf( __( 'Sorry, your session has expired. <a href="%s">Return to homepage →</a>', 'woocommerce' ), home_url() ) );
|
||||
|
||||
do_action('woocommerce_checkout_process');
|
||||
do_action( 'woocommerce_checkout_process' );
|
||||
|
||||
// Checkout fields (not defined in checkout_fields)
|
||||
$this->posted['shiptobilling'] = isset($_POST['shiptobilling']) ? 1 : 0;
|
||||
$this->posted['terms'] = isset($_POST['terms']) ? 1 : 0;
|
||||
$this->posted['createaccount'] = isset($_POST['createaccount']) ? 1 : 0;
|
||||
$this->posted['payment_method'] = isset($_POST['payment_method']) ? woocommerce_clean($_POST['payment_method']) : '';
|
||||
$this->posted['shipping_method'] = isset($_POST['shipping_method']) ? woocommerce_clean($_POST['shipping_method']) : '';
|
||||
$this->posted['shiptobilling'] = isset( $_POST['shiptobilling'] ) ? 1 : 0;
|
||||
$this->posted['terms'] = isset( $_POST['terms'] ) ? 1 : 0;
|
||||
$this->posted['createaccount'] = isset( $_POST['createaccount'] ) ? 1 : 0;
|
||||
$this->posted['payment_method'] = isset( $_POST['payment_method'] ) ? woocommerce_clean( $_POST['payment_method'] ) : '';
|
||||
$this->posted['shipping_method'] = isset( $_POST['shipping_method'] ) ? woocommerce_clean( $_POST['shipping_method'] ) : '';
|
||||
|
||||
// Ship to billing only option
|
||||
if ( $woocommerce->cart->ship_to_billing_address_only() ) $this->posted['shiptobilling'] = 1;
|
||||
if ( $woocommerce->cart->ship_to_billing_address_only() )
|
||||
$this->posted['shiptobilling'] = 1;
|
||||
|
||||
// Update customer shipping and payment method to posted method
|
||||
$_SESSION['_chosen_shipping_method'] = $this->posted['shipping_method'];
|
||||
$_SESSION['_chosen_payment_method'] = $this->posted['payment_method'];
|
||||
$woocommerce->session->chosen_shipping_method = $this->posted['shipping_method'];
|
||||
$woocommerce->session->chosen_shipping_method = $this->posted['payment_method'];
|
||||
|
||||
// Note if we skip shipping
|
||||
$skipped_shipping = false;
|
||||
|
@ -315,7 +317,7 @@ class WC_Checkout {
|
|||
|
||||
// Terms
|
||||
if ( ! isset( $_POST['woocommerce_checkout_update_totals'] ) && empty( $this->posted['terms'] ) && woocommerce_get_page_id( 'terms' ) > 0 )
|
||||
$woocommerce->add_error( __('You must accept our Terms & Conditions.', 'woocommerce') );
|
||||
$woocommerce->add_error( __( 'You must accept our Terms & Conditions.', 'woocommerce' ) );
|
||||
|
||||
if ( $woocommerce->cart->needs_shipping() ) {
|
||||
|
||||
|
@ -323,32 +325,32 @@ class WC_Checkout {
|
|||
$available_methods = $woocommerce->shipping->get_available_shipping_methods();
|
||||
|
||||
if ( ! isset( $available_methods[ $this->posted['shipping_method'] ] ) )
|
||||
$woocommerce->add_error( __('Invalid shipping method.', 'woocommerce') );
|
||||
$woocommerce->add_error( __( 'Invalid shipping method.', 'woocommerce' ) );
|
||||
|
||||
}
|
||||
|
||||
if ($woocommerce->cart->needs_payment()) {
|
||||
if ( $woocommerce->cart->needs_payment() ) {
|
||||
|
||||
// Payment Method
|
||||
$available_gateways = $woocommerce->payment_gateways->get_available_payment_gateways();
|
||||
|
||||
if ( ! isset( $available_gateways[ $this->posted['payment_method'] ] ) )
|
||||
$woocommerce->add_error( __('Invalid payment method.', 'woocommerce') );
|
||||
$woocommerce->add_error( __( 'Invalid payment method.', 'woocommerce' ) );
|
||||
else
|
||||
$available_gateways[$this->posted['payment_method']]->validate_fields(); // Payment Method Field Validation
|
||||
$available_gateways[ $this->posted['payment_method'] ]->validate_fields(); // Payment Method Field Validation
|
||||
}
|
||||
|
||||
// Action after validation
|
||||
do_action( 'woocommerce_after_checkout_validation', $this->posted );
|
||||
|
||||
if ( ! isset( $_POST['woocommerce_checkout_update_totals'] ) && $woocommerce->error_count() == 0 ) :
|
||||
if ( ! isset( $_POST['woocommerce_checkout_update_totals'] ) && $woocommerce->error_count() == 0 ) {
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
|
||||
while (1) :
|
||||
try {
|
||||
|
||||
// Create customer account and log them in
|
||||
if ($this->creating_account && !$user_id) :
|
||||
if ( $this->creating_account && ! $user_id ) {
|
||||
|
||||
$reg_errors = new WP_Error();
|
||||
|
||||
|
@ -357,18 +359,16 @@ class WC_Checkout {
|
|||
$errors = apply_filters( 'woocommerce_registration_errors', $reg_errors, $this->posted['account_username'], $this->posted['billing_email'] );
|
||||
|
||||
// if there are no errors, let's create the user account
|
||||
if ( !$reg_errors->get_error_code() ) :
|
||||
if ( ! $reg_errors->get_error_code() ) {
|
||||
|
||||
$user_pass = esc_attr( $this->posted['account_password'] );
|
||||
$user_id = wp_create_user( $this->posted['account_username'], $user_pass, $this->posted['billing_email'] );
|
||||
|
||||
if ( !$user_id ) :
|
||||
$woocommerce->add_error( '<strong>' . __('ERROR', 'woocommerce') . '</strong>: ' . __('Couldn’t register you… please contact us if you continue to have problems.', 'woocommerce') );
|
||||
break;
|
||||
endif;
|
||||
if ( ! $user_id )
|
||||
throw new MyException( '<strong>' . __('ERROR', 'woocommerce') . '</strong>: ' . __('Couldn’t register you… please contact us if you continue to have problems.', 'woocommerce') );
|
||||
|
||||
// Change role
|
||||
wp_update_user( array ('ID' => $user_id, 'role' => 'customer') ) ;
|
||||
wp_update_user( array('ID' => $user_id, 'role' => 'customer') ) ;
|
||||
|
||||
// Action
|
||||
do_action( 'woocommerce_created_customer', $user_id );
|
||||
|
@ -381,12 +381,11 @@ class WC_Checkout {
|
|||
$secure_cookie = is_ssl() ? true : false;
|
||||
wp_set_auth_cookie($user_id, true, $secure_cookie);
|
||||
|
||||
else :
|
||||
$woocommerce->add_error( $reg_errors->get_error_message() );
|
||||
break;
|
||||
endif;
|
||||
} else {
|
||||
throw new MyException( $reg_errors->get_error_message() );
|
||||
}
|
||||
|
||||
endif;
|
||||
}
|
||||
|
||||
// Create Order (send cart variable so we can record items and reduce inventory). Only create if this is a new order, not if the payment was rejected last time.
|
||||
$_tax = new WC_Tax();
|
||||
|
@ -398,7 +397,7 @@ class WC_Checkout {
|
|||
'ping_status' => 'closed',
|
||||
'post_excerpt' => $this->posted['order_comments'],
|
||||
'post_author' => 1,
|
||||
'post_password' => uniqid('order_') // Protects the post just in case
|
||||
'post_password' => uniqid( 'order_' ) // Protects the post just in case
|
||||
);
|
||||
|
||||
// Cart items
|
||||
|
@ -442,43 +441,40 @@ class WC_Checkout {
|
|||
// Check order items for errors
|
||||
do_action('woocommerce_check_new_order_items', $order_items);
|
||||
|
||||
if ($woocommerce->error_count()>0) break;
|
||||
if ( $woocommerce->error_count() > 0 )
|
||||
throw new MyException();
|
||||
|
||||
// Insert or update the post data
|
||||
$create_new_order = true;
|
||||
|
||||
if (isset($_SESSION['order_awaiting_payment']) && $_SESSION['order_awaiting_payment'] > 0) :
|
||||
if ( $woocommerce->session->order_awaiting_payment > 0 ) {
|
||||
|
||||
$order_id = (int) $_SESSION['order_awaiting_payment'];
|
||||
$order_id = (int) $woocommerce->session->order_awaiting_payment;
|
||||
|
||||
/* Check order is unpaid by getting its status */
|
||||
$terms = wp_get_object_terms( $order_id, 'shop_order_status', array('fields' => 'slugs') );
|
||||
$order_status = (isset($terms[0])) ? $terms[0] : 'pending';
|
||||
$terms = wp_get_object_terms( $order_id, 'shop_order_status', array( 'fields' => 'slugs' ) );
|
||||
$order_status = isset( $terms[0] ) ? $terms[0] : 'pending';
|
||||
|
||||
if ( $order_status == 'pending' ) :
|
||||
if ( $order_status == 'pending' ) {
|
||||
|
||||
// Resume the unpaid order
|
||||
$order_data['ID'] = $order_id;
|
||||
wp_update_post( $order_data );
|
||||
do_action('woocommerce_resume_order', $order_id);
|
||||
do_action( 'woocommerce_resume_order', $order_id );
|
||||
|
||||
$create_new_order = false;
|
||||
|
||||
endif;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
if ($create_new_order) :
|
||||
if ( $create_new_order ) {
|
||||
$order_id = wp_insert_post( $order_data );
|
||||
|
||||
if (is_wp_error($order_id)) :
|
||||
$woocommerce->add_error( 'Error: Unable to create order. Please try again.' );
|
||||
break;
|
||||
else :
|
||||
// Inserted successfully
|
||||
do_action('woocommerce_new_order', $order_id);
|
||||
endif;
|
||||
endif;
|
||||
if ( is_wp_error( $order_id ) )
|
||||
throw new MyException( 'Error: Unable to create order. Please try again.' );
|
||||
else
|
||||
do_action( 'woocommerce_new_order', $order_id ); // Inserted successfully
|
||||
}
|
||||
|
||||
// Get better formatted shipping method (title)
|
||||
$shipping_method = $this->posted['shipping_method'];
|
||||
|
@ -493,64 +489,65 @@ class WC_Checkout {
|
|||
// UPDATE ORDER META
|
||||
|
||||
// Save billing and shipping first, also save to user meta if logged in
|
||||
if ($this->checkout_fields['billing']) {
|
||||
foreach ($this->checkout_fields['billing'] as $key => $field) {
|
||||
if ( $this->checkout_fields['billing'] ) {
|
||||
foreach ( $this->checkout_fields['billing'] as $key => $field ) {
|
||||
|
||||
// Post
|
||||
update_post_meta( $order_id, '_' . $key, $this->posted[$key] );
|
||||
update_post_meta( $order_id, '_' . $key, $this->posted[ $key ] );
|
||||
|
||||
// User
|
||||
if ($user_id>0 && !empty($this->posted[$key])) {
|
||||
update_user_meta( $user_id, $key, $this->posted[$key] );
|
||||
if ( $user_id > 0 && ! empty( $this->posted[ $key ] ) ) {
|
||||
update_user_meta( $user_id, $key, $this->posted[ $key ] );
|
||||
|
||||
// Special fields
|
||||
switch ($key) {
|
||||
switch ( $key ) {
|
||||
case "billing_email" :
|
||||
if (!email_exists($this->posted[$key])) wp_update_user( array ( 'ID' => $user_id, 'user_email' => $this->posted[$key] ) ) ;
|
||||
if ( ! email_exists( $this->posted[ $key ] ) )
|
||||
wp_update_user( array ( 'ID' => $user_id, 'user_email' => $this->posted[ $key ] ) ) ;
|
||||
break;
|
||||
case "billing_first_name" :
|
||||
wp_update_user( array ( 'ID' => $user_id, 'first_name' => $this->posted[$key] ) ) ;
|
||||
wp_update_user( array ( 'ID' => $user_id, 'first_name' => $this->posted[ $key ] ) ) ;
|
||||
break;
|
||||
case "billing_last_name" :
|
||||
wp_update_user( array ( 'ID' => $user_id, 'last_name' => $this->posted[$key] ) ) ;
|
||||
wp_update_user( array ( 'ID' => $user_id, 'last_name' => $this->posted[ $key ] ) ) ;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->checkout_fields['shipping'] && ( $woocommerce->cart->needs_shipping() || get_option('woocommerce_require_shipping_address') == 'yes' ) ) {
|
||||
foreach ($this->checkout_fields['shipping'] as $key => $field) {
|
||||
foreach ( $this->checkout_fields['shipping'] as $key => $field ) {
|
||||
if ( $this->posted['shiptobilling'] ) {
|
||||
|
||||
$field_key = str_replace('shipping_', 'billing_', $key);
|
||||
|
||||
// Post
|
||||
update_post_meta( $order_id, '_' . $key, $this->posted[$field_key] );
|
||||
update_post_meta( $order_id, '_' . $key, $this->posted[ $field_key ] );
|
||||
} else {
|
||||
// Post
|
||||
update_post_meta( $order_id, '_' . $key, $this->posted[$key] );
|
||||
update_post_meta( $order_id, '_' . $key, $this->posted[ $key ] );
|
||||
|
||||
// User
|
||||
if ( $user_id > 0 )
|
||||
update_user_meta( $user_id, $key, $this->posted[$key] );
|
||||
update_user_meta( $user_id, $key, $this->posted[ $key ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Save any other user meta
|
||||
if ($user_id) do_action('woocommerce_checkout_update_user_meta', $user_id, $this->posted);
|
||||
if ( $user_id )
|
||||
do_action( 'woocommerce_checkout_update_user_meta', $user_id, $this->posted );
|
||||
|
||||
// Prepare order taxes for storage
|
||||
$order_taxes = array();
|
||||
|
||||
foreach (array_keys($woocommerce->cart->taxes + $woocommerce->cart->shipping_taxes) as $key) {
|
||||
foreach ( array_keys( $woocommerce->cart->taxes + $woocommerce->cart->shipping_taxes ) as $key ) {
|
||||
|
||||
$is_compound = ($woocommerce->cart->tax->is_compound( $key )) ? 1 : 0;
|
||||
$is_compound = $woocommerce->cart->tax->is_compound( $key ) ? 1 : 0;
|
||||
|
||||
$cart_tax = (isset($woocommerce->cart->taxes[$key])) ? $woocommerce->cart->taxes[$key] : 0;
|
||||
$shipping_tax = (isset($woocommerce->cart->shipping_taxes[$key])) ? $woocommerce->cart->shipping_taxes[$key] : 0;
|
||||
$cart_tax = isset( $woocommerce->cart->taxes[ $key ] ) ? $woocommerce->cart->taxes[ $key ] : 0;
|
||||
$shipping_tax = isset( $woocommerce->cart->shipping_taxes[ $key ] ) ? $woocommerce->cart->shipping_taxes[ $key ] : 0;
|
||||
|
||||
$order_taxes[] = array(
|
||||
'label' => $woocommerce->cart->tax->get_rate_label( $key ),
|
||||
|
@ -561,8 +558,8 @@ class WC_Checkout {
|
|||
}
|
||||
|
||||
// Save other order meta fields
|
||||
update_post_meta( $order_id, '_shipping_method', $this->posted['shipping_method']);
|
||||
update_post_meta( $order_id, '_payment_method', $this->posted['payment_method']);
|
||||
update_post_meta( $order_id, '_shipping_method', $this->posted['shipping_method'] );
|
||||
update_post_meta( $order_id, '_payment_method', $this->posted['payment_method'] );
|
||||
update_post_meta( $order_id, '_shipping_method_title', $shipping_method );
|
||||
update_post_meta( $order_id, '_payment_method_title', $payment_method );
|
||||
update_post_meta( $order_id, '_order_shipping', woocommerce_format_total( $woocommerce->cart->shipping_total ) );
|
||||
|
@ -576,7 +573,7 @@ class WC_Checkout {
|
|||
update_post_meta( $order_id, '_order_items', $order_items );
|
||||
update_post_meta( $order_id, '_order_taxes', $order_taxes );
|
||||
update_post_meta( $order_id, '_order_currency', get_woocommerce_currency() );
|
||||
update_post_meta( $order_id, '_prices_include_tax', get_option('woocommerce_prices_include_tax') );
|
||||
update_post_meta( $order_id, '_prices_include_tax', get_option( 'woocommerce_prices_include_tax' ) );
|
||||
|
||||
// Store technical customer details in meta
|
||||
$customer_ip = isset( $_SERVER['HTTP_X_FORWARD_FOR'] ) ? $_SERVER['HTTP_X_FORWARD_FOR'] : $_SERVER['REMOTE_ADDR'];
|
||||
|
@ -586,7 +583,7 @@ class WC_Checkout {
|
|||
update_post_meta( $order_id, __( 'Customer UA', 'woocommerce' ), $customer_user_agent );
|
||||
|
||||
// Let plugins add meta
|
||||
do_action('woocommerce_checkout_update_order_meta', $order_id, $this->posted );
|
||||
do_action( 'woocommerce_checkout_update_order_meta', $order_id, $this->posted );
|
||||
|
||||
// Order status
|
||||
wp_set_object_terms( $order_id, 'pending', 'shop_order_status' );
|
||||
|
@ -603,36 +600,36 @@ class WC_Checkout {
|
|||
}
|
||||
|
||||
// Order is saved
|
||||
do_action('woocommerce_checkout_order_processed', $order_id, $this->posted);
|
||||
do_action( 'woocommerce_checkout_order_processed', $order_id, $this->posted );
|
||||
|
||||
// Prevent timeout
|
||||
@set_time_limit(0);
|
||||
|
||||
// Process payment
|
||||
if ($woocommerce->cart->needs_payment()) :
|
||||
if ( $woocommerce->cart->needs_payment() ) {
|
||||
|
||||
// Store Order ID in session so it can be re-used after payment failure
|
||||
$_SESSION['order_awaiting_payment'] = $order_id;
|
||||
$woocommerce->session->order_awaiting_payment = $order_id;
|
||||
|
||||
// Process Payment
|
||||
$result = $available_gateways[$this->posted['payment_method']]->process_payment( $order_id );
|
||||
$result = $available_gateways[ $this->posted['payment_method'] ]->process_payment( $order_id );
|
||||
|
||||
// Redirect to success/confirmation/payment page
|
||||
if ($result['result']=='success') :
|
||||
if ( $result['result'] == 'success' ) {
|
||||
|
||||
$result = apply_filters('woocommerce_payment_successful_result', $result );
|
||||
|
||||
if (is_ajax()) :
|
||||
if ( is_ajax() ) {
|
||||
echo json_encode( $result );
|
||||
exit;
|
||||
else :
|
||||
} else {
|
||||
wp_redirect( $result['redirect'] );
|
||||
exit;
|
||||
endif;
|
||||
}
|
||||
|
||||
endif;
|
||||
}
|
||||
|
||||
else :
|
||||
} else {
|
||||
|
||||
if ( empty( $order ) )
|
||||
$order = new WC_Order( $order_id );
|
||||
|
@ -644,11 +641,11 @@ class WC_Checkout {
|
|||
$woocommerce->cart->empty_cart();
|
||||
|
||||
// Get redirect
|
||||
$return_url = get_permalink(woocommerce_get_page_id('thanks'));
|
||||
$return_url = add_query_arg('key', $order->order_key, add_query_arg('order', $order->id, $return_url));
|
||||
$return_url = get_permalink( woocommerce_get_page_id( 'thanks' ) );
|
||||
$return_url = add_query_arg( 'key', $order->order_key, add_query_arg( 'order', $order->id, $return_url ) );
|
||||
|
||||
// Redirect to success/confirmation/payment page
|
||||
if (is_ajax()) :
|
||||
if ( is_ajax() ) {
|
||||
echo json_encode(
|
||||
array(
|
||||
'result' => 'success',
|
||||
|
@ -656,24 +653,26 @@ class WC_Checkout {
|
|||
)
|
||||
);
|
||||
exit;
|
||||
else :
|
||||
} else {
|
||||
wp_safe_redirect(
|
||||
apply_filters( 'woocommerce_checkout_no_payment_needed_redirect', $return_url, $order)
|
||||
);
|
||||
exit;
|
||||
endif;
|
||||
}
|
||||
|
||||
endif;
|
||||
}
|
||||
|
||||
// Break out of loop
|
||||
break;
|
||||
} catch ( Exception $e ) {
|
||||
|
||||
if ( ! empty( $e ) )
|
||||
$woocommerce->add_error( $e );
|
||||
|
||||
}
|
||||
|
||||
endwhile;
|
||||
|
||||
endif;
|
||||
} // endif
|
||||
|
||||
// If we reached this point then there were errors
|
||||
if (is_ajax()) :
|
||||
if ( is_ajax() ) {
|
||||
|
||||
ob_start();
|
||||
$woocommerce->show_messages();
|
||||
|
@ -683,13 +682,13 @@ class WC_Checkout {
|
|||
array(
|
||||
'result' => 'failure',
|
||||
'messages' => $messages,
|
||||
'refresh' => (isset($_SESSION['refresh_totals'])) ? 'true' : 'false'
|
||||
'refresh' => isset( $woocommerce->session->refresh_totals ) ? 'true' : 'false'
|
||||
)
|
||||
);
|
||||
|
||||
unset($_SESSION['refresh_totals']);
|
||||
unset( $woocommerce->session->refresh_totals );
|
||||
exit;
|
||||
endif;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1169,8 +1169,9 @@ class WC_Order {
|
|||
* @return void
|
||||
*/
|
||||
function cancel_order( $note = '' ) {
|
||||
|
||||
unset($_SESSION['order_awaiting_payment']);
|
||||
global $woocommerce;
|
||||
|
||||
unset( $woocommerce->session->order_awaiting_payment );
|
||||
|
||||
$this->update_status('cancelled', $note);
|
||||
|
||||
|
@ -1190,8 +1191,9 @@ class WC_Order {
|
|||
* @return void
|
||||
*/
|
||||
function payment_complete() {
|
||||
|
||||
unset( $_SESSION['order_awaiting_payment'] );
|
||||
global $woocommerce;
|
||||
|
||||
unset( $woocommerce->session->order_awaiting_payment );
|
||||
|
||||
if ( $this->status == 'on-hold' || $this->status == 'pending' || $this->status == 'failed' ) {
|
||||
|
||||
|
|
|
@ -309,7 +309,9 @@ class WC_Query {
|
|||
* @return array
|
||||
*/
|
||||
function get_catalog_ordering_args() {
|
||||
$current_order = ( isset( $_SESSION['orderby'] ) ) ? $_SESSION['orderby'] : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
|
||||
global $woocommerce;
|
||||
|
||||
$current_order = ( isset( $woocommerce->session->orderby ) ) ? $woocommerce->session->orderby : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
|
||||
|
||||
switch ( $current_order ) {
|
||||
case 'date' :
|
||||
|
|
|
@ -24,7 +24,7 @@ class WC_Session {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function __construct() {
|
||||
public function __construct() {
|
||||
|
||||
$this->_cookie = 'wc_session_cookie_' . COOKIEHASH;
|
||||
$this->_customer_id = $this->get_customer_id();
|
||||
|
@ -34,9 +34,8 @@ class WC_Session {
|
|||
$this->_data = array();
|
||||
|
||||
// When leaving or ending page load, store data
|
||||
add_filter( 'wp_redirect', array( &$this, 'save_data' ), 1, 2 );
|
||||
add_filter( 'shutdown', array( &$this, 'save_data' ) );
|
||||
}
|
||||
add_action( 'shutdown', array( &$this, 'save_data' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* get_customer_id function.
|
||||
|
@ -44,7 +43,7 @@ class WC_Session {
|
|||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
function get_customer_id() {
|
||||
public function get_customer_id() {
|
||||
if ( is_user_logged_in() ) {
|
||||
return get_current_user_id();
|
||||
} elseif ( $customer_id = $this->get_session_cookie() ) {
|
||||
|
@ -60,7 +59,7 @@ class WC_Session {
|
|||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
function get_session_cookie() {
|
||||
public function get_session_cookie() {
|
||||
if ( ! isset( $_COOKIE[ $this->_cookie ] ) )
|
||||
return false;
|
||||
|
||||
|
@ -82,8 +81,8 @@ class WC_Session {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function create_customer_id() {
|
||||
$customer_id = uniqid( 'wc_' );
|
||||
public function create_customer_id() {
|
||||
$customer_id = wp_generate_password( 32 ); // Ensure this and the transient is < 45 chars. wc_session_ leaves 34.
|
||||
$expires = time() + 172800;
|
||||
$data = $customer_id . $expires;
|
||||
$hash = hash_hmac( 'md5', $data, wp_hash( $data ) );
|
||||
|
@ -117,6 +116,28 @@ class WC_Session {
|
|||
$this->_data[ $property ] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* __isset function.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $property
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset( $property ) {
|
||||
return isset( $this->_data[ $property ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* __unset function.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $property
|
||||
* @return void
|
||||
*/
|
||||
public function __unset( $property ) {
|
||||
unset( $this->_data[ $property ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* save_data function.
|
||||
*
|
||||
|
|
|
@ -236,9 +236,6 @@ class WC_BACS extends WC_Payment_Gateway {
|
|||
// Remove cart
|
||||
$woocommerce->cart->empty_cart();
|
||||
|
||||
// Empty awaiting payment session
|
||||
unset($_SESSION['order_awaiting_payment']);
|
||||
|
||||
// Return thankyou redirect
|
||||
return array(
|
||||
'result' => 'success',
|
||||
|
|
|
@ -150,9 +150,6 @@ class WC_Cheque extends WC_Payment_Gateway {
|
|||
// Remove cart
|
||||
$woocommerce->cart->empty_cart();
|
||||
|
||||
// Empty awaiting payment session
|
||||
unset($_SESSION['order_awaiting_payment']);
|
||||
|
||||
// Return thankyou redirect
|
||||
return array(
|
||||
'result' => 'success',
|
||||
|
|
|
@ -132,13 +132,13 @@ class WC_COD extends WC_Payment_Gateway {
|
|||
|
||||
$chosen_method = $order->shipping_method;
|
||||
|
||||
} elseif ( empty( $_SESSION['_chosen_shipping_method'] ) ) {
|
||||
} elseif ( empty( $woocommerce->session->chosen_shipping_method ) ) {
|
||||
return false;
|
||||
} else {
|
||||
$chosen_method = $_SESSION['_chosen_shipping_method'];
|
||||
$chosen_method = $woocommerce->session->chosen_shipping_method;
|
||||
}
|
||||
|
||||
$found = false;
|
||||
$found = false;
|
||||
|
||||
foreach ( $this->enable_for_methods as $method_id ) {
|
||||
if ( strpos( $chosen_method, $method_id ) === 0 ) {
|
||||
|
@ -176,9 +176,6 @@ class WC_COD extends WC_Payment_Gateway {
|
|||
// Remove cart
|
||||
$woocommerce->cart->empty_cart();
|
||||
|
||||
// Empty awaiting payment session
|
||||
unset($_SESSION['order_awaiting_payment']);
|
||||
|
||||
// Return thankyou redirect
|
||||
return array(
|
||||
'result' => 'success',
|
||||
|
|
|
@ -203,8 +203,8 @@ class WC_Shipping {
|
|||
$_available_methods = $this->get_available_shipping_methods();
|
||||
|
||||
// Get chosen method
|
||||
if ( ! empty( $_SESSION['_chosen_shipping_method'] ) && isset( $_SESSION['_available_methods_count'] ) && $_SESSION['_available_methods_count'] == sizeof( $_available_methods ) )
|
||||
$chosen_method = $_SESSION['_chosen_shipping_method'];
|
||||
if ( ! empty( $_SESSION['chosen_shipping_method'] ) && isset( $_SESSION['_available_methods_count'] ) && $_SESSION['_available_methods_count'] == sizeof( $_available_methods ) )
|
||||
$chosen_method = $_SESSION['chosen_shipping_method'];
|
||||
|
||||
$_SESSION['_available_methods_count'] = sizeof( $_available_methods );
|
||||
|
||||
|
@ -240,7 +240,7 @@ class WC_Shipping {
|
|||
}
|
||||
|
||||
if ( $chosen_method ) {
|
||||
$_SESSION['_chosen_shipping_method'] = $chosen_method;
|
||||
$_SESSION['chosen_shipping_method'] = $chosen_method;
|
||||
$this->shipping_total = $_available_methods[$chosen_method]->cost;
|
||||
$this->shipping_taxes = $_available_methods[$chosen_method]->taxes;
|
||||
$this->shipping_label = $_available_methods[$chosen_method]->label;
|
||||
|
@ -349,7 +349,7 @@ class WC_Shipping {
|
|||
* @return void
|
||||
*/
|
||||
function reset_shipping() {
|
||||
unset( $_SESSION['_chosen_shipping_method'] );
|
||||
unset( $_SESSION['chosen_shipping_method'] );
|
||||
$this->shipping_total = 0;
|
||||
$this->shipping_taxes = array();
|
||||
$this->shipping_label = null;
|
||||
|
|
|
@ -150,19 +150,24 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
|
|||
|
||||
== Changelog ==
|
||||
|
||||
= 1.7 =
|
||||
= 1.7.0 =
|
||||
* Feature - Added sales by category report
|
||||
* Feature - Multiple downloadable files per product/variation (kudos Justin Stern)
|
||||
* Feature - Download expirey for variations (kudos niravmehta)
|
||||
* Feature - Added wildcard support to local delivery postcodes
|
||||
* Feature - Option to enable Cash on Delivery for select shipping methods only
|
||||
* Feature - Stopped using PHP sessions for cart data - using cookies and transients instead to allow WC to function better with static caching. Also to reduce support regarding hosts and session configurations.
|
||||
|
||||
* Templating - email-order-items.php change get_downloadable_file_url() to get_downloadable_file_urls() to support multiple files
|
||||
|
||||
* Tweak - If a PayPal prefix is changed, IPN requests break for all existing orders - fixed. new woocommerce_get_order_id_by_order_key() function added. Thanks Brent.
|
||||
* Tweak - On add to cart success, redirect back.
|
||||
* Tweak - Prefix jquery plugins JS
|
||||
|
||||
* Fix - Added more error messages for coupons.
|
||||
* Fix - Variation sku updating after selection.
|
||||
* Fix - Active plugins display on status page.
|
||||
|
||||
* Localization - French update by Arnaud Cheminand
|
||||
* Localization - Romanian update by silviu-bucsa
|
||||
* Localization - Dutch updates by Ramoonus
|
||||
|
|
|
@ -56,8 +56,8 @@ function woocommerce_cart( $atts ) {
|
|||
|
||||
$validation = $woocommerce->validation();
|
||||
|
||||
$_SESSION['calculated_shipping'] = true;
|
||||
unset($_SESSION['_chosen_shipping_method']);
|
||||
$woocommerce->session->calculated_shipping = true;
|
||||
unset( $woocommerce->session->chosen_shipping_method );
|
||||
$country = $_POST['calc_shipping_country'];
|
||||
$state = $_POST['calc_shipping_state'];
|
||||
$postcode = $_POST['calc_shipping_postcode'];
|
||||
|
|
|
@ -44,7 +44,7 @@ function woocommerce_thankyou( $atts ) {
|
|||
if (isset($_GET['key'])) $order_key = $_GET['key']; else $order_key = '';
|
||||
|
||||
// Empty awaiting payment session
|
||||
unset($_SESSION['order_awaiting_payment']);
|
||||
unset( $woocommerce->session->order_awaiting_payment );
|
||||
|
||||
if ($order_id > 0) :
|
||||
$order = new WC_Order( $order_id );
|
||||
|
|
|
@ -79,7 +79,7 @@ $available_methods = $woocommerce->shipping->get_available_shipping_methods();
|
|||
echo '<select name="shipping_method" id="shipping_method">';
|
||||
|
||||
foreach ( $available_methods as $method )
|
||||
echo '<option value="' . esc_attr( $method->id ) . '" ' . selected( $method->id, $_SESSION['_chosen_shipping_method'], false ) . '>' . strip_tags( $method->full_label ) . '</option>';
|
||||
echo '<option value="' . esc_attr( $method->id ) . '" ' . selected( $method->id, $woocommerce->session->chosen_shipping_method, false ) . '>' . strip_tags( $method->full_label ) . '</option>';
|
||||
|
||||
echo '</select>';
|
||||
|
||||
|
@ -89,7 +89,7 @@ $available_methods = $woocommerce->shipping->get_available_shipping_methods();
|
|||
echo '<ul id="shipping_method">';
|
||||
|
||||
foreach ( $available_methods as $method )
|
||||
echo '<li><input type="radio" name="shipping_method" id="shipping_method_' . sanitize_title( $method->id ) . '" value="' . esc_attr( $method->id ) . '" ' . checked( $method->id, $_SESSION['_chosen_shipping_method'], false) . ' /> <label for="shipping_method_' . sanitize_title( $method->id ) . '">' . $method->full_label . '</label></li>';
|
||||
echo '<li><input type="radio" name="shipping_method" id="shipping_method_' . sanitize_title( $method->id ) . '" value="' . esc_attr( $method->id ) . '" ' . checked( $method->id, $woocommerce->session->chosen_shipping_method, false) . ' /> <label for="shipping_method_' . sanitize_title( $method->id ) . '">' . $method->full_label . '</label></li>';
|
||||
|
||||
echo '</ul>';
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ $available_methods = $woocommerce->shipping->get_available_shipping_methods();
|
|||
echo '<select name="shipping_method" id="shipping_method">';
|
||||
|
||||
foreach ( $available_methods as $method )
|
||||
echo '<option value="' . esc_attr( $method->id ) . '" ' . selected( $method->id, $_SESSION['_chosen_shipping_method'], false ) . '>' . strip_tags( $method->full_label ) . '</option>';
|
||||
echo '<option value="' . esc_attr( $method->id ) . '" ' . selected( $method->id, $woocommerce->session->chosen_shipping_method, false ) . '>' . strip_tags( $method->full_label ) . '</option>';
|
||||
|
||||
echo '</select>';
|
||||
|
||||
|
@ -94,7 +94,7 @@ $available_methods = $woocommerce->shipping->get_available_shipping_methods();
|
|||
echo '<ul id="shipping_method">';
|
||||
|
||||
foreach ( $available_methods as $method )
|
||||
echo '<li><input type="radio" name="shipping_method" id="shipping_method_' . sanitize_title( $method->id ) . '" value="' . esc_attr( $method->id ) . '" ' . checked( $method->id, $_SESSION['_chosen_shipping_method'], false) . ' /> <label for="shipping_method_' . sanitize_title( $method->id ) . '">' . $method->full_label . '</label></li>';
|
||||
echo '<li><input type="radio" name="shipping_method" id="shipping_method_' . sanitize_title( $method->id ) . '" value="' . esc_attr( $method->id ) . '" ' . checked( $method->id, $woocommerce->session->chosen_shipping_method, false) . ' /> <label for="shipping_method_' . sanitize_title( $method->id ) . '">' . $method->full_label . '</label></li>';
|
||||
|
||||
echo '</ul>';
|
||||
|
||||
|
@ -239,13 +239,15 @@ $available_methods = $woocommerce->shipping->get_available_shipping_methods();
|
|||
// Chosen Method
|
||||
if (sizeof($available_gateways)) :
|
||||
$default_gateway = get_option('woocommerce_default_gateway');
|
||||
if (isset($_SESSION['_chosen_payment_method']) && isset($available_gateways[$_SESSION['_chosen_payment_method']])) :
|
||||
$available_gateways[$_SESSION['_chosen_payment_method']]->set_current();
|
||||
elseif (isset($available_gateways[$default_gateway])) :
|
||||
$available_gateways[$default_gateway]->set_current();
|
||||
else :
|
||||
current($available_gateways)->set_current();
|
||||
endif;
|
||||
|
||||
if ( isset( $woocommerce->session->chosen_shipping_method ) && isset( $available_gateways[ $woocommerce->session->chosen_shipping_method ] ) ) {
|
||||
$available_gateways[ $woocommerce->session->chosen_shipping_method ]->set_current();
|
||||
} elseif ( isset( $available_gateways[ $default_gateway ] ) ) {
|
||||
$available_gateways[ $default_gateway ]->set_current();
|
||||
} else {
|
||||
current( $available_gateways )->set_current();
|
||||
}
|
||||
|
||||
endif;
|
||||
foreach ($available_gateways as $gateway ) :
|
||||
?>
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
*
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 1.6.4
|
||||
* @version 1.7
|
||||
*/
|
||||
|
||||
global $woocommerce;
|
||||
?>
|
||||
<form class="woocommerce_ordering" method="POST">
|
||||
<select name="sort" class="orderby">
|
||||
|
@ -19,7 +19,7 @@
|
|||
));
|
||||
|
||||
foreach ( $catalog_orderby as $id => $name )
|
||||
echo '<option value="' . $id . '" ' . selected( $_SESSION['orderby'], $id, false ) . '>' . $name . '</option>';
|
||||
echo '<option value="' . $id . '" ' . selected( $woocommerce->session->orderby, $id, false ) . '>' . $name . '</option>';
|
||||
?>
|
||||
</select>
|
||||
</form>
|
|
@ -119,7 +119,8 @@ function woocommerce_ajax_update_shipping_method() {
|
|||
|
||||
if ( ! defined('WOOCOMMERCE_CART') ) define( 'WOOCOMMERCE_CART', true );
|
||||
|
||||
if ( isset( $_POST['shipping_method'] ) ) $_SESSION['_chosen_shipping_method'] = $_POST['shipping_method'];
|
||||
if ( isset( $_POST['shipping_method'] ) )
|
||||
$woocommerce->session->chosen_shipping_method = $_POST['shipping_method'];
|
||||
|
||||
$woocommerce->cart->calculate_totals();
|
||||
|
||||
|
@ -143,23 +144,32 @@ function woocommerce_ajax_update_order_review() {
|
|||
|
||||
check_ajax_referer( 'update-order-review', 'security' );
|
||||
|
||||
if (!defined('WOOCOMMERCE_CHECKOUT')) define('WOOCOMMERCE_CHECKOUT', true);
|
||||
if ( ! defined( 'WOOCOMMERCE_CHECKOUT' ) )
|
||||
define( 'WOOCOMMERCE_CHECKOUT', true );
|
||||
|
||||
if (sizeof($woocommerce->cart->get_cart())==0) :
|
||||
echo '<div class="woocommerce_error">'.__('Sorry, your session has expired.', 'woocommerce').' <a href="'.home_url().'">'.__('Return to homepage →', 'woocommerce').'</a></div>';
|
||||
if ( sizeof( $woocommerce->cart->get_cart() ) == 0 ) {
|
||||
echo '<div class="woocommerce_error">' . __( 'Sorry, your session has expired.', 'woocommerce' ) . ' <a href="' . home_url() . '">' . __( 'Return to homepage →', 'woocommerce' ) . '</a></div>';
|
||||
die();
|
||||
endif;
|
||||
}
|
||||
|
||||
do_action('woocommerce_checkout_update_order_review', $_POST['post_data']);
|
||||
|
||||
if (isset($_POST['shipping_method'])) $_SESSION['_chosen_shipping_method'] = $_POST['shipping_method'];
|
||||
if (isset($_POST['payment_method'])) $_SESSION['_chosen_payment_method'] = $_POST['payment_method'];
|
||||
if (isset($_POST['country'])) $woocommerce->customer->set_country( $_POST['country'] );
|
||||
if (isset($_POST['state'])) $woocommerce->customer->set_state( $_POST['state'] );
|
||||
if (isset($_POST['postcode'])) $woocommerce->customer->set_postcode( $_POST['postcode'] );
|
||||
if (isset($_POST['s_country'])) $woocommerce->customer->set_shipping_country( $_POST['s_country'] );
|
||||
if (isset($_POST['s_state'])) $woocommerce->customer->set_shipping_state( $_POST['s_state'] );
|
||||
if (isset($_POST['s_postcode'])) $woocommerce->customer->set_shipping_postcode( $_POST['s_postcode'] );
|
||||
if ( isset( $_POST['shipping_method'] ) )
|
||||
$woocommerce->session->chosen_shipping_method = $_POST['shipping_method'];
|
||||
if ( isset( $_POST['payment_method'] ) )
|
||||
$woocommerce->session->chosen_shipping_method = $_POST['payment_method'];
|
||||
if ( isset( $_POST['country'] ) )
|
||||
$woocommerce->customer->set_country( $_POST['country'] );
|
||||
if ( isset( $_POST['state'] ) )
|
||||
$woocommerce->customer->set_state( $_POST['state'] );
|
||||
if ( isset( $_POST['postcode'] ) )
|
||||
$woocommerce->customer->set_postcode( $_POST['postcode'] );
|
||||
if ( isset( $_POST['s_country'] ) )
|
||||
$woocommerce->customer->set_shipping_country( $_POST['s_country'] );
|
||||
if ( isset( $_POST['s_state'] ) )
|
||||
$woocommerce->customer->set_shipping_state( $_POST['s_state'] );
|
||||
if ( isset( $_POST['s_postcode'] ) )
|
||||
$woocommerce->customer->set_shipping_postcode( $_POST['s_postcode'] );
|
||||
|
||||
$woocommerce->cart->calculate_totals();
|
||||
|
||||
|
|
|
@ -217,13 +217,9 @@ function woocommerce_load_persistent_cart( $user_login, $user ) {
|
|||
|
||||
$saved_cart = get_user_meta( $user->ID, '_woocommerce_persistent_cart', true );
|
||||
|
||||
if ($saved_cart) {
|
||||
if (!isset($_SESSION['cart']) || !is_array($_SESSION['cart']) || sizeof($_SESSION['cart'])==0) {
|
||||
|
||||
$_SESSION['cart'] = $saved_cart['cart'];
|
||||
|
||||
}
|
||||
}
|
||||
if ( $saved_cart )
|
||||
if ( empty( $woocommerce->session->cart ) || ! is_array( $woocommerce->session->cart ) || sizeof( $woocommerce->session->cart ) == 0 )
|
||||
$woocommerce->session->cart = $saved_cart['cart'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -148,8 +148,10 @@ function woocommerce_nav_menu_items( $items, $args ) {
|
|||
* @return void
|
||||
*/
|
||||
function woocommerce_update_catalog_ordering() {
|
||||
global $woocommerce;
|
||||
|
||||
if ( isset( $_REQUEST['sort'] ) && $_REQUEST['sort'] != '' )
|
||||
$_SESSION['orderby'] = esc_attr($_REQUEST['sort']);
|
||||
$woocommerce->session->orderby = esc_attr( $_REQUEST['sort'] );
|
||||
}
|
||||
|
||||
|
||||
|
@ -438,19 +440,17 @@ function woocommerce_clear_cart_after_payment() {
|
|||
|
||||
if ( $order->order_key == $order_key ) {
|
||||
$woocommerce->cart->empty_cart();
|
||||
unset( $_SESSION['order_awaiting_payment'] );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( isset( $_SESSION['order_awaiting_payment'] ) && $_SESSION['order_awaiting_payment'] > 0 ) {
|
||||
if ( $woocommerce->session->order_awaiting_payment > 0 ) {
|
||||
|
||||
$order = new WC_Order( $_SESSION['order_awaiting_payment'] );
|
||||
$order = new WC_Order( $woocommerce->session->order_awaiting_payment );
|
||||
|
||||
if ( $order->id > 0 && $order->status !== 'pending' ) {
|
||||
$woocommerce->cart->empty_cart();
|
||||
unset($_SESSION['order_awaiting_payment']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -377,8 +377,11 @@ if ( ! function_exists( 'woocommerce_catalog_ordering' ) ) {
|
|||
* @return void
|
||||
*/
|
||||
function woocommerce_catalog_ordering() {
|
||||
if ( ! isset( $_SESSION['orderby'] ) )
|
||||
$_SESSION['orderby'] = apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
|
||||
global $woocommerce;
|
||||
|
||||
if ( ! isset( $woocommerce->session->orderby ) )
|
||||
$woocommerce->session->orderby = apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
|
||||
|
||||
woocommerce_get_template( 'loop/sorting.php' );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Plugin Name: WooCommerce
|
||||
* Plugin URI: http://www.woothemes.com/woocommerce/
|
||||
* Description: An e-commerce toolkit that helps you sell anything. Beautifully.
|
||||
* Version: 1.6.5.1
|
||||
* Version: 1.7.0 beta
|
||||
* Author: WooThemes
|
||||
* Author URI: http://woothemes.com
|
||||
* Requires at least: 3.3
|
||||
|
@ -37,7 +37,7 @@ class Woocommerce {
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
var $version = '1.6.5.1';
|
||||
var $version = '1.7.0';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
|
@ -240,6 +240,7 @@ class Woocommerce {
|
|||
include( 'classes/class-wc-cart.php' ); // The main cart class
|
||||
include( 'classes/class-wc-coupon.php' ); // Coupon class
|
||||
include( 'classes/class-wc-customer.php' ); // Customer class
|
||||
include( 'classes/class-wc-session.php' ); // Session class
|
||||
}
|
||||
|
||||
|
||||
|
@ -297,7 +298,8 @@ class Woocommerce {
|
|||
|
||||
// Class instances
|
||||
$this->cart = new WC_Cart(); // Cart class, stores the cart contents
|
||||
$this->customer = new WC_Customer(); // Customer class, sorts out session data such as location
|
||||
$this->customer = new WC_Customer(); // Customer class, handles data such as customer location
|
||||
$this->session = new WC_Session(); // Session class, handles session data for customers
|
||||
$this->query = new WC_Query(); // Query class, handles front-end queries and loops
|
||||
|
||||
// Load messages
|
||||
|
@ -1147,7 +1149,7 @@ class Woocommerce {
|
|||
}
|
||||
|
||||
// Global frontend scripts
|
||||
wp_enqueue_script( 'woocommerce', $frontend_script_path . 'woocommerce' . $suffix . '.js', array( 'jquery', 'jquery-plugins' ), $this->version, true );
|
||||
wp_enqueue_script( 'woocommerce', $frontend_script_path . 'woocommerce' . $suffix . '.js', array( 'jquery', 'wc-jquery-plugins' ), $this->version, true );
|
||||
|
||||
// Variables for JS scripts
|
||||
$woocommerce_params = array(
|
||||
|
@ -1366,16 +1368,13 @@ class Woocommerce {
|
|||
* @return void
|
||||
*/
|
||||
function load_messages() {
|
||||
if ( isset( $_SESSION['errors'] ) ) $this->errors = $_SESSION['errors'];
|
||||
if ( isset( $_SESSION['messages'] ) ) $this->messages = $_SESSION['messages'];
|
||||
|
||||
unset( $_SESSION['messages'] );
|
||||
unset( $_SESSION['errors'] );
|
||||
$this->errors = $this->session->errors;
|
||||
$this->messages = $this->session->messages;
|
||||
unset( $this->session->errors, $this->session->messages );
|
||||
|
||||
// Load errors from querystring
|
||||
if ( isset( $_GET['wc_error'] ) ) {
|
||||
if ( isset( $_GET['wc_error'] ) )
|
||||
$this->add_error( esc_attr( $_GET['wc_error'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1411,7 +1410,7 @@ class Woocommerce {
|
|||
*/
|
||||
function clear_messages() {
|
||||
$this->errors = $this->messages = array();
|
||||
unset( $_SESSION['messages'], $_SESSION['errors'] );
|
||||
unset( $this->session->errors, $this->session->messages );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1477,8 +1476,8 @@ class Woocommerce {
|
|||
* @return void
|
||||
*/
|
||||
function set_messages() {
|
||||
$_SESSION['errors'] = $this->errors;
|
||||
$_SESSION['messages'] = $this->messages;
|
||||
$this->session->errors = $this->errors;
|
||||
$this->session->messages = $this->messages;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1496,7 +1495,8 @@ class Woocommerce {
|
|||
$this->set_messages();
|
||||
|
||||
// IIS fix
|
||||
if ( $is_IIS ) session_write_close();
|
||||
if ( $is_IIS )
|
||||
session_write_close();
|
||||
|
||||
return apply_filters( 'woocommerce_redirect', $location );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue