Revert 136456f805ccdf9b7b6bce027dc24da3c14d4281^..HEAD
This commit is contained in:
parent
b6248e66e9
commit
1dc5a3bc0b
|
@ -753,12 +753,12 @@ function woocommerce_product_type_box() {
|
|||
), $product_type) ) );
|
||||
|
||||
// Visibility
|
||||
woocommerce_wp_select( array( 'id' => '_visibility', 'label' => __('Visibility', 'woocommerce'), 'options' => apply_filters('woocommerce_product_visibility_options', array(
|
||||
'visible' => __('Catalog & search', 'woocommerce'),
|
||||
woocommerce_wp_select( array( 'id' => '_visibility', 'label' => __('Product visibility', 'woocommerce'), 'options' => apply_filters('woocommerce_product_visibility_options', array(
|
||||
'visible' => __('Catalog & Search', 'woocommerce'),
|
||||
'catalog' => __('Catalog', 'woocommerce'),
|
||||
'search' => __('Search', 'woocommerce'),
|
||||
'hidden' => __('Hidden', 'woocommerce')
|
||||
)), 'description' => __('Define the loops this product should be visible in. It will still be accessible directly.', 'woocommerce') ) );
|
||||
)) ) );
|
||||
|
||||
woocommerce_wp_checkbox( array( 'id' => '_virtual', 'wrapper_class' => 'show_if_simple', 'label' => __('Virtual', 'woocommerce'), 'description' => __('Enable this option if a product is not shipped or there is no shipping cost', 'woocommerce') ) );
|
||||
|
||||
|
|
|
@ -39,8 +39,6 @@ add_action('admin_init', 'woocommerce_admin_init');
|
|||
function woocommerce_admin_init() {
|
||||
global $pagenow;
|
||||
|
||||
ob_start();
|
||||
|
||||
include_once( 'woocommerce-admin-hooks.php' );
|
||||
include_once( 'woocommerce-admin-functions.php' );
|
||||
|
||||
|
|
|
@ -38,15 +38,13 @@ form.cart .button{vertical-align:middle;float:left;}
|
|||
span.onsale{color:#fff;min-height:32px;min-width:32px;padding:4px;font-size:12px;font-weight:bold;position:absolute;text-align:center;line-height:32px;top:6px;left:6px;margin:0;-webkit-border-radius:20px;-moz-border-radius:20px;border-radius:20px;background:#a1c41e;background:-webkit-gradient(linear, left top, left bottom, from(#a1c41e), to(#8fae1b));background:-webkit-linear-gradient(#a1c41e, #8fae1b);background:-moz-linear-gradient(center top, #a1c41e 0%, #8fae1b 100%);background:-moz-gradient(center top, #a1c41e 0%, #8fae1b 100%);text-shadow:0 -1px 0 #8fae1b;-webkit-box-shadow:inset 0 1px 0 rgba(255, 255, 255, 0.3),inset 0 -1px 0 rgba(0, 0, 0, 0.2),0 1px 2px rgba(0, 0, 0, 0.2);-moz-box-shadow:inset 0 1px 0 rgba(255, 255, 255, 0.3),inset 0 -1px 0 rgba(0, 0, 0, 0.2),0 1px 2px rgba(0, 0, 0, 0.2);box-shadow:inset 0 1px 0 rgba(255, 255, 255, 0.3),inset 0 -1px 0 rgba(0, 0, 0, 0.2),0 1px 2px rgba(0, 0, 0, 0.2);}
|
||||
.products ul,ul.products{margin:0 0 14px;padding:0;list-style:none outside;}.products ul li,ul.products li{list-style:none outside;}
|
||||
.related,.upsells.products{overflow:hidden;zoom:1;}.related ul.products,.upsells.products ul.products,.related ul,.upsells.products ul{float:none;}.related ul.products li,.upsells.products ul.products li,.related ul li,.upsells.products ul li{width:48%;}.related ul.products li img,.upsells.products ul.products li img,.related ul li img,.upsells.products ul li img{width:100%;height:auto;}
|
||||
ul.products{clear:both;margin-left:0;padding-left:0;}ul.products li{float:left;margin:0 3.8% 2.992em 0;padding:0;position:relative;width:22.05%;margin-left:0;}ul.products li .onsale{top:0;right:0;left:auto;margin:-6px -6px 0 0;}
|
||||
ul.products li h3{padding:.5em 0;margin:0;font-size:1em;}
|
||||
ul.products{clear:both;margin-left:0;padding-left:0;}ul.products li{float:left;margin:0 3.8% 20px 0;padding:0;position:relative;width:22.05%;margin-left:0;}ul.products li .onsale{top:0;right:0;left:auto;margin:-6px -6px 0 0;}
|
||||
ul.products li a{text-decoration:none;}
|
||||
ul.products li a img{width:100%;height:auto;display:block;margin:0 0 8px;border:1px solid #ddd;box-shadow:0 1px 2px 0 rgba(0, 0, 0, 0.1);-webkit-box-shadow:0 1px 2px 0 rgba(0, 0, 0, 0.1);-moz-box-shadow:0 1px 2px 0 rgba(0, 0, 0, 0.1);}
|
||||
ul.products li a:hover img{border:1px solid #bbb;}
|
||||
ul.products li strong{color:#555;display:block;}
|
||||
ul.products li .price{color:#8fae1b;display:block;font-weight:normal;margin-bottom:.5em;}ul.products li .price del{font-size:11px;line-height:10px;margin:-2px 0 0 0;display:block;color:#ccc;}
|
||||
ul.products li .price ins{background:none;}
|
||||
ul.products li .price .from{font-size:11px;line-height:10px;margin:-2px 0 0 0;display:block;text-transform:uppercase;color:#ccc;}
|
||||
ul.products li .price{color:green;display:block;font-weight:normal;}ul.products li .price del{font-size:10px;line-height:10px;margin:-2px 0 0 0;display:block;color:#ccc;}
|
||||
ul.products li .price .from{font-size:10px;line-height:10px;margin:-2px 0 0 0;display:block;color:#ccc;}
|
||||
ul.products li.first{clear:both;}
|
||||
ul.products li.last{margin-right:0;}
|
||||
.woocommerce_ordering{margin-bottom:24px;}
|
||||
|
@ -89,7 +87,7 @@ table.shop_table tfoot td{font-weight:bold;}
|
|||
table.my_account_orders{font-size:0.85em;}table.my_account_orders th,table.my_account_orders td{padding:4px 8px;vertical-align:top;}
|
||||
table.my_account_orders .button{white-space:nowrap;}
|
||||
table.cart img{width:32px;height:auto;}
|
||||
ul.cart_list,ul.product_list_widget{list-style:none outside;padding:0;margin:0;}ul.cart_list li,ul.product_list_widget li{padding:4px 0;margin:0;list-style:none;}ul.cart_list li:after,ul.product_list_widget li:after{content:"";display:block;clear:both;}
|
||||
ul.cart_list,ul.product_list_widget{list-style:none outside;padding:0;margin:0;}ul.cart_list li,ul.product_list_widget li{padding:4px 0;margin:0;}ul.cart_list li:after,ul.product_list_widget li:after{content:"";display:block;clear:both;}
|
||||
ul.cart_list li a,ul.product_list_widget li a{display:block;font-weight:bold;}
|
||||
ul.cart_list li img,ul.product_list_widget li img{float:left;margin-right:4px;border:1px solid #ddd;width:32px;height:auto;}
|
||||
.widget_shopping_cart .total{border-top:3px double #ddd;padding:4px 0 0;margin:0;}.widget_shopping_cart .total strong{min-width:40px;display:inline-block;}
|
||||
|
@ -177,6 +175,6 @@ ol.commentlist.notes li.note .description p:last-child{margin-bottom:0;}
|
|||
.widget_price_filter .ui-slider-horizontal .ui-slider-range{top:0;height:100%;}
|
||||
.widget_price_filter .ui-slider-horizontal .ui-slider-range-min{left:0;}
|
||||
.widget_price_filter .ui-slider-horizontal .ui-slider-range-max{right:0;}
|
||||
.widget_layered_nav ul{margin:0;padding:0;border:0;list-style:none outside;}.widget_layered_nav ul li{overflow:hidden;zoom:1;padding:0 0 1px;list-style:none;}.widget_layered_nav ul li a,.widget_layered_nav ul li span{padding:1px 0;float:left;}
|
||||
.widget_layered_nav ul{margin:0;padding:0;border:0;list-style:none outside;}.widget_layered_nav ul li{overflow:hidden;zoom:1;padding:0 0 1px;}.widget_layered_nav ul li a,.widget_layered_nav ul li span{padding:1px 0;float:left;}
|
||||
.widget_layered_nav ul li.chosen a{padding:0 6px 0 18px;border:1px solid #3399cc;background:#3399cc url(../images/cross_white.png) no-repeat 6px center;box-shadow:inset 0 1px 1px rgba(255, 255, 255, 0.5) #888888;-webkit-box-shadow:inset 0 1px 1px rgba(255, 255, 255, 0.5) #888888;-moz-box-shadow:inset 0 1px 1px rgba(255, 255, 255, 0.5) #888888;color:#fff;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;}
|
||||
.widget_layered_nav ul small.count{float:right;margin-left:6px;font-size:1em;padding:1px 0;color:#999;}
|
||||
|
|
|
@ -317,6 +317,7 @@ form.cart {
|
|||
.button {
|
||||
vertical-align: middle;
|
||||
float: left;
|
||||
//margin: 2px 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -383,7 +384,7 @@ ul.products {
|
|||
padding-left:0;
|
||||
li {
|
||||
float: left;
|
||||
margin: 0 3.8% 2.992em 0;
|
||||
margin: 0 3.8% 20px 0;
|
||||
padding: 0;
|
||||
position: relative;
|
||||
width:22.05%;
|
||||
|
@ -394,11 +395,6 @@ ul.products {
|
|||
left: auto;
|
||||
margin: -6px -6px 0 0;
|
||||
}
|
||||
h3 {
|
||||
padding:.5em 0;
|
||||
margin:0;
|
||||
font-size:1em;
|
||||
}
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
@ -418,26 +414,21 @@ ul.products {
|
|||
display: block;
|
||||
}
|
||||
.price {
|
||||
color: #8fae1b;
|
||||
color: green;
|
||||
display: block;
|
||||
font-weight: normal;
|
||||
margin-bottom:.5em;
|
||||
del {
|
||||
font-size: 11px;
|
||||
font-size: 10px;
|
||||
line-height: 10px;
|
||||
margin: -2px 0 0 0;
|
||||
display: block;
|
||||
color: #ccc;
|
||||
}
|
||||
ins {
|
||||
background: none;
|
||||
}
|
||||
.from {
|
||||
font-size: 11px;
|
||||
font-size: 10px;
|
||||
line-height: 10px;
|
||||
margin: -2px 0 0 0;
|
||||
display: block;
|
||||
text-transform: uppercase;
|
||||
color: #ccc;
|
||||
}
|
||||
}
|
||||
|
@ -491,10 +482,20 @@ a.button, button.button, input.button, #review_form #submit {
|
|||
0 1px 2px rgba(0,0,0,0.1);
|
||||
|
||||
&.loading {
|
||||
//.opacity(0.5);
|
||||
color:#999;
|
||||
border-color:#ccc;
|
||||
|
||||
&:before {
|
||||
&:before {
|
||||
/*content:"";
|
||||
position: absolute;
|
||||
height:16px;
|
||||
width:16px;
|
||||
top:0.35em;
|
||||
right:-26px;
|
||||
text-indent: 0;
|
||||
background: url(../images/ajax-loader.gif) no-repeat;*/
|
||||
|
||||
content: "";
|
||||
position: absolute;
|
||||
top:0;
|
||||
|
@ -745,6 +746,10 @@ table.shop_table {
|
|||
border-top: 1px solid #E7E7E7;
|
||||
padding: 6px 12px;
|
||||
vertical-align: middle;
|
||||
|
||||
a.button {
|
||||
//margin:0 3px;
|
||||
}
|
||||
}
|
||||
tfoot td {
|
||||
font-weight: bold;
|
||||
|
@ -759,6 +764,7 @@ table.my_account_orders {
|
|||
}
|
||||
.button {
|
||||
white-space: nowrap;
|
||||
//margin: 4px 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -782,7 +788,6 @@ ul.cart_list, ul.product_list_widget {
|
|||
padding: 4px 0;
|
||||
margin: 0;
|
||||
.clearfix;
|
||||
list-style: none;
|
||||
a {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
|
@ -843,6 +848,7 @@ td.actions {
|
|||
}
|
||||
.button.alt {
|
||||
float: right;
|
||||
//margin:2px 0 0 6px;
|
||||
}
|
||||
}
|
||||
td.product-name {
|
||||
|
@ -935,6 +941,7 @@ td.quantity {
|
|||
}
|
||||
|
||||
.cart input {
|
||||
//width:100px;
|
||||
margin: 0;
|
||||
vertical-align: middle;
|
||||
line-height: 1em;
|
||||
|
@ -1349,7 +1356,6 @@ ol.commentlist.notes {
|
|||
overflow: hidden;
|
||||
zoom: 1;
|
||||
padding: 0 0 1px;
|
||||
list-style: none;
|
||||
a, span {
|
||||
padding: 1px 0;
|
||||
float: left;
|
||||
|
|
|
@ -157,345 +157,322 @@ class woocommerce_checkout {
|
|||
*/
|
||||
function process_checkout() {
|
||||
global $wpdb, $woocommerce;
|
||||
|
||||
|
||||
if (!defined('WOOCOMMERCE_CHECKOUT')) define('WOOCOMMERCE_CHECKOUT', true);
|
||||
|
||||
$woocommerce->verify_nonce('process_checkout');
|
||||
|
||||
|
||||
do_action('woocommerce_before_checkout_process');
|
||||
|
||||
if (isset($_POST) && $_POST && !isset($_POST['login']) && !isset($_POST['coupon_code'])) :
|
||||
|
||||
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()) );
|
||||
endif;
|
||||
|
||||
do_action('woocommerce_checkout_process');
|
||||
$woocommerce->verify_nonce('process_checkout');
|
||||
|
||||
// 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']) : '';
|
||||
|
||||
// Ship to billing only option
|
||||
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'];
|
||||
|
||||
// Update cart totals
|
||||
$woocommerce->cart->calculate_totals();
|
||||
|
||||
// Note if we skip shipping
|
||||
$skipped_shipping = false;
|
||||
|
||||
// Get posted checkout_fields and do validation
|
||||
foreach ($this->checkout_fields as $fieldset_key => $fieldset) :
|
||||
|
||||
// Skip shipping if its not needed
|
||||
if ($fieldset_key=='shipping' && (!$woocommerce->cart->needs_shipping() || $woocommerce->cart->ship_to_billing_address_only() || $this->posted['shiptobilling'])) :
|
||||
$skipped_shipping = true;
|
||||
continue;
|
||||
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()) );
|
||||
endif;
|
||||
|
||||
foreach ($fieldset as $key => $field) :
|
||||
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']) : '';
|
||||
|
||||
// Ship to billing only option
|
||||
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'];
|
||||
|
||||
// Update cart totals
|
||||
$woocommerce->cart->calculate_totals();
|
||||
|
||||
// Note if we skip shipping
|
||||
$skipped_shipping = false;
|
||||
|
||||
// Get posted checkout_fields and do validation
|
||||
foreach ($this->checkout_fields as $fieldset_key => $fieldset) :
|
||||
|
||||
if (!isset($field['type'])) $field['type'] = 'text';
|
||||
// Skip shipping if its not needed
|
||||
if ($fieldset_key=='shipping' && (!$woocommerce->cart->needs_shipping() || $woocommerce->cart->ship_to_billing_address_only() || $this->posted['shiptobilling'])) :
|
||||
$skipped_shipping = true;
|
||||
continue;
|
||||
endif;
|
||||
|
||||
// Get Value
|
||||
switch ($field['type']) :
|
||||
case "checkbox" :
|
||||
$this->posted[$key] = isset($_POST[$key]) ? 1 : 0;
|
||||
break;
|
||||
default :
|
||||
$this->posted[$key] = isset($_POST[$key]) ? woocommerce_clean($_POST[$key]) : '';
|
||||
break;
|
||||
endswitch;
|
||||
|
||||
// Hook to allow modification of value
|
||||
$this->posted[$key] = apply_filters('woocommerce_process_checkout_field_' . $key, $this->posted[$key]);
|
||||
|
||||
// Validation: Required fields
|
||||
if ( isset($field['required']) && $field['required'] && empty($this->posted[$key]) ) $woocommerce->add_error( $field['label'] . ' ' . __('is a required field.', 'woocommerce') );
|
||||
|
||||
if (!empty($this->posted[$key])) :
|
||||
// Special handling for validation and formatting
|
||||
switch ($key) :
|
||||
case "billing_postcode" :
|
||||
case "shipping_postcode" :
|
||||
$this->posted[$key] = strtolower(str_replace(' ', '', $this->posted[$key]));
|
||||
|
||||
if (!$woocommerce->validation->is_postcode( $this->posted[$key], $_POST['billing_country'] )) : $woocommerce->add_error( $field['label'] . __(' (billing) is not a valid postcode/ZIP.', 'woocommerce') );
|
||||
else :
|
||||
$this->posted[$key] = $woocommerce->validation->format_postcode( $this->posted[$key], $_POST['billing_country'] );
|
||||
endif;
|
||||
foreach ($fieldset as $key => $field) :
|
||||
|
||||
if (!isset($field['type'])) $field['type'] = 'text';
|
||||
|
||||
// Get Value
|
||||
switch ($field['type']) :
|
||||
case "checkbox" :
|
||||
$this->posted[$key] = isset($_POST[$key]) ? 1 : 0;
|
||||
break;
|
||||
case "billing_phone" :
|
||||
if (!$woocommerce->validation->is_phone( $this->posted[$key] )) : $woocommerce->add_error( $field['label'] . ' ' . __('is not a valid number.', 'woocommerce') ); endif;
|
||||
break;
|
||||
case "billing_email" :
|
||||
if (!$woocommerce->validation->is_email( $this->posted[$key] )) : $woocommerce->add_error( $field['label'] . ' ' . __('is not a valid email address.', 'woocommerce') ); endif;
|
||||
default :
|
||||
$this->posted[$key] = isset($_POST[$key]) ? woocommerce_clean($_POST[$key]) : '';
|
||||
break;
|
||||
endswitch;
|
||||
endif;
|
||||
|
||||
// Hook to allow modification of value
|
||||
$this->posted[$key] = apply_filters('woocommerce_process_checkout_field_' . $key, $this->posted[$key]);
|
||||
|
||||
// Validation: Required fields
|
||||
if ( isset($field['required']) && $field['required'] && empty($this->posted[$key]) ) $woocommerce->add_error( $field['label'] . ' ' . __('is a required field.', 'woocommerce') );
|
||||
|
||||
if (!empty($this->posted[$key])) :
|
||||
// Special handling for validation and formatting
|
||||
switch ($key) :
|
||||
case "billing_postcode" :
|
||||
case "shipping_postcode" :
|
||||
$this->posted[$key] = strtolower(str_replace(' ', '', $this->posted[$key]));
|
||||
|
||||
if (!$woocommerce->validation->is_postcode( $this->posted[$key], $_POST['billing_country'] )) : $woocommerce->add_error( $field['label'] . __(' (billing) is not a valid postcode/ZIP.', 'woocommerce') );
|
||||
else :
|
||||
$this->posted[$key] = $woocommerce->validation->format_postcode( $this->posted[$key], $_POST['billing_country'] );
|
||||
endif;
|
||||
break;
|
||||
case "billing_phone" :
|
||||
if (!$woocommerce->validation->is_phone( $this->posted[$key] )) : $woocommerce->add_error( $field['label'] . ' ' . __('is not a valid number.', 'woocommerce') ); endif;
|
||||
break;
|
||||
case "billing_email" :
|
||||
if (!$woocommerce->validation->is_email( $this->posted[$key] )) : $woocommerce->add_error( $field['label'] . ' ' . __('is not a valid email address.', 'woocommerce') ); endif;
|
||||
break;
|
||||
endswitch;
|
||||
endif;
|
||||
|
||||
endforeach;
|
||||
|
||||
endforeach;
|
||||
|
||||
endforeach;
|
||||
|
||||
// Update customer location to posted location so we can correctly check available shipping methods
|
||||
$woocommerce->customer->set_country( $this->posted['billing_country'] );
|
||||
$woocommerce->customer->set_state( $this->posted['billing_state'] );
|
||||
$woocommerce->customer->set_postcode( $this->posted['billing_postcode'] );
|
||||
|
||||
// Shipping Information
|
||||
if (!$skipped_shipping) :
|
||||
|
||||
// Update customer location to posted location so we can correctly check available shipping methods
|
||||
$woocommerce->customer->set_shipping_country( $this->posted['shipping_country'] );
|
||||
$woocommerce->customer->set_shipping_state( $this->posted['shipping_state'] );
|
||||
$woocommerce->customer->set_shipping_postcode( $this->posted['shipping_postcode'] );
|
||||
$woocommerce->customer->set_country( $this->posted['billing_country'] );
|
||||
$woocommerce->customer->set_state( $this->posted['billing_state'] );
|
||||
$woocommerce->customer->set_postcode( $this->posted['billing_postcode'] );
|
||||
|
||||
else :
|
||||
|
||||
// Update customer location to posted location so we can correctly check available shipping methods
|
||||
$woocommerce->customer->set_shipping_country( $this->posted['billing_country'] );
|
||||
$woocommerce->customer->set_shipping_state( $this->posted['billing_state'] );
|
||||
$woocommerce->customer->set_shipping_postcode( $this->posted['billing_postcode'] );
|
||||
|
||||
endif;
|
||||
|
||||
if (is_user_logged_in()) :
|
||||
$this->creating_account = false;
|
||||
elseif (isset($this->posted['createaccount']) && $this->posted['createaccount']) :
|
||||
$this->creating_account = true;
|
||||
elseif ($this->must_create_account) :
|
||||
$this->creating_account = true;
|
||||
else :
|
||||
$this->creating_account = false;
|
||||
endif;
|
||||
|
||||
if ($this->creating_account) :
|
||||
|
||||
if ( empty($this->posted['account_username']) ) $woocommerce->add_error( __('Please enter an account username.', 'woocommerce') );
|
||||
if ( empty($this->posted['account_password']) ) $woocommerce->add_error( __('Please enter an account password.', 'woocommerce') );
|
||||
if ( $this->posted['account_password-2'] !== $this->posted['account_password'] ) $woocommerce->add_error( __('Passwords do not match.', 'woocommerce') );
|
||||
|
||||
// Check the username
|
||||
if ( !validate_username( $this->posted['account_username'] ) ) :
|
||||
$woocommerce->add_error( __('Invalid email/username.', 'woocommerce') );
|
||||
elseif ( username_exists( $this->posted['account_username'] ) ) :
|
||||
$woocommerce->add_error( __('An account is already registered with that username. Please choose another.', 'woocommerce') );
|
||||
endif;
|
||||
|
||||
// Check the e-mail address
|
||||
if ( email_exists( $this->posted['billing_email'] ) ) :
|
||||
$woocommerce->add_error( __('An account is already registered with your email address. Please login.', 'woocommerce') );
|
||||
endif;
|
||||
|
||||
endif;
|
||||
|
||||
// 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') );
|
||||
|
||||
if ($woocommerce->cart->needs_shipping()) :
|
||||
|
||||
// Shipping Method
|
||||
$available_methods = $woocommerce->shipping->get_available_shipping_methods();
|
||||
|
||||
if (!isset($available_methods[$this->posted['shipping_method']])) :
|
||||
$woocommerce->add_error( __('Invalid shipping method.', 'woocommerce') );
|
||||
endif;
|
||||
|
||||
endif;
|
||||
|
||||
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') );
|
||||
// Shipping Information
|
||||
if (!$skipped_shipping) :
|
||||
|
||||
// Update customer location to posted location so we can correctly check available shipping methods
|
||||
$woocommerce->customer->set_shipping_country( $this->posted['shipping_country'] );
|
||||
$woocommerce->customer->set_shipping_state( $this->posted['shipping_state'] );
|
||||
$woocommerce->customer->set_shipping_postcode( $this->posted['shipping_postcode'] );
|
||||
|
||||
else :
|
||||
// Payment Method Field Validation
|
||||
$available_gateways[$this->posted['payment_method']]->validate_fields();
|
||||
|
||||
// Update customer location to posted location so we can correctly check available shipping methods
|
||||
$woocommerce->customer->set_shipping_country( $this->posted['billing_country'] );
|
||||
$woocommerce->customer->set_shipping_state( $this->posted['billing_state'] );
|
||||
$woocommerce->customer->set_shipping_postcode( $this->posted['billing_postcode'] );
|
||||
|
||||
endif;
|
||||
endif;
|
||||
|
||||
if (is_user_logged_in()) :
|
||||
$this->creating_account = false;
|
||||
elseif (isset($this->posted['createaccount']) && $this->posted['createaccount']) :
|
||||
$this->creating_account = true;
|
||||
elseif ($this->must_create_account) :
|
||||
$this->creating_account = true;
|
||||
else :
|
||||
$this->creating_account = false;
|
||||
endif;
|
||||
|
||||
if ($this->creating_account) :
|
||||
|
||||
if ( empty($this->posted['account_username']) ) $woocommerce->add_error( __('Please enter an account username.', 'woocommerce') );
|
||||
if ( empty($this->posted['account_password']) ) $woocommerce->add_error( __('Please enter an account password.', 'woocommerce') );
|
||||
if ( $this->posted['account_password-2'] !== $this->posted['account_password'] ) $woocommerce->add_error( __('Passwords do not match.', 'woocommerce') );
|
||||
|
||||
// Check the username
|
||||
if ( !validate_username( $this->posted['account_username'] ) ) :
|
||||
$woocommerce->add_error( __('Invalid email/username.', 'woocommerce') );
|
||||
elseif ( username_exists( $this->posted['account_username'] ) ) :
|
||||
$woocommerce->add_error( __('An account is already registered with that username. Please choose another.', 'woocommerce') );
|
||||
endif;
|
||||
|
||||
// Check the e-mail address
|
||||
if ( email_exists( $this->posted['billing_email'] ) ) :
|
||||
$woocommerce->add_error( __('An account is already registered with your email address. Please login.', 'woocommerce') );
|
||||
endif;
|
||||
|
||||
endif;
|
||||
|
||||
// Terms
|
||||
if (!isset($_POST['update_totals']) && empty($this->posted['terms']) && woocommerce_get_page_id('terms')>0 ) $woocommerce->add_error( __('You must accept our Terms & Conditions.', 'woocommerce') );
|
||||
|
||||
if ($woocommerce->cart->needs_shipping()) :
|
||||
|
||||
// Shipping Method
|
||||
$available_methods = $woocommerce->shipping->get_available_shipping_methods();
|
||||
|
||||
if (!isset($available_methods[$this->posted['shipping_method']])) :
|
||||
$woocommerce->add_error( __('Invalid shipping method.', 'woocommerce') );
|
||||
endif;
|
||||
|
||||
endif;
|
||||
|
||||
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') );
|
||||
else :
|
||||
// Payment Method Field Validation
|
||||
$available_gateways[$this->posted['payment_method']]->validate_fields();
|
||||
endif;
|
||||
endif;
|
||||
|
||||
do_action( 'woocommerce_after_checkout_validation', $this->posted );
|
||||
|
||||
if (!isset($_POST['update_totals']) && $woocommerce->error_count()==0) :
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
|
||||
while (1) :
|
||||
|
||||
// Create customer account and log them in
|
||||
if ($this->creating_account && !$user_id) :
|
||||
|
||||
$reg_errors = new WP_Error();
|
||||
|
||||
do_action('woocommerce_register_post', $this->posted['account_username'], $this->posted['billing_email'], $reg_errors);
|
||||
|
||||
$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() ) :
|
||||
|
||||
do_action( 'woocommerce_after_checkout_validation', $this->posted );
|
||||
|
||||
if (!isset($_POST['woocommerce_checkout_update_totals']) && $woocommerce->error_count()==0) :
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
|
||||
while (1) :
|
||||
|
||||
// Create customer account and log them in
|
||||
if ($this->creating_account && !$user_id) :
|
||||
|
||||
$reg_errors = new WP_Error();
|
||||
|
||||
do_action('woocommerce_register_post', $this->posted['account_username'], $this->posted['billing_email'], $reg_errors);
|
||||
|
||||
$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() ) :
|
||||
|
||||
$user_pass = $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;
|
||||
|
||||
// Change role
|
||||
wp_update_user( array ('ID' => $user_id, 'role' => 'customer') ) ;
|
||||
|
||||
// send the user a confirmation and their login details
|
||||
$mailer = $woocommerce->mailer();
|
||||
$mailer->customer_new_account( $user_id, $password );
|
||||
|
||||
// set the WP login cookie
|
||||
$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;
|
||||
|
||||
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 woocommerce_tax();
|
||||
|
||||
$order_data = array(
|
||||
'post_type' => 'shop_order',
|
||||
'post_title' => 'Order – '.date('F j, Y @ h:i A'),
|
||||
'post_status' => 'publish',
|
||||
'post_excerpt' => $this->posted['order_comments'],
|
||||
'post_author' => 1
|
||||
);
|
||||
|
||||
// Cart items
|
||||
$order_items = array();
|
||||
|
||||
foreach ($woocommerce->cart->get_cart() as $cart_item_key => $values) :
|
||||
|
||||
$_product = $values['data'];
|
||||
|
||||
// Store any item meta data - item meta class lets plugins add item meta in a standardized way
|
||||
$item_meta = new order_item_meta();
|
||||
|
||||
$item_meta->new_order_item( $values );
|
||||
|
||||
// Store variation data in meta so admin can view it
|
||||
if ($values['variation'] && is_array($values['variation'])) :
|
||||
foreach ($values['variation'] as $key => $value) :
|
||||
$item_meta->add( esc_attr(str_replace('attribute_', '', $key)), $value );
|
||||
endforeach;
|
||||
endif;
|
||||
|
||||
$order_items[] = apply_filters('new_order_item', array(
|
||||
'id' => $values['product_id'],
|
||||
'variation_id' => $values['variation_id'],
|
||||
'name' => $_product->get_title(),
|
||||
'qty' => (int) $values['quantity'],
|
||||
'item_meta' => $item_meta->meta,
|
||||
'base_tax' => number_format($values['base_tax'], 2, '.', ''), // Base tax (unit, before discounts)
|
||||
'base_cost' => number_format($values['base_cost'], 2, '.', ''), // Base price (unit, before discounts)
|
||||
'line_cost' => number_format($values['line_cost'], 2, '.', ''), // Discounted line cost
|
||||
'line_tax' => number_format($values['line_tax'], 2, '.', ''), // Tax for the line (total)
|
||||
'tax_status' => $_product->get_tax_status(), // Taxble, shipping, none
|
||||
'tax_class' => $_product->get_tax_class() // Tax class (adjusted by filters)
|
||||
), $values);
|
||||
|
||||
endforeach;
|
||||
|
||||
// Check order items for errors
|
||||
do_action('woocommerce_check_new_order_items', $order_items);
|
||||
|
||||
if ($woocommerce->error_count()>0) break;
|
||||
|
||||
// Insert or update the post data
|
||||
$create_new_order = true;
|
||||
|
||||
if (isset($_SESSION['order_awaiting_payment']) && $_SESSION['order_awaiting_payment'] > 0) :
|
||||
|
||||
$order_id = (int) $_SESSION['order_awaiting_payment'];
|
||||
|
||||
/* Check order is unpaid */
|
||||
$order = new woocommerce_order( $order_id );
|
||||
|
||||
if ( $order->status == 'pending' ) :
|
||||
$user_pass = $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;
|
||||
|
||||
// Change role
|
||||
wp_update_user( array ('ID' => $user_id, 'role' => 'customer') ) ;
|
||||
|
||||
// send the user a confirmation and their login details
|
||||
$mailer = $woocommerce->mailer();
|
||||
$mailer->customer_new_account( $user_id, $password );
|
||||
|
||||
// set the WP login cookie
|
||||
$secure_cookie = is_ssl() ? true : false;
|
||||
wp_set_auth_cookie($user_id, true, $secure_cookie);
|
||||
|
||||
// Resume the unpaid order
|
||||
$order_data['ID'] = $order_id;
|
||||
wp_update_post( $order_data );
|
||||
do_action('woocommerce_resume_order', $order_id);
|
||||
|
||||
$create_new_order = false;
|
||||
|
||||
endif;
|
||||
|
||||
endif;
|
||||
|
||||
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;
|
||||
|
||||
// Get better formatted billing method (title)
|
||||
$shipping_method = $this->posted['shipping_method'];
|
||||
if (isset($available_methods) && isset($available_methods[$this->posted['shipping_method']])) :
|
||||
$shipping_method = $available_methods[$this->posted['shipping_method']]->label;
|
||||
endif;
|
||||
|
||||
// Get better formatted shipping method (title/label)
|
||||
$payment_method = $this->posted['payment_method'];
|
||||
if (isset($available_gateways) && isset($available_gateways[$this->posted['payment_method']])) :
|
||||
$payment_method = $available_gateways[$this->posted['payment_method']]->title;
|
||||
endif;
|
||||
|
||||
// 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) :
|
||||
|
||||
// Post
|
||||
update_post_meta( $order_id, '_' . $key, $this->posted[$key] );
|
||||
|
||||
// User
|
||||
if ($user_id>0) :
|
||||
update_user_meta( $user_id, $key, $this->posted[$key] );
|
||||
else :
|
||||
$woocommerce->add_error( $reg_errors->get_error_message() );
|
||||
break;
|
||||
endif;
|
||||
|
||||
endforeach;
|
||||
endif;
|
||||
if ($this->checkout_fields['shipping'] && $woocommerce->cart->needs_shipping()) :
|
||||
foreach ($this->checkout_fields['shipping'] as $key => $field) :
|
||||
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 woocommerce_tax();
|
||||
|
||||
$order_data = array(
|
||||
'post_type' => 'shop_order',
|
||||
'post_title' => 'Order – '.date('F j, Y @ h:i A'),
|
||||
'post_status' => 'publish',
|
||||
'post_excerpt' => $this->posted['order_comments'],
|
||||
'post_author' => 1
|
||||
);
|
||||
|
||||
// Cart items
|
||||
$order_items = array();
|
||||
|
||||
foreach ($woocommerce->cart->get_cart() as $cart_item_key => $values) :
|
||||
|
||||
if ($this->posted['shiptobilling']) :
|
||||
$_product = $values['data'];
|
||||
|
||||
// Store any item meta data - item meta class lets plugins add item meta in a standardized way
|
||||
$item_meta = new order_item_meta();
|
||||
|
||||
$item_meta->new_order_item( $values );
|
||||
|
||||
// Store variation data in meta so admin can view it
|
||||
if ($values['variation'] && is_array($values['variation'])) :
|
||||
foreach ($values['variation'] as $key => $value) :
|
||||
$item_meta->add( esc_attr(str_replace('attribute_', '', $key)), $value );
|
||||
endforeach;
|
||||
endif;
|
||||
|
||||
$order_items[] = apply_filters('new_order_item', array(
|
||||
'id' => $values['product_id'],
|
||||
'variation_id' => $values['variation_id'],
|
||||
'name' => $_product->get_title(),
|
||||
'qty' => (int) $values['quantity'],
|
||||
'item_meta' => $item_meta->meta,
|
||||
'base_tax' => number_format($values['base_tax'], 2, '.', ''), // Base tax (unit, before discounts)
|
||||
'base_cost' => number_format($values['base_cost'], 2, '.', ''), // Base price (unit, before discounts)
|
||||
'line_cost' => number_format($values['line_cost'], 2, '.', ''), // Discounted line cost
|
||||
'line_tax' => number_format($values['line_tax'], 2, '.', ''), // Tax for the line (total)
|
||||
'tax_status' => $_product->get_tax_status(), // Taxble, shipping, none
|
||||
'tax_class' => $_product->get_tax_class() // Tax class (adjusted by filters)
|
||||
), $values);
|
||||
|
||||
// Check cart items for errors
|
||||
do_action('woocommerce_check_cart_items', $order_items);
|
||||
|
||||
endforeach;
|
||||
|
||||
if ($woocommerce->error_count()>0) break;
|
||||
|
||||
// Insert or update the post data
|
||||
$create_new_order = true;
|
||||
|
||||
if (isset($_SESSION['order_awaiting_payment']) && $_SESSION['order_awaiting_payment'] > 0) :
|
||||
|
||||
$order_id = (int) $_SESSION['order_awaiting_payment'];
|
||||
|
||||
/* Check order is unpaid */
|
||||
$order = new woocommerce_order( $order_id );
|
||||
|
||||
if ( $order->status == 'pending' ) :
|
||||
|
||||
$field_key = str_replace('shipping_', 'billing_', $key);
|
||||
// Resume the unpaid order
|
||||
$order_data['ID'] = $order_id;
|
||||
wp_update_post( $order_data );
|
||||
do_action('woocommerce_resume_order', $order_id);
|
||||
|
||||
// Post
|
||||
update_post_meta( $order_id, '_' . $key, $this->posted[$field_key] );
|
||||
|
||||
// User
|
||||
if ($user_id>0) :
|
||||
update_user_meta( $user_id, $key, $this->posted[$field_key] );
|
||||
endif;
|
||||
$create_new_order = false;
|
||||
|
||||
endif;
|
||||
|
||||
endif;
|
||||
|
||||
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;
|
||||
|
||||
// Get better formatted billing method (title)
|
||||
$shipping_method = $this->posted['shipping_method'];
|
||||
if (isset($available_methods) && isset($available_methods[$this->posted['shipping_method']])) :
|
||||
$shipping_method = $available_methods[$this->posted['shipping_method']]->label;
|
||||
endif;
|
||||
|
||||
// Get better formatted shipping method (title/label)
|
||||
$payment_method = $this->posted['payment_method'];
|
||||
if (isset($available_gateways) && isset($available_gateways[$this->posted['payment_method']])) :
|
||||
$payment_method = $available_gateways[$this->posted['payment_method']]->title;
|
||||
endif;
|
||||
|
||||
// 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) :
|
||||
|
||||
// Post
|
||||
update_post_meta( $order_id, '_' . $key, $this->posted[$key] );
|
||||
|
||||
|
@ -503,109 +480,141 @@ class woocommerce_checkout {
|
|||
if ($user_id>0) :
|
||||
update_user_meta( $user_id, $key, $this->posted[$key] );
|
||||
endif;
|
||||
endif;
|
||||
|
||||
endforeach;
|
||||
endif;
|
||||
if ($this->checkout_fields['shipping'] && $woocommerce->cart->needs_shipping()) :
|
||||
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] );
|
||||
|
||||
// User
|
||||
if ($user_id>0) :
|
||||
update_user_meta( $user_id, $key, $this->posted[$field_key] );
|
||||
endif;
|
||||
else :
|
||||
// Post
|
||||
update_post_meta( $order_id, '_' . $key, $this->posted[$key] );
|
||||
|
||||
// User
|
||||
if ($user_id>0) :
|
||||
update_user_meta( $user_id, $key, $this->posted[$key] );
|
||||
endif;
|
||||
endif;
|
||||
|
||||
endforeach;
|
||||
endif;
|
||||
|
||||
// Put order taxes into an array to store
|
||||
$order_taxes = array();
|
||||
|
||||
if (is_array($woocommerce->cart->taxes) && sizeof($woocommerce->cart->taxes)>0) foreach ( $woocommerce->cart->taxes as $key => $tax ) :
|
||||
|
||||
$is_compound = ($woocommerce->cart->tax->is_compound( $key )) ? 1 : 0;
|
||||
|
||||
$order_taxes[] = array(
|
||||
'label' => $woocommerce->cart->tax->get_rate_label( $key ),
|
||||
'compound' => $is_compound,
|
||||
'total' => number_format($tax, 2, '.', '')
|
||||
);
|
||||
|
||||
endforeach;
|
||||
endif;
|
||||
|
||||
// Put order taxes into an array to store
|
||||
$order_taxes = array();
|
||||
|
||||
if (is_array($woocommerce->cart->taxes) && sizeof($woocommerce->cart->taxes)>0) foreach ( $woocommerce->cart->taxes as $key => $tax ) :
|
||||
|
||||
$is_compound = ($woocommerce->cart->tax->is_compound( $key )) ? 1 : 0;
|
||||
// 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_title', $shipping_method);
|
||||
update_post_meta( $order_id, '_payment_method_title', $payment_method);
|
||||
update_post_meta( $order_id, '_order_shipping', number_format($woocommerce->cart->shipping_total, 2, '.', ''));
|
||||
update_post_meta( $order_id, '_order_discount', number_format($woocommerce->cart->get_order_discount_total(), 2, '.', ''));
|
||||
update_post_meta( $order_id, '_cart_discount', number_format($woocommerce->cart->get_cart_discount_total(), 2, '.', ''));
|
||||
update_post_meta( $order_id, '_order_tax', number_format($woocommerce->cart->tax_total, 2, '.', ''));
|
||||
update_post_meta( $order_id, '_order_shipping_tax', number_format($woocommerce->cart->shipping_tax_total, 2, '.', ''));
|
||||
update_post_meta( $order_id, '_order_total', number_format($woocommerce->cart->total, 2, '.', ''));
|
||||
update_post_meta( $order_id, '_order_key', apply_filters('woocommerce_generate_order_key', uniqid('order_') ));
|
||||
update_post_meta( $order_id, '_customer_user', (int) $user_id );
|
||||
update_post_meta( $order_id, '_order_items', $order_items );
|
||||
update_post_meta( $order_id, '_order_taxes', $order_taxes );
|
||||
|
||||
$order_taxes[] = array(
|
||||
'label' => $woocommerce->cart->tax->get_rate_label( $key ),
|
||||
'compound' => $is_compound,
|
||||
'total' => number_format($tax, 2, '.', '')
|
||||
);
|
||||
do_action('woocommerce_checkout_update_order_meta', $order_id, $this->posted);
|
||||
|
||||
endforeach;
|
||||
|
||||
// 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_title', $shipping_method);
|
||||
update_post_meta( $order_id, '_payment_method_title', $payment_method);
|
||||
update_post_meta( $order_id, '_order_shipping', number_format($woocommerce->cart->shipping_total, 2, '.', ''));
|
||||
update_post_meta( $order_id, '_order_discount', number_format($woocommerce->cart->get_order_discount_total(), 2, '.', ''));
|
||||
update_post_meta( $order_id, '_cart_discount', number_format($woocommerce->cart->get_cart_discount_total(), 2, '.', ''));
|
||||
update_post_meta( $order_id, '_order_tax', number_format($woocommerce->cart->tax_total, 2, '.', ''));
|
||||
update_post_meta( $order_id, '_order_shipping_tax', number_format($woocommerce->cart->shipping_tax_total, 2, '.', ''));
|
||||
update_post_meta( $order_id, '_order_total', number_format($woocommerce->cart->total, 2, '.', ''));
|
||||
update_post_meta( $order_id, '_order_key', apply_filters('woocommerce_generate_order_key', uniqid('order_') ));
|
||||
update_post_meta( $order_id, '_customer_user', (int) $user_id );
|
||||
update_post_meta( $order_id, '_order_items', $order_items );
|
||||
update_post_meta( $order_id, '_order_taxes', $order_taxes );
|
||||
|
||||
do_action('woocommerce_checkout_update_order_meta', $order_id, $this->posted);
|
||||
|
||||
// Order status
|
||||
wp_set_object_terms( $order_id, 'pending', 'shop_order_status' );
|
||||
// Order status
|
||||
wp_set_object_terms( $order_id, 'pending', 'shop_order_status' );
|
||||
|
||||
// Discount code meta
|
||||
if ($applied_coupons = $woocommerce->cart->get_applied_coupons()) update_post_meta($order_id, 'coupons', implode(', ', $applied_coupons));
|
||||
|
||||
// Discount code meta
|
||||
if ($applied_coupons = $woocommerce->cart->get_applied_coupons()) update_post_meta($order_id, 'coupons', implode(', ', $applied_coupons));
|
||||
|
||||
// Order is saved
|
||||
do_action('woocommerce_checkout_order_processed', $order_id, $this->posted);
|
||||
|
||||
// Process payment
|
||||
if ($woocommerce->cart->needs_payment()) :
|
||||
// Order is saved
|
||||
do_action('woocommerce_checkout_order_processed', $order_id, $this->posted);
|
||||
|
||||
// Store Order ID in session so it can be re-used after payment failure
|
||||
$_SESSION['order_awaiting_payment'] = $order_id;
|
||||
// Process 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;
|
||||
|
||||
// Process Payment
|
||||
$result = $available_gateways[$this->posted['payment_method']]->process_payment( $order_id );
|
||||
// Process Payment
|
||||
$result = $available_gateways[$this->posted['payment_method']]->process_payment( $order_id );
|
||||
|
||||
// Redirect to success/confirmation/payment page
|
||||
if ($result['result']=='success') :
|
||||
|
||||
$result = apply_filters('woocommerce_payment_successful_result', $result );
|
||||
|
||||
if (is_ajax()) :
|
||||
ob_clean();
|
||||
echo json_encode( $result );
|
||||
exit;
|
||||
else :
|
||||
wp_safe_redirect( $result['redirect'] );
|
||||
exit;
|
||||
endif;
|
||||
|
||||
endif;
|
||||
|
||||
// Redirect to success/confirmation/payment page
|
||||
if ($result['result']=='success') :
|
||||
else :
|
||||
|
||||
$result = apply_filters('woocommerce_payment_successful_result', $result );
|
||||
$order = new woocommerce_order($order_id);
|
||||
|
||||
// No payment was required for order
|
||||
$order->payment_complete();
|
||||
|
||||
// Empty the Cart
|
||||
$woocommerce->cart->empty_cart();
|
||||
|
||||
// Redirect to success/confirmation/payment page
|
||||
if (is_ajax()) :
|
||||
echo json_encode( $result );
|
||||
ob_clean();
|
||||
echo json_encode( array('redirect' => apply_filters( 'woocommerce_checkout_no_payment_needed_redirect', get_permalink(woocommerce_get_page_id('thanks')))) );
|
||||
exit;
|
||||
else :
|
||||
wp_safe_redirect( $result['redirect'] );
|
||||
wp_safe_redirect( apply_filters( 'woocommerce_checkout_no_payment_needed_redirect', get_permalink(woocommerce_get_page_id('thanks'))) );
|
||||
exit;
|
||||
endif;
|
||||
|
||||
endif;
|
||||
|
||||
// Break out of loop
|
||||
break;
|
||||
|
||||
else :
|
||||
|
||||
$order = new woocommerce_order($order_id);
|
||||
|
||||
// No payment was required for order
|
||||
$order->payment_complete();
|
||||
|
||||
// Empty the Cart
|
||||
$woocommerce->cart->empty_cart();
|
||||
|
||||
// Redirect to success/confirmation/payment page
|
||||
if (is_ajax()) :
|
||||
echo json_encode( array('redirect' => apply_filters( 'woocommerce_checkout_no_payment_needed_redirect', get_permalink(woocommerce_get_page_id('thanks')))) );
|
||||
exit;
|
||||
else :
|
||||
wp_safe_redirect( apply_filters( 'woocommerce_checkout_no_payment_needed_redirect', get_permalink(woocommerce_get_page_id('thanks'))) );
|
||||
exit;
|
||||
endif;
|
||||
|
||||
endif;
|
||||
|
||||
// Break out of loop
|
||||
break;
|
||||
endwhile;
|
||||
|
||||
endif;
|
||||
|
||||
endwhile;
|
||||
|
||||
endif;
|
||||
// If we reached this point then there were errors
|
||||
if (is_ajax()) :
|
||||
ob_clean();
|
||||
$woocommerce->show_messages();
|
||||
exit;
|
||||
else :
|
||||
$woocommerce->show_messages();
|
||||
endif;
|
||||
|
||||
// If we reached this point then there were errors
|
||||
if (is_ajax()) :
|
||||
$woocommerce->show_messages();
|
||||
exit;
|
||||
endif;
|
||||
}
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ class woocommerce_bacs extends woocommerce_payment_gateway {
|
|||
// Return thankyou redirect
|
||||
return array(
|
||||
'result' => 'success',
|
||||
'redirect' => add_query_arg('key', $order->order_key, add_query_arg('order', $order->id, get_permalink(woocommerce_get_page_id('thanks'))))
|
||||
'redirect' => add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink(woocommerce_get_page_id('thanks'))))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ class woocommerce_cheque extends woocommerce_payment_gateway {
|
|||
* Process the payment and return the result
|
||||
**/
|
||||
function process_payment( $order_id ) {
|
||||
global $woocommerce;
|
||||
global $woocommerce;
|
||||
|
||||
$order = new woocommerce_order( $order_id );
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class woocommerce_order {
|
|||
}
|
||||
|
||||
/** Get the order if ID is passed, otherwise the order is new and empty */
|
||||
function __construct ( $id='' ) {
|
||||
function woocommerce_order( $id='' ) {
|
||||
$this->calc_taxes = (get_option('woocommerce_calc_taxes')=='yes') ? true : false;
|
||||
$this->prices_include_tax = (get_option('woocommerce_prices_include_tax')=='yes') ? true : false;
|
||||
$this->display_totals_ex_tax = (get_option('woocommerce_display_totals_excluding_tax')=='yes') ? true : false;
|
||||
|
@ -682,7 +682,7 @@ class woocommerce_order {
|
|||
$this->add_order_note( sprintf( __('Item #%s stock reduced from %s to %s.', 'woocommerce'), $item['id'], $old_stock, $new_quantity) );
|
||||
|
||||
if ($new_quantity<0) :
|
||||
do_action('woocommerce_product_on_backorder', array( 'product' => $item['id'], 'order_id' => $this->id, 'quantity' => $item['qty']));
|
||||
do_action('woocommerce_product_on_backorder', array( 'product' => $item['id'], 'order_id' => $this->id, 'quantity' => $item['quantity']));
|
||||
endif;
|
||||
|
||||
// stock status notifications
|
||||
|
|
|
@ -440,7 +440,7 @@ class woocommerce_product {
|
|||
}
|
||||
|
||||
/** Returns whether or not the product is visible */
|
||||
function is_visible() {
|
||||
function is_visible( $single = false ) {
|
||||
|
||||
$visible = true;
|
||||
|
||||
|
@ -450,6 +450,7 @@ class woocommerce_product {
|
|||
// visibility setting
|
||||
elseif ($this->visibility=='hidden') $visible = false;
|
||||
elseif ($this->visibility=='visible') $visible = true;
|
||||
elseif ($single) $visible = true;
|
||||
|
||||
// Visibility in loop
|
||||
elseif ($this->visibility=='search' && is_search()) $visible = true;
|
||||
|
|
|
@ -91,8 +91,9 @@ class woocommerce_email {
|
|||
return $message;
|
||||
}
|
||||
|
||||
function send( $to, $subject, $message, $headers = "", $attachments = "" ) {
|
||||
|
||||
function send( $to, $subject, $message, $headers = '', $attachments = "" ) {
|
||||
if (!$headers) $headers = "Content-Type: text/html\r\n";
|
||||
|
||||
add_filter( 'wp_mail_from', array(&$this, 'get_from_address') );
|
||||
add_filter( 'wp_mail_from_name', array(&$this, 'get_from_name') );
|
||||
add_filter( 'wp_mail_content_type', array(&$this, 'get_content_type') );
|
||||
|
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
|||
=== WooCommerce ===
|
||||
Contributors: woothemes, mikejolley, jameskoster
|
||||
Contributors: woothemes, mikejolley
|
||||
Tags: ecommerce, e-commerce, commerce, woothemes, wordpress ecommerce, store, shop, shopping, cart, checkout, widgets, reports, shipping, tax, paypal, inventory
|
||||
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=paypal@woothemes.com&item_name=Donation+for+WooCommerce
|
||||
Requires at least: 3.3
|
||||
|
@ -120,9 +120,7 @@ Yes you can! Join in on our GitHub repository :) https://github.com/woothemes/wo
|
|||
* Change textdomain from woothemes to woocommerce
|
||||
* Free shipping coupons ignore min-amount
|
||||
* Delete all variations option
|
||||
* Removed the need of ob_start on most frontend pages to improve page loading speed
|
||||
* Product category widget option to show current children only
|
||||
* Tweaked visibility settings and made them more clear
|
||||
|
||||
= 1.3.2.1 - 15/12/2011 =
|
||||
* Category/Ordering fix
|
||||
|
|
|
@ -15,15 +15,25 @@ function get_woocommerce_checkout( $atts ) {
|
|||
}
|
||||
|
||||
function woocommerce_checkout( $atts ) {
|
||||
global $woocommerce;
|
||||
global $woocommerce, $woocommerce_checkout;
|
||||
|
||||
if (sizeof($woocommerce->cart->get_cart())==0) return;
|
||||
if (!defined('WOOCOMMERCE_CHECKOUT')) define('WOOCOMMERCE_CHECKOUT', true);
|
||||
|
||||
$non_js_checkout = (isset($_POST['woocommerce_checkout_update_totals']) && $_POST['woocommerce_checkout_update_totals']) ? true : false;
|
||||
if (sizeof($woocommerce->cart->get_cart())==0) :
|
||||
wp_redirect(get_permalink(woocommerce_get_page_id('cart')));
|
||||
exit;
|
||||
endif;
|
||||
|
||||
$non_js_checkout = (isset($_POST['update_totals']) && $_POST['update_totals']) ? true : false;
|
||||
|
||||
$woocommerce_checkout = $woocommerce->checkout();
|
||||
|
||||
$woocommerce_checkout->process_checkout();
|
||||
|
||||
do_action('woocommerce_check_cart_items');
|
||||
|
||||
if ( $woocommerce->error_count()==0 && $non_js_checkout) $woocommerce->add_message( __('The order totals have been updated. Please confirm your order by pressing the Place Order button at the bottom of the page.', 'woocommerce') );
|
||||
|
||||
woocommerce_get_template('checkout/form.php', false);
|
||||
|
||||
}
|
|
@ -72,7 +72,10 @@ function woocommerce_my_account( $atts ) {
|
|||
function woocommerce_edit_address() {
|
||||
global $woocommerce, $load_address, $address;
|
||||
|
||||
if ( ! is_user_logged_in() ) return;
|
||||
if ( ! is_user_logged_in() ) :
|
||||
wp_safe_redirect( get_permalink( woocommerce_get_page_id('myaccount') ) );
|
||||
exit;
|
||||
endif;
|
||||
|
||||
$load_address = woocommerce_get_address_to_edit();
|
||||
|
||||
|
@ -85,6 +88,9 @@ function woocommerce_edit_address() {
|
|||
* Save and and update a billing or shipping address if the
|
||||
* form was submitted through the user account page.
|
||||
*
|
||||
* @todo Address fields should be loaded using the array defined in
|
||||
* the checkout class.
|
||||
*
|
||||
* @package WooCommerce
|
||||
* @since 1.4
|
||||
*/
|
||||
|
@ -181,7 +187,10 @@ function woocommerce_get_address_to_edit() {
|
|||
function woocommerce_change_password() {
|
||||
global $woocommerce;
|
||||
|
||||
if ( ! is_user_logged_in() ) return;
|
||||
if ( ! is_user_logged_in() ) :
|
||||
wp_safe_redirect( get_permalink( woocommerce_get_page_id('myaccount') ) );
|
||||
exit;
|
||||
endif;
|
||||
|
||||
woocommerce_get_template( 'myaccount/change-password.php' );
|
||||
}
|
||||
|
@ -237,15 +246,18 @@ add_action( 'template_redirect', 'woocommerce_save_password' );
|
|||
function woocommerce_view_order() {
|
||||
global $woocommerce;
|
||||
|
||||
if ( ! is_user_logged_in() ) return;
|
||||
if ( ! is_user_logged_in() ) :
|
||||
wp_safe_redirect( get_permalink( woocommerce_get_page_id('myaccount') ) );
|
||||
exit;
|
||||
endif;
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
$order_id = (isset($_GET['order'])) ? $_GET['order'] : 0;
|
||||
$order = new woocommerce_order( $order_id );
|
||||
|
||||
|
||||
if ( $order_id==0 || $order->user_id != $user_id ) :
|
||||
echo '<div class="woocommerce_error">' . __('Invalid order.', 'woocommerce') . ' <a href="'.get_permalink( woocommerce_get_page_id('myaccount') ).'">'. __('My Account →', 'woocommerce') .'</a>' . '</div>';
|
||||
return;
|
||||
wp_safe_redirect( get_permalink( woocommerce_get_page_id('myaccount') ) );
|
||||
exit;
|
||||
endif;
|
||||
|
||||
$status = get_term_by('slug', $order->status, 'shop_order_status');
|
||||
|
|
|
@ -34,6 +34,40 @@ function woocommerce_pay() {
|
|||
if ($order->billing_state) $woocommerce->customer->set_state( $order->billing_state );
|
||||
if ($order->billing_postcode) $woocommerce->customer->set_postcode( $order->billing_postcode );
|
||||
|
||||
// Pay form was posted - process payment
|
||||
if (isset($_POST['pay']) && $woocommerce->verify_nonce('pay')) :
|
||||
|
||||
// Update payment method
|
||||
if ($order->order_total > 0 ) :
|
||||
$payment_method = woocommerce_clean($_POST['payment_method']);
|
||||
|
||||
$available_gateways = $woocommerce->payment_gateways->get_available_payment_gateways();
|
||||
|
||||
// Update meta
|
||||
update_post_meta( $order_id, '_payment_method', $payment_method);
|
||||
if (isset($available_gateways) && isset($available_gateways[$payment_method])) :
|
||||
$payment_method_title = $available_gateways[$payment_method]->title;
|
||||
endif;
|
||||
update_post_meta( $order_id, '_payment_method_title', $payment_method_title);
|
||||
|
||||
$result = $available_gateways[$payment_method]->process_payment( $order_id );
|
||||
|
||||
// Redirect to success/confirmation/payment page
|
||||
if ($result['result']=='success') :
|
||||
wp_redirect( $result['redirect'] );
|
||||
exit;
|
||||
endif;
|
||||
else :
|
||||
|
||||
// No payment was required for order
|
||||
$order->payment_complete();
|
||||
wp_safe_redirect( get_permalink(woocommerce_get_page_id('thanks')) );
|
||||
exit;
|
||||
|
||||
endif;
|
||||
|
||||
endif;
|
||||
|
||||
// Show form
|
||||
woocommerce_get_template('checkout/pay_for_order.php');
|
||||
|
||||
|
@ -90,16 +124,16 @@ function woocommerce_pay() {
|
|||
|
||||
else :
|
||||
|
||||
$woocommerce->add_error( __('Your order has already been paid for. Please contact us if you need assistance.', 'woocommerce') );
|
||||
$woocommerce->show_messages();
|
||||
wp_safe_redirect( get_permalink(woocommerce_get_page_id('myaccount')) );
|
||||
exit;
|
||||
|
||||
endif;
|
||||
|
||||
else :
|
||||
|
||||
$woocommerce->add_error( __('Invalid order.', 'woocommerce') );
|
||||
$woocommerce->show_messages();
|
||||
|
||||
wp_safe_redirect( get_permalink(woocommerce_get_page_id('myaccount')) );
|
||||
exit;
|
||||
|
||||
endif;
|
||||
|
||||
endif;
|
||||
|
|
|
@ -20,8 +20,6 @@ function get_woocommerce_thankyou( $atts ) {
|
|||
function woocommerce_thankyou( $atts ) {
|
||||
global $woocommerce, $order;
|
||||
|
||||
$order = false;
|
||||
|
||||
// Pay for order after checkout step
|
||||
if (isset($_GET['order'])) $order_id = $_GET['order']; else $order_id = 0;
|
||||
if (isset($_GET['key'])) $order_key = $_GET['key']; else $order_key = '';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php global $woocommerce; $woocommerce_checkout = $woocommerce->checkout(); ?>
|
||||
<?php global $woocommerce, $woocommerce_checkout; ?>
|
||||
|
||||
<?php $woocommerce->show_messages(); ?>
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
|
||||
<div class="form-row">
|
||||
<?php $woocommerce->nonce_field('pay')?>
|
||||
<input type="submit" class="button alt" name="woocommerce_pay" id="place_order" value="<?php _e('Pay for order', 'woocommerce'); ?>" />
|
||||
<input type="submit" class="button-alt" name="pay" id="place_order" value="<?php _e('Pay for order', 'woocommerce'); ?>" />
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
@ -226,13 +226,13 @@
|
|||
|
||||
<div class="form-row">
|
||||
|
||||
<noscript><?php _e('Since your browser does not support JavaScript, or it is disabled, please ensure you click the <em>Update Totals</em> button before placing your order. You may be charged more than the amount stated above if you fail to do so.', 'woocommerce'); ?><br/><input type="submit" class="button-alt" name="woocommerce_checkout_update_totals" value="<?php _e('Update totals', 'woocommerce'); ?>" /></noscript>
|
||||
<noscript><?php _e('Since your browser does not support JavaScript, or it is disabled, please ensure you click the <em>Update Totals</em> button before placing your order. You may be charged more than the amount stated above if you fail to do so.', 'woocommerce'); ?><br/><input type="submit" class="button-alt" name="update_totals" value="<?php _e('Update totals', 'woocommerce'); ?>" /></noscript>
|
||||
|
||||
<?php $woocommerce->nonce_field('process_checkout')?>
|
||||
|
||||
<?php do_action( 'woocommerce_review_order_before_submit' ); ?>
|
||||
|
||||
<input type="submit" class="button alt" name="woocommerce_checkout_place_order" id="place_order" value="<?php echo apply_filters('woocommerce_order_button_text', __('Place order', 'woocommerce')); ?>" />
|
||||
<input type="submit" class="button alt" name="place_order" id="place_order" value="<?php echo apply_filters('woocommerce_order_button_text', __('Place order', 'woocommerce')); ?>" />
|
||||
|
||||
<?php if (woocommerce_get_page_id('terms')>0) : ?>
|
||||
<p class="form-row terms">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php if (!defined('ABSPATH')) exit; ?>
|
||||
|
||||
<?php global $order; ?>
|
||||
<?php global $order, $woocommerce; ?>
|
||||
|
||||
<?php do_action('woocommerce_email_header'); ?>
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ function woocommerce_ajax_update_order_review() {
|
|||
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>';
|
||||
echo '<p class="error">'.__('Sorry, your session has expired.', 'woocommerce').' <a href="'.home_url().'">'.__('Return to homepage →', 'woocommerce').'</a></p>';
|
||||
die();
|
||||
endif;
|
||||
|
||||
|
@ -161,8 +161,8 @@ function woocommerce_ajax_add_to_cart() {
|
|||
add_action('wp_ajax_woocommerce-checkout', 'woocommerce_process_checkout');
|
||||
add_action('wp_ajax_nopriv_woocommerce-checkout', 'woocommerce_process_checkout');
|
||||
|
||||
function woocommerce_process_checkout() {
|
||||
global $woocommerce;
|
||||
function woocommerce_process_checkout () {
|
||||
global $woocommerce, $woocommerce_checkout;
|
||||
|
||||
$woocommerce_checkout = $woocommerce->checkout();
|
||||
$woocommerce_checkout->process_checkout();
|
||||
|
|
|
@ -27,7 +27,7 @@ function woocommerce_mail( $to, $subject, $message, $headers = "Content-Type: te
|
|||
**/
|
||||
if (!function_exists('woocommerce_get_page_id')) {
|
||||
function woocommerce_get_page_id( $page ) {
|
||||
return apply_filters('woocommerce_get_' . $page . '_page_id', get_option('woocommerce_' . $page . '_page_id'));
|
||||
return (int) apply_filters('woocommerce_get_' . $page . '_page_id', get_option('woocommerce_' . $page . '_page_id'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,7 @@ if (!function_exists('is_checkout')) {
|
|||
if (!function_exists('is_account_page')) {
|
||||
function is_account_page() {
|
||||
if ( is_page(woocommerce_get_page_id('myaccount')) || is_page(woocommerce_get_page_id('edit_address')) || is_page(woocommerce_get_page_id('view_order')) || is_page(woocommerce_get_page_id('change_password')) ) return true; else return false;
|
||||
return is_page(woocommerce_get_page_id('myaccount'));
|
||||
}
|
||||
}
|
||||
if (!function_exists('is_ajax')) {
|
||||
|
|
|
@ -10,35 +10,13 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Handle redirects before content is output - hooked into template_redirect so is_page works
|
||||
* When default permalinks are enabled, redirect shop page to post type archive url
|
||||
**/
|
||||
function woocommerce_redirects() {
|
||||
global $woocommerce;
|
||||
|
||||
// When default permalinks are enabled, redirect shop page to post type archive url
|
||||
function woocommerce_shop_page_archive_redirect() {
|
||||
if ( isset($_GET['page_id']) && get_option( 'permalink_structure' )=="" && $_GET['page_id'] == woocommerce_get_page_id('shop') ) :
|
||||
wp_safe_redirect( get_post_type_archive_link('product') );
|
||||
exit;
|
||||
endif;
|
||||
|
||||
// When on the checkout with an empty cart, redirect to cart page
|
||||
if (is_page(woocommerce_get_page_id('checkout')) && sizeof($woocommerce->cart->get_cart())==0) :
|
||||
wp_redirect(get_permalink(woocommerce_get_page_id('cart')));
|
||||
exit;
|
||||
endif;
|
||||
|
||||
// When on pay page with no query string, redirect to checkout
|
||||
if (is_page(woocommerce_get_page_id('pay')) && !isset($_GET['order'])) :
|
||||
wp_redirect(get_permalink(woocommerce_get_page_id('checkout')));
|
||||
exit;
|
||||
endif;
|
||||
|
||||
// My account page redirects (logged out)
|
||||
if (!is_user_logged_in() && ( is_page(woocommerce_get_page_id('edit_address')) || is_page(woocommerce_get_page_id('view_order')) || is_page(woocommerce_get_page_id('change_password')) )) :
|
||||
wp_redirect(get_permalink(woocommerce_get_page_id('myaccount')));
|
||||
exit;
|
||||
endif;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -360,7 +338,7 @@ function woocommerce_add_to_cart_message() {
|
|||
$woocommerce->add_message( sprintf('<a href="%s" class="button">%s</a> %s', $return_to, __('Continue Shopping →', 'woocommerce'), __('Product successfully added to your cart.', 'woocommerce') ));
|
||||
|
||||
else :
|
||||
$woocommerce->add_message( sprintf('<a href="%s" class="button">%s</a> %s', get_permalink(woocommerce_get_page_id('cart')), __('View Cart →', 'woocommerce'), __('Product successfully added to your cart.', 'woocommerce') ));
|
||||
$woocommerce->add_message( sprintf('<a href="%s" class="button">%s</a> %s', $return_to, __('View Cart →', 'woocommerce'), __('Product successfully added to your cart.', 'woocommerce') ));
|
||||
endif;
|
||||
}
|
||||
|
||||
|
@ -402,81 +380,6 @@ function woocommerce_clear_cart_after_payment() {
|
|||
endif;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Process the checkout form
|
||||
**/
|
||||
function woocommerce_checkout_action() {
|
||||
global $woocommerce;
|
||||
|
||||
if (isset($_POST['woocommerce_checkout_place_order']) || isset($_POST['woocommerce_checkout_update_totals'])) :
|
||||
|
||||
if (sizeof($woocommerce->cart->get_cart())==0) :
|
||||
wp_redirect(get_permalink(woocommerce_get_page_id('cart')));
|
||||
exit;
|
||||
endif;
|
||||
|
||||
$woocommerce_checkout = $woocommerce->checkout();
|
||||
$woocommerce_checkout->process_checkout();
|
||||
|
||||
endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the pay form
|
||||
**/
|
||||
function woocommerce_pay_action() {
|
||||
global $woocommerce;
|
||||
|
||||
if (isset($_POST['woocommerce_pay']) && $woocommerce->verify_nonce('pay')) :
|
||||
|
||||
// Pay for existing order
|
||||
$order_key = urldecode( $_GET['order'] );
|
||||
$order_id = (int) $_GET['order_id'];
|
||||
$order = new woocommerce_order( $order_id );
|
||||
|
||||
if ($order->id == $order_id && $order->order_key == $order_key && in_array($order->status, array('pending', 'failed'))) :
|
||||
|
||||
// Set customer location to order location
|
||||
if ($order->billing_country) $woocommerce->customer->set_country( $order->billing_country );
|
||||
if ($order->billing_state) $woocommerce->customer->set_state( $order->billing_state );
|
||||
if ($order->billing_postcode) $woocommerce->customer->set_postcode( $order->billing_postcode );
|
||||
|
||||
// Update payment method
|
||||
if ($order->order_total > 0 ) :
|
||||
$payment_method = woocommerce_clean($_POST['payment_method']);
|
||||
|
||||
$available_gateways = $woocommerce->payment_gateways->get_available_payment_gateways();
|
||||
|
||||
// Update meta
|
||||
update_post_meta( $order_id, '_payment_method', $payment_method);
|
||||
if (isset($available_gateways) && isset($available_gateways[$payment_method])) :
|
||||
$payment_method_title = $available_gateways[$payment_method]->title;
|
||||
endif;
|
||||
update_post_meta( $order_id, '_payment_method_title', $payment_method_title);
|
||||
|
||||
$result = $available_gateways[$payment_method]->process_payment( $order_id );
|
||||
|
||||
// Redirect to success/confirmation/payment page
|
||||
if ($result['result']=='success') :
|
||||
wp_redirect( $result['redirect'] );
|
||||
exit;
|
||||
endif;
|
||||
else :
|
||||
|
||||
// No payment was required for order
|
||||
$order->payment_complete();
|
||||
wp_safe_redirect( get_permalink(woocommerce_get_page_id('thanks')) );
|
||||
exit;
|
||||
|
||||
endif;
|
||||
|
||||
endif;
|
||||
|
||||
endif;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Process the login form
|
||||
**/
|
||||
|
|
|
@ -39,6 +39,7 @@ add_action( 'woocommerce_before_subcategory_title', 'woocommerce_subcategory_thu
|
|||
|
||||
/* Before Single Products */
|
||||
add_action( 'woocommerce_before_single_product', array(&$woocommerce, 'show_messages'), 10 );
|
||||
add_action( 'woocommerce_before_single_product', 'woocommerce_check_product_visibility', 10);
|
||||
|
||||
/* Before Single Products Summary Div */
|
||||
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20);
|
||||
|
@ -96,7 +97,7 @@ add_action( 'woocommerce_thankyou', 'woocommerce_order_details_table', 10 );
|
|||
/** Store Event Hooks *****************************************************/
|
||||
|
||||
/* Shop Page Handling and Support */
|
||||
add_action( 'template_redirect', 'woocommerce_redirects' );
|
||||
add_action( 'init', 'woocommerce_shop_page_archive_redirect' );
|
||||
add_filter( 'wp_nav_menu_objects', 'woocommerce_nav_menu_item_classes', 2, 20 );
|
||||
add_action( 'wp', 'woocommerce_front_page_archive_paging_fix', 1 );
|
||||
add_action( 'loop_start', 'woocommerce_front_page_archive', 1 );
|
||||
|
@ -117,10 +118,6 @@ add_action( 'init', 'woocommerce_update_catalog_ordering' );
|
|||
add_action( 'init', 'woocommerce_update_cart_action' );
|
||||
add_action( 'init', 'woocommerce_add_to_cart_action' );
|
||||
|
||||
/* Checkout Actions */
|
||||
add_action( 'init', 'woocommerce_checkout_action' );
|
||||
add_action( 'init', 'woocommerce_pay_action' );
|
||||
|
||||
/* Login and Registration */
|
||||
add_action( 'init', 'woocommerce_process_login' );
|
||||
add_action( 'init', 'woocommerce_process_coupon_form' );
|
||||
|
|
|
@ -182,6 +182,17 @@ if (!function_exists('woocommerce_get_product_thumbnail')) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check product visibility in loop
|
||||
**/
|
||||
if (!function_exists('woocommerce_check_product_visibility')) {
|
||||
function woocommerce_check_product_visibility() {
|
||||
global $post, $product;
|
||||
if (!$product->is_visible( true ) && $post->post_parent > 0) : wp_safe_redirect(get_permalink($post->post_parent)); exit; endif;
|
||||
if (!$product->is_visible( true )) : wp_safe_redirect(home_url()); exit; endif;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pagination
|
||||
**/
|
||||
|
|
|
@ -52,7 +52,6 @@ class woocommerce {
|
|||
var $countries;
|
||||
var $validation;
|
||||
var $woocommerce_email;
|
||||
var $checkout;
|
||||
|
||||
/** Taxonomies ************************************************************/
|
||||
|
||||
|
@ -286,7 +285,7 @@ class woocommerce {
|
|||
|
||||
// Init styles
|
||||
if (!is_admin()) $this->init_styles();
|
||||
|
||||
|
||||
do_action( 'woocommerce_init' );
|
||||
}
|
||||
|
||||
|
@ -891,12 +890,8 @@ class woocommerce {
|
|||
* Get Checkout Class
|
||||
*/
|
||||
function checkout() {
|
||||
if ( !class_exists('woocommerce_checkout') ) :
|
||||
include( 'classes/checkout.class.php' );
|
||||
$this->checkout = new woocommerce_checkout();
|
||||
endif;
|
||||
|
||||
return $this->checkout;
|
||||
if ( !class_exists('woocommerce_checkout') ) include( 'classes/checkout.class.php' );
|
||||
return new woocommerce_checkout();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue