Merge remote branch 'upstream/master'

This commit is contained in:
Ramon van Belzen 2012-01-08 10:56:49 +01:00
commit 2b0c61af3b
52 changed files with 510 additions and 324 deletions

View File

@ -432,53 +432,6 @@ function woocommerce_products_subtype_query($query) {
endif;
}
/**
* Add functionality to the image uploader on product pages to exclude an image
**/
add_filter('attachment_fields_to_edit', 'woocommerce_exclude_image_from_product_page_field', 1, 2);
add_filter('attachment_fields_to_save', 'woocommerce_exclude_image_from_product_page_field_save', 1, 2);
function woocommerce_exclude_image_from_product_page_field( $fields, $object ) {
if (!$object->post_parent) return $fields;
$parent = get_post( $object->post_parent );
if ($parent->post_type!=='product') return $fields;
$exclude_image = (int) get_post_meta($object->ID, '_woocommerce_exclude_image', true);
$label = __('Exclude image', 'woocommerce');
$html = '<input type="checkbox" '.checked($exclude_image, 1, false).' name="attachments['.$object->ID.'][woocommerce_exclude_image]" id="attachments['.$object->ID.'][woocommerce_exclude_image" />';
$fields['woocommerce_exclude_image'] = array(
'label' => $label,
'input' => 'html',
'html' => $html,
'value' => '',
'helps' => __('Enabling this option will hide it from the product page image gallery.', 'woocommerce')
);
return $fields;
}
function woocommerce_exclude_image_from_product_page_field_save( $post, $attachment ) {
if (isset($_REQUEST['attachments'][$post['ID']]['woocommerce_exclude_image'])) :
delete_post_meta( (int) $post['ID'], '_woocommerce_exclude_image' );
update_post_meta( (int) $post['ID'], '_woocommerce_exclude_image', 1);
else :
delete_post_meta( (int) $post['ID'], '_woocommerce_exclude_image' );
update_post_meta( (int) $post['ID'], '_woocommerce_exclude_image', 0);
endif;
return $post;
}
/**
* Search by SKU or ID for products. Adapted from code by BenIrvin (Admin Search by ID)
*/

View File

@ -198,6 +198,8 @@ function variable_product_type_options() {
<button type="button" class="button button-primary add_variation" <?php disabled($variation_attribute_found, false); ?>><?php _e('Add Variation', 'woocommerce'); ?></button>
<button type="button" class="button link_all_variations" <?php disabled($variation_attribute_found, false); ?>><?php _e('Link all variations', 'woocommerce'); ?></button>
<a href="#" class="delete delete_variations"><?php _e('Delete all variations', 'woocommerce'); ?></a>
<p class="description"><?php _e('Add (optional) information for product variations. If you modify your product attributes you must save the product before they will be selectable.', 'woocommerce'); ?></p>
<?php endif; ?>
@ -385,6 +387,44 @@ function variable_product_type_options() {
return false;
});
jQuery('a.delete_variations').live('click', function(){
var answer = confirm('<?php _e('Are you sure you want to delete all variations? This cannot be undone.', 'woocommerce'); ?>');
if (answer){
var answer = confirm('<?php _e('Last warning, are you sure?', 'woocommerce'); ?>');
if (answer) {
var variation_ids = [];
jQuery('.woocommerce_variations .woocommerce_variation').block({ message: null, overlayCSS: { background: '#fff url(<?php echo $woocommerce->plugin_url(); ?>/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } });
jQuery('.woocommerce_variations .woocommerce_variation .remove_variation').each(function(){
var variation = jQuery(this).attr('rel');
if (variation>0) {
variation_ids.push(variation);
}
});
var data = {
action: 'woocommerce_remove_variations',
variation_ids: variation_ids,
security: '<?php echo wp_create_nonce("delete-variations"); ?>'
};
jQuery.post('<?php echo admin_url('admin-ajax.php'); ?>', data, function(response) {
jQuery('.woocommerce_variations .woocommerce_variation').fadeOut('300', function(){
jQuery('.woocommerce_variations .woocommerce_variation').remove();
});
});
}
}
return false;
});
jQuery('a.set_all_prices').click(function(){
var value = prompt("<?php _e('Enter a price', 'woocommerce'); ?>");
jQuery('input[name^="variable_price"]').val( value );

View File

@ -99,7 +99,7 @@ Gothica minim lectores demonstraverunt ut soluta. Sequitur quam exerci veniam al
*/
function woocommerce_prevent_admin_access() {
if ( get_option('woocommerce_lock_down_admin')=='yes' && !is_ajax() && !current_user_can('edit_posts') ) :
wp_safe_redirect(get_permalink(get_option('woocommerce_myaccount_page_id')));
wp_safe_redirect(get_permalink(woocommerce_get_page_id('myaccount')));
exit;
endif;
}

View File

@ -266,4 +266,54 @@ function woocommerce_admin_head() {
</style>
<?php
}
add_action('admin_head', 'woocommerce_admin_head');
add_action('admin_head', 'woocommerce_admin_head');
/**
* Add functionality to the image uploader on product pages to exclude an image
**/
add_filter('attachment_fields_to_edit', 'woocommerce_exclude_image_from_product_page_field', 1, 2);
add_filter('attachment_fields_to_save', 'woocommerce_exclude_image_from_product_page_field_save', 1, 2);
add_action('add_attachment', 'woocommerce_exclude_image_from_product_page_field_add');
function woocommerce_exclude_image_from_product_page_field( $fields, $object ) {
if (!$object->post_parent) return $fields;
$parent = get_post( $object->post_parent );
if ($parent->post_type!=='product') return $fields;
$exclude_image = (int) get_post_meta($object->ID, '_woocommerce_exclude_image', true);
$label = __('Exclude image', 'woocommerce');
$html = '<input type="checkbox" '.checked($exclude_image, 1, false).' name="attachments['.$object->ID.'][woocommerce_exclude_image]" id="attachments['.$object->ID.'][woocommerce_exclude_image" />';
$fields['woocommerce_exclude_image'] = array(
'label' => $label,
'input' => 'html',
'html' => $html,
'value' => '',
'helps' => __('Enabling this option will hide it from the product page image gallery.', 'woocommerce')
);
return $fields;
}
function woocommerce_exclude_image_from_product_page_field_save( $post, $attachment ) {
if (isset($_REQUEST['attachments'][$post['ID']]['woocommerce_exclude_image'])) :
delete_post_meta( (int) $post['ID'], '_woocommerce_exclude_image' );
update_post_meta( (int) $post['ID'], '_woocommerce_exclude_image', 1);
else :
delete_post_meta( (int) $post['ID'], '_woocommerce_exclude_image' );
update_post_meta( (int) $post['ID'], '_woocommerce_exclude_image', 0);
endif;
return $post;
}
function woocommerce_exclude_image_from_product_page_field_add( $post_id ) {
add_post_meta( $post_id, '_woocommerce_exclude_image', 0);
}

View File

@ -162,19 +162,19 @@ function woocommerce_create_pages() {
woocommerce_create_page( esc_sql( _x('my-account', 'page_slug', 'woocommerce') ), 'woocommerce_myaccount_page_id', __('My Account', 'woocommerce'), '[woocommerce_my_account]' );
// Edit address page
woocommerce_create_page( esc_sql( _x('edit-address', 'page_slug', 'woocommerce') ), 'woocommerce_edit_address_page_id', __('Edit My Address', 'woocommerce'), '[woocommerce_edit_address]', get_option('woocommerce_myaccount_page_id') );
woocommerce_create_page( esc_sql( _x('edit-address', 'page_slug', 'woocommerce') ), 'woocommerce_edit_address_page_id', __('Edit My Address', 'woocommerce'), '[woocommerce_edit_address]', woocommerce_get_page_id('myaccount') );
// View order page
woocommerce_create_page( esc_sql( _x('view-order', 'page_slug', 'woocommerce') ), 'woocommerce_view_order_page_id', __('View Order', 'woocommerce'), '[woocommerce_view_order]', get_option('woocommerce_myaccount_page_id') );
woocommerce_create_page( esc_sql( _x('view-order', 'page_slug', 'woocommerce') ), 'woocommerce_view_order_page_id', __('View Order', 'woocommerce'), '[woocommerce_view_order]', woocommerce_get_page_id('myaccount') );
// Change password page
woocommerce_create_page( esc_sql( _x('change-password', 'page_slug', 'woocommerce') ), 'woocommerce_change_password_page_id', __('Change Password', 'woocommerce'), '[woocommerce_change_password]', get_option('woocommerce_myaccount_page_id') );
woocommerce_create_page( esc_sql( _x('change-password', 'page_slug', 'woocommerce') ), 'woocommerce_change_password_page_id', __('Change Password', 'woocommerce'), '[woocommerce_change_password]', woocommerce_get_page_id('myaccount') );
// Pay page
woocommerce_create_page( esc_sql( _x('pay', 'page_slug', 'woocommerce') ), 'woocommerce_pay_page_id', __('Checkout &rarr; Pay', 'woocommerce'), '[woocommerce_pay]', get_option('woocommerce_checkout_page_id') );
woocommerce_create_page( esc_sql( _x('pay', 'page_slug', 'woocommerce') ), 'woocommerce_pay_page_id', __('Checkout &rarr; Pay', 'woocommerce'), '[woocommerce_pay]', woocommerce_get_page_id('checkout') );
// Thanks page
woocommerce_create_page( esc_sql( _x('order-received', 'page_slug', 'woocommerce') ), 'woocommerce_thanks_page_id', __('Order Received', 'woocommerce'), '[woocommerce_thankyou]', get_option('woocommerce_checkout_page_id') );
woocommerce_create_page( esc_sql( _x('order-received', 'page_slug', 'woocommerce') ), 'woocommerce_thanks_page_id', __('Order Received', 'woocommerce'), '[woocommerce_thankyou]', woocommerce_get_page_id('checkout') );
}

View File

@ -253,7 +253,7 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings',
)); // End general settings
$shop_page_id = get_option('woocommerce_shop_page_id');
$shop_page_id = woocommerce_get_page_id('shop');
$base_slug = ($shop_page_id > 0 && get_page( $shop_page_id )) ? get_page_uri( $shop_page_id ) : 'shop';
$woocommerce_settings['pages'] = apply_filters('woocommerce_page_settings', array(
@ -1021,14 +1021,14 @@ function woocommerce_settings() {
flush_rewrite_rules( false );
if (get_option('woocommerce_shop_page_id')) :
if (woocommerce_get_page_id('shop')) :
$install_complete = true;
else :
$show_page_installer = true;
endif;
// If we havn't just installed, but page installed has not been skipped and shop page does not exist...
elseif (!get_option('skip_install_woocommerce_pages') && !get_option('woocommerce_shop_page_id')) :
elseif (!get_option('skip_install_woocommerce_pages') && !woocommerce_get_page_id('shop')) :
$show_page_installer = true;
@ -1114,6 +1114,7 @@ function woocommerce_settings() {
<table class="wc_shipping widefat" cellspacing="0">
<thead>
<tr>
<th><?php _e('Default', 'woocommerce'); ?></th>
<th><?php _e('Shipping Method', 'woocommerce'); ?></th>
<th><?php _e('Status', 'woocommerce'); ?></th>
</tr>
@ -1121,12 +1122,16 @@ function woocommerce_settings() {
<tbody>
<?php
foreach ( $woocommerce->shipping->shipping_methods as $method ) :
echo '<tr>
$default_shipping_method = get_option('woocommerce_default_shipping_method');
echo '<tr>
<td width="1%" class="radio">
<input type="radio" name="default_shipping_method" value="'.$method->id.'" '.checked($default_shipping_method, $method->id, false).' />
<input type="hidden" name="method_order[]" value="'.$method->id.'" />
<td>
<p><strong>'.$method->title.'</strong><br/>
<small>'.__('Method ID', 'woocommerce').': '.$method->id.'</small></p>
<input type="hidden" name="method_order[]" value="'.$method->id.'" />
</td>
<td>';

View File

@ -94,14 +94,9 @@ function woocommerce_user_column_values($value, $column_name, $user_id) {
}
/**
* Show Address Fields on edit user pages
* Get Address Fields for edit user pages
*/
add_action( 'show_user_profile', 'woocommerce_customer_meta_fields' );
add_action( 'edit_user_profile', 'woocommerce_customer_meta_fields' );
function woocommerce_customer_meta_fields( $user ) {
if (!current_user_can('manage_woocommerce')) return $columns;
function woocommerce_get_customer_meta_fields() {
$show_fields = apply_filters('woocommerce_customer_meta_fields', array(
'billing' => array(
'title' => __('Customer Billing Address', 'woocommerce'),
@ -186,6 +181,19 @@ function woocommerce_customer_meta_fields( $user ) {
)
)
));
return $show_fields;
}
/**
* Show Address Fields on edit user pages
*/
add_action( 'show_user_profile', 'woocommerce_customer_meta_fields' );
add_action( 'edit_user_profile', 'woocommerce_customer_meta_fields' );
function woocommerce_customer_meta_fields( $user ) {
if (!current_user_can('manage_woocommerce')) return $columns;
$show_fields = woocommerce_get_customer_meta_fields();
foreach( $show_fields as $fieldset ) :
?>
@ -207,4 +215,24 @@ function woocommerce_customer_meta_fields( $user ) {
</table>
<?php
endforeach;
}
/**
* Save Address Fields on edit user pages
*/
add_action( 'personal_options_update', 'woocommerce_save_customer_meta_fields' );
add_action( 'edit_user_profile_update', 'woocommerce_save_customer_meta_fields' );
function woocommerce_save_customer_meta_fields( $user_id ) {
if (!current_user_can('manage_woocommerce')) return $columns;
$save_fields = woocommerce_get_customer_meta_fields();
foreach( $save_fields as $fieldset ) :
foreach( $fieldset['fields'] as $key => $field ) :
if (isset($_POST[$key])) update_user_meta( $user_id, $key, trim(esc_attr( $_POST[$key] )) );
endforeach;
endforeach;
}

View File

@ -169,6 +169,7 @@ table.woocommerce_attributes .taxonomy td.name{padding:10px 15px;font-size:14px;
table.woocommerce_attributes .taxonomy td.values{position:relative;}table.woocommerce_attributes .taxonomy td.values .chzn-container{width:100% !important;margin:0 1px;display:block;}table.woocommerce_attributes .taxonomy td.values .chzn-container .chzn-drop{width:100% !important;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;}
table.woocommerce_attributes .center{text-align:center;}
#woocommerce_attributes select.attribute_taxonomy,button.add_attribute,button.add_variable_attribute,button.add_variation,button.link_all_variations{float:right;}
a.delete_variations{float:right;line-height:23px;margin-right:3px;color:#999;}a.delete_variations:hover{color:red;}
#upsells_and_crosssells_product_data{padding:0 9px 9px;}
div.multi_select_products_wrapper{float:left;width:49%;padding:0;}
div.multi_select_products_wrapper-alt{float:right;}
@ -180,7 +181,7 @@ div.multi_select_products_wrapper-alt{float:right;}
.multi_select_products .product_search input{width:100%;}
#woocommerce-product-data input.dp-applied{float:left;}
#grouped_product_options,#virtual_product_options,#simple_product_options{padding:12px;font-style:italic;color:#666;}
#variable_product_options p.description{float:left;padding:0;margin:0;}
#variable_product_options p.description{float:left;padding:0;margin:0;line-height:23px;}
#variable_product_options p.bulk_edit,#variable_product_options p.default_variation{background:#ececec;padding:6px !important;margin:0 0 8px !important;overflow:hidden;zoom:1;}#variable_product_options p.bulk_edit strong,#variable_product_options p.default_variation strong{margin:0 6px 0 0;float:left;line-height:23px;}
#variable_product_options p.bulk_edit .button,#variable_product_options p.default_variation .button,#variable_product_options p.bulk_edit select,#variable_product_options p.default_variation select{margin:0 6px 0 0;float:left;}
#variable_product_options p.bulk_edit a.set,#variable_product_options p.default_variation a.set{padding-left:20px;background:#fefefe url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAARklEQVQYGWP8//8/AzGACV3Rnj17/oMwujiGQnQFMD7RChlBbsRmFcwkEO3i4sJImonIumGmg0xBFifaRKIVgj2DbAUuNgCfThpracSKqwAAAABJRU5ErkJggg==) no-repeat 7px 5px;}

View File

@ -982,6 +982,15 @@ table.woocommerce_attributes .center {
#woocommerce_attributes select.attribute_taxonomy, button.add_attribute, button.add_variable_attribute, button.add_variation, button.link_all_variations {
float: right;
}
a.delete_variations {
float: right;
line-height: 23px;
margin-right: 3px;
color: #999;
&:hover {
color: red;
}
}
#upsells_and_crosssells_product_data {
padding: 0 9px 9px;
@ -1042,6 +1051,7 @@ div.multi_select_products_wrapper-alt {
float: left;
padding: 0;
margin: 0;
line-height: 23px;
}
p.bulk_edit, p.default_variation {
background: #ececec;

View File

@ -21,7 +21,7 @@ div.product div.summary{float:right;width:48%;}
div.product div.social{text-align:right;margin:0 0 1em;}div.product div.social span{margin:0 0 0 2px;}div.product div.social span span{margin:0;}
div.product div.social span .stButton .chicklets{padding-left:16px;width:0;}
div.product div.social iframe{float:left;margin-top:3px;}
div.product .woocommerce_tabs{clear:both;padding:1em 0 0 0;margin:0 0 1em 0;}div.product .woocommerce_tabs ul.tabs{-webkit-border-top-left-radius:3px;-webkit-border-top-right-radius:3px;-moz-border-radius-topleft:3px;-moz-border-radius-topright:3px;border-top-left-radius:3px;border-top-right-radius:3px;background:#ddd;overflow:hidden;zoom:1;margin:0;padding:4px 4px 0;list-style:none outside;}div.product .woocommerce_tabs ul.tabs li{float:left;margin:0 4px 0 0;font-size:0.92em;}
div.product .woocommerce_tabs{clear:both;padding:1em 0 0 0;margin:0 0 1em 0;}div.product .woocommerce_tabs ul.tabs{-webkit-border-top-left-radius:3px;-webkit-border-top-right-radius:3px;-moz-border-radius-topleft:3px;-moz-border-radius-topright:3px;border-top-left-radius:3px;border-top-right-radius:3px;background:#ddd;overflow:hidden;zoom:1;margin:0;padding:4px 4px 0;list-style:none outside;}div.product .woocommerce_tabs ul.tabs li{float:left;margin:0 4px 0 0;font-size:0.92em;list-style:none outside;}
div.product .woocommerce_tabs ul.tabs a{float:left;padding:6px 12px;background:#eee;text-decoration:none;-webkit-border-top-left-radius:2px;-webkit-border-top-right-radius:2px;-moz-border-radius-topleft:2px;-moz-border-radius-topright:2px;border-top-left-radius:2px;border-top-right-radius:2px;}
div.product .woocommerce_tabs ul.tabs li.active a{background:#fff;color:#555;}
div.product .woocommerce_tabs .panel{border:1px solid #ddd;border-top:0;padding:15px 15px 0;-webkit-border-bottom-left-radius:3px;-webkit-border-bottom-right-radius:3px;-moz-border-radius-bottomleft:3px;-moz-border-radius-bottomright:3px;border-bottom-left-radius:3px;border-bottom-right-radius:3px;}
@ -36,7 +36,7 @@ form.cart .variations label{font-weight:bold;}
form.cart .variations select{width:100%;float:left;}
form.cart .button{vertical-align:middle;float:left;margin:2px 0;}
span.onsale{background:green;color:#fff;min-height:32px;min-width:32px;padding:4px;font-size:12px;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;}
.products ul,ul.products{margin:0 0 14px;padding:0;list-style:none;}
.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% 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;}

View File

@ -248,6 +248,7 @@ div.product {
float: left;
margin: 0 4px 0 0;
font-size: 0.92em;
list-style: none outside;
}
a {
float: left;
@ -339,7 +340,10 @@ span.onsale {
.products ul, ul.products {
margin: 0 0 14px;
padding: 0;
list-style: none;
list-style: none outside;
li {
list-style: none outside;
}
}
.related, .upsells.products {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -261,24 +261,24 @@ class woocommerce_cart {
/** gets the url to the cart page */
function get_cart_url() {
$cart_page_id = get_option('woocommerce_cart_page_id');
if ($cart_page_id) return get_permalink($cart_page_id);
$cart_page_id = woocommerce_get_page_id('cart');
if ($cart_page_id) return apply_filters('woocommerce_get_cart_url', get_permalink($cart_page_id));
}
/** gets the url to the checkout page */
function get_checkout_url() {
$checkout_page_id = get_option('woocommerce_checkout_page_id');
$checkout_page_id = woocommerce_get_page_id('checkout');
if ($checkout_page_id) :
if (is_ssl()) return str_replace('http:', 'https:', get_permalink($checkout_page_id));
return get_permalink($checkout_page_id);
return apply_filters('woocommerce_get_checkout_url', get_permalink($checkout_page_id));
endif;
}
/** gets the url to remove an item from the cart */
function get_remove_url( $cart_item_key ) {
global $woocommerce;
$cart_page_id = get_option('woocommerce_cart_page_id');
if ($cart_page_id) return $woocommerce->nonce_url( 'cart', add_query_arg('remove_item', $cart_item_key, get_permalink($cart_page_id)));
$cart_page_id = woocommerce_get_page_id('cart');
if ($cart_page_id) return apply_filters('woocommerce_get_remove_url', $woocommerce->nonce_url( 'cart', add_query_arg('remove_item', $cart_item_key, get_permalink($cart_page_id))));
}
/**

View File

@ -221,24 +221,26 @@ class woocommerce_checkout {
// Validation: Required fields
if ( isset($field['required']) && $field['required'] && empty($this->posted[$key]) ) $woocommerce->add_error( $field['label'] . ' ' . __('is a required field.', 'woocommerce') );
// 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;
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;
@ -297,7 +299,7 @@ class woocommerce_checkout {
endif;
// Terms
if (!isset($_POST['update_totals']) && empty($this->posted['terms']) && get_option('woocommerce_terms_page_id')>0 ) $woocommerce->add_error( __('You must accept our Terms &amp; Conditions.', 'woocommerce') );
if (!isset($_POST['update_totals']) && empty($this->posted['terms']) && woocommerce_get_page_id('terms')>0 ) $woocommerce->add_error( __('You must accept our Terms &amp; Conditions.', 'woocommerce') );
if ($woocommerce->cart->needs_shipping()) :
@ -563,10 +565,12 @@ class woocommerce_checkout {
// 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);
echo json_encode( $result );
exit;
else :
wp_safe_redirect( $result['redirect'] );
@ -586,10 +590,10 @@ class woocommerce_checkout {
// Redirect to success/confirmation/payment page
if (is_ajax()) :
ob_clean();
echo json_encode( array('redirect' => get_permalink(get_option('woocommerce_thanks_page_id'))) );
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( get_permalink(get_option('woocommerce_thanks_page_id')) );
wp_safe_redirect( apply_filters( 'woocommerce_checkout_no_payment_needed_redirect', get_permalink(woocommerce_get_page_id('thanks'))) );
exit;
endif;

View File

@ -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(get_option('woocommerce_thanks_page_id'))))
'redirect' => add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink(woocommerce_get_page_id('thanks'))))
);
}

View File

@ -126,7 +126,7 @@ class woocommerce_cheque 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(get_option('woocommerce_thanks_page_id'))))
'redirect' => add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink(woocommerce_get_page_id('thanks'))))
);
}

View File

@ -317,7 +317,7 @@ class woocommerce_paypal extends woocommerce_payment_gateway {
return array(
'result' => 'success',
'redirect' => add_query_arg('order', $order->id, add_query_arg('key', $order->order_key, get_permalink(get_option('woocommerce_pay_page_id'))))
'redirect' => add_query_arg('order', $order->id, add_query_arg('key', $order->order_key, get_permalink(woocommerce_get_page_id('pay'))))
);
}
@ -340,14 +340,19 @@ class woocommerce_paypal extends woocommerce_payment_gateway {
global $woocommerce;
if ($this->debug=='yes') $this->log->add( 'paypal', 'Checking IPN response is valid...' );
// Add cmd to the post array
$_POST['cmd'] = '_notify-validate';
// Get recieved values from post data
$received_values = (array) stripslashes_deep( $_POST );
// Add cmd to the post array
$received_values['cmd'] = '_notify-validate';
// Send back post vars to paypal
$params = array(
'body' => $_POST,
'sslverify' => false
'body' => $received_values,
'sslverify' => false,
'timeout' => 30,
'user-agent' => 'WooCommerce/'.$woocommerce->version
);
// Get url
@ -359,9 +364,6 @@ class woocommerce_paypal extends woocommerce_payment_gateway {
// Post back to get a response
$response = wp_remote_post( $paypal_adr, $params );
// Clean
unset($_POST['cmd']);
// check to see if the request was valid
if ( !is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 && (strcmp( $response['body'], "VERIFIED") == 0)) {
@ -385,13 +387,21 @@ class woocommerce_paypal extends woocommerce_payment_gateway {
function check_ipn_response() {
if (isset($_GET['paypalListener']) && $_GET['paypalListener'] == 'paypal_standard_IPN'):
ob_clean();
$_POST = stripslashes_deep($_POST);
if ($this->check_ipn_request_is_valid()) :
header('HTTP/1.1 200 OK');
do_action("valid-paypal-standard-ipn-request", $_POST);
else :
wp_die("PayPal IPN Request Failure");
endif;
endif;

View File

@ -28,7 +28,7 @@ class woocommerce_payment_gateway extends woocommerce_settings_api {
*/
function get_return_url( $order = '' ) {
$thanks_page_id = get_option('woocommerce_thanks_page_id');
$thanks_page_id = woocommerce_get_page_id('thanks');
if ($thanks_page_id) :
$return_url = get_permalink($thanks_page_id);
else :
@ -41,7 +41,7 @@ class woocommerce_payment_gateway extends woocommerce_settings_api {
if (is_ssl() || get_option('woocommerce_force_ssl_checkout')=='yes') $return_url = str_replace('http:', 'https:', $return_url);
return $return_url;
return apply_filters('woocommerce_get_return_url', $return_url);
}
/**

View File

@ -470,18 +470,18 @@ class woocommerce_order {
/** Generates a URL so that a customer can checkout/pay for their (unpaid - pending) order via a link */
function get_checkout_payment_url() {
$payment_page = get_permalink(get_option('woocommerce_pay_page_id'));
$payment_page = get_permalink(woocommerce_get_page_id('pay'));
if (get_option('woocommerce_force_ssl_checkout')=='yes' || is_ssl()) $payment_page = str_replace('http:', 'https:', $payment_page);
return add_query_arg('pay_for_order', 'true', add_query_arg('order', $this->order_key, add_query_arg('order_id', $this->id, $payment_page)));
return apply_filters('woocommerce_get_checkout_payment_url', add_query_arg('pay_for_order', 'true', add_query_arg('order', $this->order_key, add_query_arg('order_id', $this->id, $payment_page))));
}
/** Generates a URL so that a customer can cancel their (unpaid - pending) order */
function get_cancel_order_url() {
global $woocommerce;
return $woocommerce->nonce_url( 'cancel_order', add_query_arg('cancel_order', 'true', add_query_arg('order', $this->order_key, add_query_arg('order_id', $this->id, trailingslashit( home_url() )))));
return apply_filters('woocommerce_get_cancel_order_url', $woocommerce->nonce_url( 'cancel_order', add_query_arg('cancel_order', 'true', add_query_arg('order', $this->order_key, add_query_arg('order_id', $this->id, trailingslashit( home_url() ))))));
}

View File

@ -198,9 +198,9 @@ class woocommerce_product {
update_post_meta($this->id, '_stock', $this->stock);
// Out of stock attribute
if (!$this->is_in_stock()) :
if ($this->managing_stock() && !$this->backorders_allowed() && $this->get_total_stock()<=0) :
update_post_meta($this->id, '_stock_status', 'outofstock');
$woocommerce->clear_product_transients( $this->id ); // Clear transient
$woocommerce->clear_product_transients( $this->id ); // Clear transient
endif;
return $this->stock;
@ -219,7 +219,10 @@ class woocommerce_product {
update_post_meta($this->id, '_stock', $this->stock);
// Out of stock attribute
if ($this->is_in_stock()) update_post_meta($this->id, '_stock_status', 'instock');
if ($this->managing_stock() && ($this->backorders_allowed() || $this->get_total_stock()>0)) :
update_post_meta($this->id, '_stock_status', 'instock');
$woocommerce->clear_product_transients( $this->id ); // Clear transient
endif;
return $this->stock;
endif;

View File

@ -62,7 +62,7 @@ class free_shipping extends woocommerce_shipping_method {
'title' => __( 'Coupon', 'woocommerce' ),
'type' => 'checkbox',
'label' => __( 'Free shipping requires a free shipping coupon', 'woocommerce' ),
'description' => __('Users will need to enter a valid free shipping coupon code to use this method.', 'woocommerce'),
'description' => __('Users will need to enter a valid free shipping coupon code to use this method. If a coupon is used, the minimum order amount will be ignored.', 'woocommerce'),
'default' => 'no'
),
'availability' => array(
@ -114,18 +114,6 @@ class free_shipping extends woocommerce_shipping_method {
if ($this->enabled=="no") return false;
if (isset($woocommerce->cart->cart_contents_total)) :
if ($woocommerce->cart->prices_include_tax) :
$total = $woocommerce->cart->tax_total + $woocommerce->cart->cart_contents_total;
else :
$total = $woocommerce->cart->cart_contents_total;
endif;
if (isset($this->min_amount) && $this->min_amount && $this->min_amount > $total) return false;
endif;
$ship_to_countries = '';
if ($this->availability == 'specific') :
@ -139,7 +127,7 @@ class free_shipping extends woocommerce_shipping_method {
if (is_array($ship_to_countries)) :
if (!in_array($woocommerce->customer->get_shipping_country(), $ship_to_countries)) return false;
endif;
if ($this->requires_coupon=="yes") :
if ($woocommerce->cart->applied_coupons) : foreach ($woocommerce->cart->applied_coupons as $code) :
@ -154,6 +142,18 @@ class free_shipping extends woocommerce_shipping_method {
return false;
endif;
if (isset($woocommerce->cart->cart_contents_total)) :
if ($woocommerce->cart->prices_include_tax) :
$total = $woocommerce->cart->tax_total + $woocommerce->cart->cart_contents_total;
else :
$total = $woocommerce->cart->cart_contents_total;
endif;
if (isset($this->min_amount) && $this->min_amount && $this->min_amount > $total) return false;
endif;
return true;
}

View File

@ -107,9 +107,6 @@ class woocommerce_shipping {
$_cheapest_cost = '';
$_cheapest_method = '';
if (isset($_SESSION['_chosen_shipping_method'])) $chosen_method = $_SESSION['_chosen_shipping_method']; else $chosen_method = '';
$calc_cheapest = false;
if (!$chosen_method || empty($chosen_method)) $calc_cheapest = true;
$this->reset_shipping_methods();
@ -117,18 +114,25 @@ class woocommerce_shipping {
if (sizeof($_available_methods)>0) :
foreach ($_available_methods as $method_id => $method) :
if ($method->cost < $_cheapest_cost || !is_numeric($_cheapest_cost)) :
$_cheapest_cost = $method->cost;
$_cheapest_method = $method_id;
// If not set, set a default
if (!$chosen_method || empty($chosen_method) || !isset($_available_methods[$chosen_method])) :
$chosen_method = get_option('woocommerce_default_shipping_method');
if (!$chosen_method || empty($chosen_method) || !isset($_available_methods[$chosen_method])) :
// Default to cheapest
foreach ($_available_methods as $method_id => $method) :
if ($method->cost < $_cheapest_cost || !is_numeric($_cheapest_cost)) :
$_cheapest_cost = $method->cost;
$_cheapest_method = $method_id;
endif;
endforeach;
$chosen_method = $_cheapest_method;
endif;
endforeach;
// Default to cheapest
if ($calc_cheapest || !isset($_available_methods[$chosen_method])) :
$chosen_method = $_cheapest_method;
endif;
if ($chosen_method) :
$_SESSION['_chosen_shipping_method'] = $chosen_method;
$this->shipping_total = $_available_methods[$chosen_method]->cost;
@ -148,6 +152,8 @@ class woocommerce_shipping {
}
function process_admin_options() {
$default_shipping_method = (isset($_POST['default_shipping_method'])) ? esc_attr($_POST['default_shipping_method']) : '';
$method_order = (isset($_POST['method_order'])) ? $_POST['method_order'] : '';
$order = array();
@ -160,6 +166,7 @@ class woocommerce_shipping {
endforeach;
endif;
update_option( 'woocommerce_default_shipping_method', $default_shipping_method );
update_option( 'woocommerce_shipping_method_order', $order );
}
}

View File

@ -71,7 +71,8 @@ class woocommerce_query {
if (!$q->is_tax( 'product_cat' ) && !$q->is_tax( 'product_tag' )) $q->set( 'post_type', 'product' );
$q->set( 'meta_query', $meta_query );
$q->set( 'post__in', $post__in );
$q->set( 'posts_per_page', apply_filters('loop_shop_per_page', get_option('posts_per_page')) );
$q->set( 'posts_per_page', ($q->get('posts_per_page')) ? $q->get('posts_per_page') : apply_filters('loop_shop_per_page', get_option('posts_per_page') ) );
// Store variables
$this->post__in = $post__in;

View File

@ -89,6 +89,7 @@ Yes you can! Join in on our GitHub repository :) https://github.com/woothemes/wo
* Rewritten parts + re-organised files for increased performance and decreased memory usage
* Moved many shortcodes (contents) to template files for easier customisation
* Moved template function contents to template files
* Added a simple, basic method of adding woocommerce support to themes using a woocommerce.php file based on page.php containing woocommerce_content()
* Moved woocommerce class into the main file
* Category ordering fix
* Made 'product' global, and auto filled when calling the_post - also remove this from the hooks. Certain themes may need to be updated.
@ -115,6 +116,8 @@ Yes you can! Join in on our GitHub repository :) https://github.com/woothemes/wo
* woocommerce_product_visibility_options filter for backend
* Shipping method classes/api changed to make rate definition simpler - shipping methods will need updating to stay compatible
* Change textdomain from woothemes to woocommerce
* Free shipping coupons ignore min-amount
* Delete all variations option
= 1.3.2.1 - 15/12/2011 =
* Category/Ordering fix

View File

@ -20,7 +20,7 @@ function woocommerce_checkout( $atts ) {
if (!defined('WOOCOMMERCE_CHECKOUT')) define('WOOCOMMERCE_CHECKOUT', true);
if (sizeof($woocommerce->cart->get_cart())==0) :
wp_redirect(get_permalink(get_option('woocommerce_cart_page_id')));
wp_redirect(get_permalink(woocommerce_get_page_id('cart')));
exit;
endif;

View File

@ -73,7 +73,7 @@ function woocommerce_edit_address() {
global $woocommerce, $load_address, $address;
if ( ! is_user_logged_in() ) :
wp_safe_redirect( get_permalink( get_option( 'woocommerce_myaccount_page_id' ) ) );
wp_safe_redirect( get_permalink( woocommerce_get_page_id('myaccount') ) );
exit;
endif;
@ -152,7 +152,7 @@ function woocommerce_save_address() {
do_action( 'woocommerce_customer_save_address', $user_id );
wp_safe_redirect( get_permalink( get_option( 'woocommerce_myaccount_page_id' ) ) );
wp_safe_redirect( get_permalink( woocommerce_get_page_id('myaccount') ) );
exit;
}
}
@ -188,7 +188,7 @@ function woocommerce_change_password() {
global $woocommerce;
if ( ! is_user_logged_in() ) :
wp_safe_redirect( get_permalink( get_option( 'woocommerce_myaccount_page_id' ) ) );
wp_safe_redirect( get_permalink( woocommerce_get_page_id('myaccount') ) );
exit;
endif;
@ -231,7 +231,7 @@ function woocommerce_save_password() {
do_action( 'woocommerce_customer_change_password', $user_id );
wp_safe_redirect( get_permalink( get_option( 'woocommerce_myaccount_page_id' ) ) );
wp_safe_redirect( get_permalink( woocommerce_get_page_id('myaccount') ) );
exit;
}
}
@ -247,7 +247,7 @@ function woocommerce_view_order() {
global $woocommerce;
if ( ! is_user_logged_in() ) :
wp_safe_redirect( get_permalink( get_option( 'woocommerce_myaccount_page_id' ) ) );
wp_safe_redirect( get_permalink( woocommerce_get_page_id('myaccount') ) );
exit;
endif;
@ -256,7 +256,7 @@ function woocommerce_view_order() {
$order = &new woocommerce_order( $order_id );
if ( $order_id==0 || $order->user_id != $user_id ) :
wp_safe_redirect( get_permalink( get_option( 'woocommerce_myaccount_page_id' ) ) );
wp_safe_redirect( get_permalink( woocommerce_get_page_id('myaccount') ) );
exit;
endif;

View File

@ -61,7 +61,7 @@ function woocommerce_pay() {
// No payment was required for order
$order->payment_complete();
wp_safe_redirect( get_permalink(get_option('woocommerce_thanks_page_id')) );
wp_safe_redirect( get_permalink(woocommerce_get_page_id('thanks')) );
exit;
endif;
@ -124,14 +124,14 @@ function woocommerce_pay() {
else :
wp_safe_redirect( get_permalink(get_option('woocommerce_myaccount_page_id')) );
wp_safe_redirect( get_permalink(woocommerce_get_page_id('myaccount')) );
exit;
endif;
else :
wp_safe_redirect( get_permalink(get_option('woocommerce_myaccount_page_id')) );
wp_safe_redirect( get_permalink(woocommerce_get_page_id('myaccount')) );
exit;
endif;

View File

@ -1,26 +1,10 @@
<?php get_header('shop'); ?>
<?php do_action('woocommerce_before_main_content'); // <div id="container"><div id="content" role="main"> ?>
<?php do_action('woocommerce_before_main_content'); ?>
<?php
$shop_page_id = get_option('woocommerce_shop_page_id');
$shop_page = get_post($shop_page_id);
$shop_page_title = (get_option('woocommerce_shop_page_title')) ? get_option('woocommerce_shop_page_title') : $shop_page->post_title;
?>
<?php if (is_search()) : ?>
<h1 class="page-title"><?php _e('Search Results:', 'woocommerce'); ?> &ldquo;<?php the_search_query(); ?>&rdquo; <?php if (get_query_var('paged')) echo ' &mdash; Page '.get_query_var('paged'); ?></h1>
<?php else : ?>
<h1 class="page-title"><?php echo apply_filters('the_title', $shop_page_title); ?></h1>
<?php endif; ?>
<?php echo apply_filters('the_content', $shop_page->post_content); ?>
<?php woocommerce_archive_product_content(); ?>
<?php woocommerce_get_template_part( 'loop', 'shop' ); ?>
<?php do_action('woocommerce_pagination'); ?>
<?php do_action('woocommerce_after_main_content'); // </div></div> ?>
<?php do_action('woocommerce_after_main_content'); ?>
<?php do_action('woocommerce_sidebar'); ?>

View File

@ -31,14 +31,14 @@ global $woocommerce;
<tr>
<td class="product-remove"><a href="<?php echo esc_url( $woocommerce->cart->get_remove_url($cart_item_key) ); ?>" class="remove" title="<?php _e('Remove this item', 'woocommerce'); ?>">&times;</a></td>
<td class="product-thumbnail">
<a href="<?php echo esc_url( get_permalink($values['product_id']) ); ?>">
<a href="<?php echo esc_url( get_permalink(apply_filters('woocommerce_in_cart_product_id', $values['product_id'])) ); ?>">
<?php
echo $_product->get_image();
?>
</a>
</td>
<td class="product-name">
<a href="<?php echo esc_url( get_permalink($values['product_id']) ); ?>"><?php echo $_product->get_title(); ?></a>
<a href="<?php echo esc_url( get_permalink(apply_filters('woocommerce_in_cart_product_id', $values['product_id'])) ); ?>"><?php echo $_product->get_title(); ?></a>
<?php
// Meta data
echo $woocommerce->cart->get_item_data( $values );

View File

@ -8,4 +8,4 @@
<?php do_action('woocommerce_cart_is_empty'); ?>
<p><a class="button" href="<?php echo get_permalink(get_option('woocommerce_shop_page_id')); ?>"><?php _e('&larr; Return To Shop', 'woocommerce') ?></a></p>
<p><a class="button" href="<?php echo get_permalink(woocommerce_get_page_id('shop')); ?>"><?php _e('&larr; Return To Shop', 'woocommerce') ?></a></p>

View File

@ -10,4 +10,4 @@ $info_message = apply_filters('woocommerce_checkout_login_message', __('Already
<p class="info"><?php echo $info_message; ?> <a href="#" class="showlogin"><?php _e('Click here to login', 'woocommerce'); ?></a></p>
<?php woocommerce_login_form( array( 'message' => __('If you have shopped with us before, please enter your username and password in the boxes below. If you are a new customer please proceed to the Billing &amp; Shipping section.', 'woocommerce'), 'redirect' => get_permalink(get_option('woocommerce_checkout_page_id')) ) ); ?>
<?php woocommerce_login_form( array( 'message' => __('If you have shopped with us before, please enter your username and password in the boxes below. If you are a new customer please proceed to the Billing &amp; Shipping section.', 'woocommerce'), 'redirect' => get_permalink(woocommerce_get_page_id('checkout')) ) ); ?>

View File

@ -234,9 +234,9 @@
<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 (get_option('woocommerce_terms_page_id')>0) : ?>
<?php if (woocommerce_get_page_id('terms')>0) : ?>
<p class="form-row terms">
<label for="terms" class="checkbox"><?php _e('I accept the', 'woocommerce'); ?> <a href="<?php echo esc_url( get_permalink(get_option('woocommerce_terms_page_id')) ); ?>" target="_blank"><?php _e('terms &amp; conditions', 'woocommerce'); ?></a></label>
<label for="terms" class="checkbox"><?php _e('I accept the', 'woocommerce'); ?> <a href="<?php echo esc_url( get_permalink(woocommerce_get_page_id('terms')) ); ?>" target="_blank"><?php _e('terms &amp; conditions', 'woocommerce'); ?></a></label>
<input type="checkbox" class="input-checkbox" name="terms" <?php if (isset($_POST['terms'])) echo 'checked="checked"'; ?> id="terms" />
</p>
<?php endif; ?>

View File

@ -23,7 +23,7 @@ global $woocommerce, $order;
<p>
<a href="<?php echo esc_url( $order->get_checkout_payment_url() ); ?>" class="button pay"><?php _e('Pay', 'woocommerce') ?></a>
<?php if (is_user_logged_in()) : ?>
<a href="<?php echo esc_url( get_permalink(get_option('woocommerce_myaccount_page_id')) ); ?>" class="button pay"><?php _e('My Account', 'woocommerce'); ?></a>
<a href="<?php echo esc_url( get_permalink(woocommerce_get_page_id('myaccount')) ); ?>" class="button pay"><?php _e('My Account', 'woocommerce'); ?></a>
<?php endif; ?>
</p>

View File

@ -11,7 +11,7 @@
<li><?php echo sprintf(__('Password: %s', 'woocommerce'), $user_pass); ?></li>
</ul>
<p><?php echo sprintf(__("You can login to your account area here: %s.", 'woocommerce'), get_permalink(get_option('woocommerce_myaccount_page_id'))); ?></p>
<p><?php echo sprintf(__("You can login to your account area here: %s.", 'woocommerce'), get_permalink(woocommerce_get_page_id('myaccount'))); ?></p>
<div style="clear:both;"></div>

View File

@ -3,8 +3,8 @@
* Sorting
*/
?>
<form class="woocommerce_ordering" method="post">
<select name="catalog_orderby" class="orderby">
<form class="woocommerce_ordering" method="<?php if (get_option( 'permalink_structure' )=="") echo 'POST'; else echo 'GET'; ?>">
<select name="orderby" class="orderby">
<?php
$catalog_orderby = apply_filters('woocommerce_catalog_orderby', array(
'title' => __('Alphabetically', 'woocommerce'),

View File

@ -8,7 +8,7 @@ global $woocommerce;
<?php $woocommerce->show_messages(); ?>
<form action="<?php echo esc_url( get_permalink(get_option('woocommerce_change_password_page_id')) ); ?>" method="post">
<form action="<?php echo esc_url( get_permalink(woocommerce_get_page_id('change_password')) ); ?>" method="post">
<p class="form-row form-row-first">
<label for="password_1"><?php _e('New password', 'woocommerce'); ?> <span class="required">*</span></label>

View File

@ -8,7 +8,7 @@ global $woocommerce, $load_address, $address;
<?php $woocommerce->show_messages(); ?>
<form action="<?php echo esc_url( add_query_arg( 'address', $load_address, get_permalink( get_option( 'woocommerce_edit_address_page_id' ) ) ) ); ?>" method="post">
<form action="<?php echo esc_url( add_query_arg( 'address', $load_address, get_permalink( woocommerce_get_page_id('edit_address') ) ) ); ?>" method="post">
<h3><?php if ($load_address=='billing') _e('Billing Address', 'woocommerce'); else _e('Shipping Address', 'woocommerce'); ?></h3>

View File

@ -8,7 +8,7 @@ global $woocommerce, $current_user, $recent_orders;
<?php $woocommerce->show_messages(); ?>
<p><?php echo sprintf( __('Hello, <strong>%s</strong>. From your account dashboard you can view your recent orders, manage your shipping and billing addresses and <a href="%s">change your password</a>.', 'woocommerce'), $current_user->display_name, get_permalink(get_option('woocommerce_change_password_page_id'))); ?></p>
<p><?php echo sprintf( __('Hello, <strong>%s</strong>. From your account dashboard you can view your recent orders, manage your shipping and billing addresses and <a href="%s">change your password</a>.', 'woocommerce'), $current_user->display_name, get_permalink(woocommerce_get_page_id('change_password'))); ?></p>
<?php do_action('woocommerce_before_my_account'); ?>
@ -65,7 +65,7 @@ if ($customer_orders) :
<a href="<?php echo esc_url( $order->get_checkout_payment_url() ); ?>" class="button pay"><?php _e('Pay', 'woocommerce'); ?></a>
<a href="<?php echo esc_url( $order->get_cancel_order_url() ); ?>" class="button cancel"><?php _e('Cancel', 'woocommerce'); ?></a>
<?php endif; ?>
<a href="<?php echo esc_url( add_query_arg('order', $order->id, get_permalink(get_option('woocommerce_view_order_page_id'))) ); ?>" class="button"><?php _e('View', 'woocommerce'); ?></a>
<a href="<?php echo esc_url( add_query_arg('order', $order->id, get_permalink(woocommerce_get_page_id('view_order'))) ); ?>" class="button"><?php _e('View', 'woocommerce'); ?></a>
</td>
</tr><?php
endforeach;
@ -86,7 +86,7 @@ endif;
<header class="title">
<h3><?php _e('Billing Address', 'woocommerce'); ?></h3>
<a href="<?php echo esc_url( add_query_arg('address', 'billing', get_permalink(get_option('woocommerce_edit_address_page_id'))) ); ?>" class="edit"><?php _e('Edit', 'woocommerce'); ?></a>
<a href="<?php echo esc_url( add_query_arg('address', 'billing', get_permalink(woocommerce_get_page_id('edit_address'))) ); ?>" class="edit"><?php _e('Edit', 'woocommerce'); ?></a>
</header>
<address>
<?php
@ -114,7 +114,7 @@ endif;
<header class="title">
<h3><?php _e('Shipping Address', 'woocommerce'); ?></h3>
<a href="<?php echo esc_url( add_query_arg('address', 'shipping', get_permalink(get_option('woocommerce_edit_address_page_id'))) ); ?>" class="edit"><?php _e('Edit', 'woocommerce'); ?></a>
<a href="<?php echo esc_url( add_query_arg('address', 'shipping', get_permalink(woocommerce_get_page_id('edit_address'))) ); ?>" class="edit"><?php _e('Edit', 'woocommerce'); ?></a>
</header>
<address>
<?php

View File

@ -1,19 +0,0 @@
<?php get_header('shop'); ?>
<?php do_action('woocommerce_before_main_content'); // <div id="container"><div id="content" role="main"> ?>
<?php $term = get_term_by( 'slug', get_query_var($wp_query->query_vars['taxonomy']), $wp_query->query_vars['taxonomy']); ?>
<h1 class="page-title"><?php echo wptexturize($term->name); ?></h1>
<?php if ($term->description) : ?><div class="term_description"><?php echo wpautop(wptexturize($term->description)); ?></div><?php endif; ?>
<?php woocommerce_get_template_part( 'loop', 'shop' ); ?>
<?php do_action('woocommerce_pagination'); ?>
<?php do_action('woocommerce_after_main_content'); // </div></div> ?>
<?php do_action('woocommerce_sidebar'); ?>
<?php get_footer('shop'); ?>

View File

@ -11,10 +11,10 @@ $home_link = home_url();
$prepend = '';
if ( get_option('woocommerce_prepend_shop_page_to_urls')=="yes" && get_option('woocommerce_shop_page_id') && get_option('page_on_front') !== get_option('woocommerce_shop_page_id') )
$prepend = $before . '<a href="' . get_permalink( get_option('woocommerce_shop_page_id') ) . '">' . get_the_title( get_option('woocommerce_shop_page_id') ) . '</a> ' . $after . $delimiter;
if ( get_option('woocommerce_prepend_shop_page_to_urls')=="yes" && woocommerce_get_page_id('shop') && get_option('page_on_front') !== woocommerce_get_page_id('shop') )
$prepend = $before . '<a href="' . get_permalink( woocommerce_get_page_id('shop') ) . '">' . get_the_title( woocommerce_get_page_id('shop') ) . '</a> ' . $after . $delimiter;
if ( (!is_home() && !is_front_page() && !(is_post_type_archive() && get_option('page_on_front')==get_option('woocommerce_shop_page_id'))) || is_paged() ) :
if ( (!is_home() && !is_front_page() && !(is_post_type_archive() && get_option('page_on_front')==woocommerce_get_page_id('shop'))) || is_paged() ) :
echo $wrap_before;
@ -74,9 +74,9 @@ if ( (!is_home() && !is_front_page() && !(is_post_type_archive() && get_option('
echo $before . get_the_time('Y') . $after;
elseif ( is_post_type_archive('product') && get_option('page_on_front') !== get_option('woocommerce_shop_page_id') ) :
elseif ( is_post_type_archive('product') && get_option('page_on_front') !== woocommerce_get_page_id('shop') ) :
$_name = get_option('woocommerce_shop_page_id') ? get_the_title( get_option('woocommerce_shop_page_id') ) : ucwords(get_option('woocommerce_shop_slug'));
$_name = woocommerce_get_page_id('shop') ? get_the_title( woocommerce_get_page_id('shop') ) : ucwords(get_option('woocommerce_shop_slug'));
if (is_search()) :

View File

@ -2,29 +2,7 @@
<?php do_action('woocommerce_before_main_content'); ?>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<?php do_action('woocommerce_before_single_product'); ?>
<div itemscope itemtype="http://schema.org/Product" id="product-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php do_action('woocommerce_before_single_product_summary'); ?>
<div class="summary">
<h1 itemprop="name" class="product_title page-title"><?php the_title(); ?></h1>
<?php do_action( 'woocommerce_single_product_summary'); ?>
</div>
<?php do_action('woocommerce_after_single_product_summary'); ?>
</div>
<?php do_action('woocommerce_after_single_product'); ?>
<?php endwhile; ?>
<?php woocommerce_single_product_content(); ?>
<?php do_action('woocommerce_after_main_content'); ?>

View File

@ -1 +1,11 @@
<?php woocommerce_get_template( 'product_taxonomy.php' ); ?>
<?php get_header('shop'); ?>
<?php do_action('woocommerce_before_main_content'); ?>
<?php woocommerce_product_taxonomy_content(); ?>
<?php do_action('woocommerce_after_main_content'); ?>
<?php do_action('woocommerce_sidebar'); ?>
<?php get_footer('shop'); ?>

View File

@ -1 +1,11 @@
<?php woocommerce_get_template( 'product_taxonomy.php' ); ?>
<?php get_header('shop'); ?>
<?php do_action('woocommerce_before_main_content'); ?>
<?php woocommerce_product_taxonomy_content(); ?>
<?php do_action('woocommerce_after_main_content'); ?>
<?php do_action('woocommerce_sidebar'); ?>
<?php get_footer('shop'); ?>

View File

@ -21,16 +21,16 @@ remove_role( 'shop_manager' );
$wp_roles->remove_cap( 'administrator', 'manage_woocommerce' );
// Pages
wp_delete_post( get_option('woocommerce_shop_page_id'), true );
wp_delete_post( get_option('woocommerce_cart_page_id'), true );
wp_delete_post( get_option('woocommerce_checkout_page_id'), true );
wp_delete_post( get_option('woocommerce_order_tracking_page_id'), true );
wp_delete_post( get_option('woocommerce_myaccount_page_id'), true );
wp_delete_post( get_option('woocommerce_edit_address_page_id'), true );
wp_delete_post( get_option('woocommerce_view_order_page_id'), true );
wp_delete_post( get_option('woocommerce_change_password_page_id'), true );
wp_delete_post( get_option('woocommerce_pay_page_id'), true );
wp_delete_post( get_option('woocommerce_thanks_page_id'), true );
wp_delete_post( woocommerce_get_page_id('shop'), true );
wp_delete_post( woocommerce_get_page_id('cart'), true );
wp_delete_post( woocommerce_get_page_id('checkout'), true );
wp_delete_post( woocommerce_get_page_id('order_tracking'), true );
wp_delete_post( woocommerce_get_page_id('myaccount'), true );
wp_delete_post( woocommerce_get_page_id('edit_address'), true );
wp_delete_post( woocommerce_get_page_id('view_order'), true );
wp_delete_post( woocommerce_get_page_id('change_password'), true );
wp_delete_post( woocommerce_get_page_id('pay'), true );
wp_delete_post( woocommerce_get_page_id('thanks'), true );
// Tables
$wpdb->query("DROP TABLE IF EXISTS ".$wpdb->prefix."woocommerce_attribute_taxonomies");

View File

@ -222,7 +222,7 @@ class WooCommerce_Widget_Layered_Nav extends WP_Widget {
// Base Link decided by current page
if (defined('SHOP_IS_ON_FRONT')) :
$link = home_url();
elseif (is_post_type_archive('product') || is_page( get_option('woocommerce_shop_page_id') )) :
elseif (is_post_type_archive('product') || is_page( woocommerce_get_page_id('shop') )) :
$link = get_post_type_archive_link('product');
else :
$link = get_term_link( get_query_var('term'), get_query_var('taxonomy') );

View File

@ -53,8 +53,8 @@ class WooCommerce_Widget_Login extends WP_Widget {
do_action('woocommerce_login_widget_logged_in_before_links');
$links = apply_filters( 'woocommerce_login_widget_logged_in_links', array(
__('My account', 'woocommerce') => get_permalink(get_option('woocommerce_myaccount_page_id')),
__('Change my password', 'woocommerce') => get_permalink(get_option('woocommerce_change_password_page_id')),
__('My account', 'woocommerce') => get_permalink(woocommerce_get_page_id('myaccount')),
__('Change my password', 'woocommerce') => get_permalink(woocommerce_get_page_id('change_password')),
__('Logout', 'woocommerce') => wp_logout_url(home_url())
));
@ -86,7 +86,7 @@ class WooCommerce_Widget_Login extends WP_Widget {
endforeach;
// Get redirect URL
$redirect_to = apply_filters( 'woocommerce_login_widget_redirect', get_permalink(get_option('woocommerce_myaccount_page_id')) );
$redirect_to = apply_filters( 'woocommerce_login_widget_redirect', get_permalink(woocommerce_get_page_id('myaccount')) );
?>
<form method="post">
@ -196,7 +196,7 @@ function woocommerce_sidebar_login_process() {
global $login_errors;
// Get redirect URL
$redirect_to = apply_filters( 'woocommerce_login_widget_redirect', get_permalink(get_option('woocommerce_myaccount_page_id')) );
$redirect_to = apply_filters( 'woocommerce_login_widget_redirect', get_permalink(woocommerce_get_page_id('myaccount')) );
// Check for Secure Cookie
$secure_cookie = '';

View File

@ -137,7 +137,7 @@ function woocommerce_ajax_add_to_cart() {
check_ajax_referer( 'add-to-cart', 'security' );
$product_id = (int) $_POST['product_id'];
$product_id = (int) apply_filters('woocommerce_add_to_cart_product_id', $_POST['product_id']);
if ($woocommerce->cart->add_to_cart($product_id, 1)) :
// Return html fragments
@ -257,6 +257,23 @@ function woocommerce_remove_variation() {
}
/**
* Delete variations via ajax function
*/
add_action('wp_ajax_woocommerce_remove_variations', 'woocommerce_remove_variations');
function woocommerce_remove_variations() {
check_ajax_referer( 'delete-variations', 'security' );
$variation_ids = (array) $_POST['variation_ids'];
foreach ($variation_ids as $variation_id) :
$variation = get_post($variation_id);
if ($variation && $variation->post_type=="product_variation") wp_delete_post( $variation_id );
endforeach;
die();
}
/**
* Add variation via ajax function
*/

View File

@ -20,6 +20,17 @@ function woocommerce_mail( $to, $subject, $message, $headers = "Content-Type: te
$mailer->send( $to, $subject, $message, $headers, $attachments );
}
/**
* WooCommerce page IDs
*
* retrieve page ids - used for myaccount, edit_address, change_password, shop, cart, checkout, pay, view_order, thanks, terms, order_tracking
**/
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'));
}
}
/**
* WooCommerce conditionals
*
@ -30,7 +41,7 @@ function is_woocommerce() {
}
if (!function_exists('is_shop')) {
function is_shop() {
if (is_post_type_archive( 'product' ) || is_page(get_option('woocommerce_shop_page_id'))) return true; else return false;
if (is_post_type_archive( 'product' ) || is_page(woocommerce_get_page_id('shop'))) return true; else return false;
}
}
if (!function_exists('is_product_category')) {
@ -50,18 +61,18 @@ if (!function_exists('is_product')) {
}
if (!function_exists('is_cart')) {
function is_cart() {
return is_page(get_option('woocommerce_cart_page_id'));
return is_page(woocommerce_get_page_id('cart'));
}
}
if (!function_exists('is_checkout')) {
function is_checkout() {
if (is_page(get_option('woocommerce_checkout_page_id')) || is_page(get_option('woocommerce_pay_page_id'))) return true; else return false;
if (is_page(woocommerce_get_page_id('checkout')) || is_page(woocommerce_get_page_id('pay'))) return true; else return false;
}
}
if (!function_exists('is_account_page')) {
function is_account_page() {
if ( is_page(get_option('woocommerce_myaccount_page_id')) || is_page(get_option('woocommerce_edit_address_page_id')) || is_page(get_option('woocommerce_view_order_page_id')) || is_page(get_option('woocommerce_change_password_page_id')) ) return true; else return false;
return is_page(get_option('woocommerce_myaccount_page_id'));
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')) {

View File

@ -13,7 +13,7 @@
* 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'] == get_option('woocommerce_shop_page_id') ) :
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;
@ -26,7 +26,7 @@ function woocommerce_nav_menu_item_classes( $menu_items, $args ) {
if (!is_woocommerce()) return $menu_items;
$shop_page = (int) get_option('woocommerce_shop_page_id');
$shop_page = (int) woocommerce_get_page_id('shop');
$page_for_posts = (int) get_option( 'page_for_posts' );
foreach ( (array) $menu_items as $key => $menu_item ) :
@ -59,7 +59,7 @@ function woocommerce_nav_menu_item_classes( $menu_items, $args ) {
**/
function woocommerce_front_page_archive_paging_fix() {
if ( is_front_page() && is_page( get_option('woocommerce_shop_page_id') )) :
if ( is_front_page() && is_page( woocommerce_get_page_id('shop') )) :
if (get_query_var('paged')) :
$paged = get_query_var('paged');
@ -69,7 +69,7 @@ function woocommerce_front_page_archive_paging_fix() {
global $wp_query;
$wp_query->query( array( 'page_id' => get_option('woocommerce_shop_page_id'), 'is_paged' => true, 'paged' => $paged ) );
$wp_query->query( array( 'page_id' => woocommerce_get_page_id('shop'), 'is_paged' => true, 'paged' => $paged ) );
define('SHOP_IS_ON_FRONT', true);
@ -119,7 +119,7 @@ function woocommerce_list_pages($pages){
if (is_woocommerce()) {
$pages = str_replace( 'current_page_parent', '', $pages); // remove current_page_parent class from any item
$shop_page = 'page-item-' . get_option('woocommerce_shop_page_id'); // find shop_page_id through woocommerce options
$shop_page = 'page-item-' . woocommerce_get_page_id('shop'); // find shop_page_id through woocommerce options
if (is_shop()) :
$pages = str_replace($shop_page, $shop_page . ' current_page_item', $pages); // add current_page_item class to shop page
@ -134,7 +134,7 @@ function woocommerce_list_pages($pages){
* Add logout link to my account menu
**/
function woocommerce_nav_menu_items( $items, $args ) {
if ( get_option('woocommerce_menu_logout_link')=='yes' && strstr($items, get_permalink(get_option('woocommerce_myaccount_page_id'))) && is_user_logged_in() ) :
if ( get_option('woocommerce_menu_logout_link')=='yes' && strstr($items, get_permalink(woocommerce_get_page_id('myaccount'))) && is_user_logged_in() ) :
$items .= '<li><a href="'. wp_logout_url(home_url()) .'">'.__('Logout', 'woocommerce').'</a></li>';
endif;
@ -145,7 +145,7 @@ function woocommerce_nav_menu_items( $items, $args ) {
* Update catalog ordering if posted
*/
function woocommerce_update_catalog_ordering() {
if (isset($_POST['catalog_orderby']) && $_POST['catalog_orderby'] != '') $_SESSION['orderby'] = $_POST['catalog_orderby'];
if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] != '') $_SESSION['orderby'] = esc_attr($_REQUEST['orderby']);
}
/**
@ -220,12 +220,12 @@ function woocommerce_add_to_cart_action( $url = false ) {
if (empty($_POST['variation_id']) || !is_numeric($_POST['variation_id'])) :
$woocommerce->add_error( __('Please choose product options&hellip;', 'woocommerce') );
wp_safe_redirect(get_permalink($_GET['product']));
wp_safe_redirect(apply_filters('woocommerce_add_to_cart_product_id', get_permalink($_GET['product'])));
exit;
else :
$product_id = (int) $_GET['product'];
$product_id = (int) apply_filters('woocommerce_add_to_cart_product_id', $_GET['product']);
$variation_id = (int) $_POST['variation_id'];
$quantity = (isset($_POST['quantity'])) ? (int) $_POST['quantity'] : 1;
@ -348,7 +348,7 @@ function woocommerce_add_to_cart_message() {
function woocommerce_clear_cart_after_payment() {
global $woocommerce;
if (is_page(get_option('woocommerce_thanks_page_id'))) :
if (is_page(woocommerce_get_page_id('thanks'))) :
if (isset($_GET['order'])) $order_id = $_GET['order']; else $order_id = 0;
if (isset($_GET['key'])) $order_key = $_GET['key']; else $order_key = '';
@ -416,7 +416,7 @@ function woocommerce_process_login() {
exit;
endif;
wp_redirect(get_permalink(get_option('woocommerce_myaccount_page_id')));
wp_redirect(get_permalink(woocommerce_get_page_id('myaccount')));
exit;
endif;
@ -523,7 +523,7 @@ function woocommerce_process_registration() {
wp_safe_redirect( wp_get_referer() );
exit;
endif;
wp_redirect(get_permalink(get_option('woocommerce_myaccount_page_id')));
wp_redirect(get_permalink(woocommerce_get_page_id('myaccount')));
exit;
else :

View File

@ -9,6 +9,94 @@
* @author WooThemes
*/
/** Template pages ********************************************************/
if (!function_exists('woocommerce_content')) {
// This function is only used in the optional 'woocommerce.php' template
// people can add to their themes to add basic woocommerce support.
function woocommerce_content() {
global $woocommerce;
if ( is_single() && get_post_type() == 'product' )
woocommerce_single_product_content();
elseif ( is_tax('product_cat') )
woocommerce_product_taxonomy_content();
elseif ( is_tax('product_tag') )
woocommerce_product_taxonomy_content();
else
woocommerce_archive_product_content();
}
}
if (!function_exists('woocommerce_archive_product_content')) {
function woocommerce_archive_product_content() { ?>
<?php
$shop_page_id = woocommerce_get_page_id('shop');
$shop_page = get_post($shop_page_id);
$shop_page_title = (get_option('woocommerce_shop_page_title')) ? get_option('woocommerce_shop_page_title') : $shop_page->post_title;
?>
<?php if (is_search()) : ?>
<h1 class="page-title"><?php _e('Search Results:', 'woocommerce'); ?> &ldquo;<?php the_search_query(); ?>&rdquo; <?php if (get_query_var('paged')) echo ' &mdash; Page '.get_query_var('paged'); ?></h1>
<?php else : ?>
<h1 class="page-title"><?php echo apply_filters('the_title', $shop_page_title); ?></h1>
<?php endif; ?>
<?php echo apply_filters('the_content', $shop_page->post_content); ?>
<?php woocommerce_get_template_part( 'loop', 'shop' ); ?>
<?php do_action('woocommerce_pagination'); ?>
<?php }
}
if (!function_exists('woocommerce_product_taxonomy_content')) {
function woocommerce_product_taxonomy_content() {
global $wp_query; ?>
<?php $term = get_term_by( 'slug', get_query_var($wp_query->query_vars['taxonomy']), $wp_query->query_vars['taxonomy']); ?>
<h1 class="page-title"><?php echo wptexturize($term->name); ?></h1>
<?php if ($term->description) : ?><div class="term_description"><?php echo wpautop(wptexturize($term->description)); ?></div><?php endif; ?>
<?php woocommerce_get_template_part( 'loop', 'shop' ); ?>
<?php do_action('woocommerce_pagination'); ?>
<?php }
}
if (!function_exists('woocommerce_single_product_content')) {
function woocommerce_single_product_content() { ?>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<?php do_action('woocommerce_before_single_product'); ?>
<div itemscope itemtype="http://schema.org/Product" id="product-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php do_action('woocommerce_before_single_product_summary'); ?>
<div class="summary">
<h1 itemprop="name" class="product_title page-title"><?php the_title(); ?></h1>
<?php do_action( 'woocommerce_single_product_summary'); ?>
</div>
<?php do_action('woocommerce_after_single_product_summary'); ?>
</div>
<?php do_action('woocommerce_after_single_product'); ?>
<?php endwhile; ?>
<?php }
}
/** Global ****************************************************************/
if (!function_exists('woocommerce_output_content_wrapper')) {
@ -591,7 +679,7 @@ if (!function_exists('woocommerce_form_field')) {
if (isset( $states[$current_cc][$current_r] )) :
// Dropdown
$field .= '<select name="'.$key.'" id="'.$key.'"><option value="">'.__('Select a state&hellip;', 'woocommerce').'</option>';
$field .= '<select name="'.$key.'" id="'.$key.'" class="state_select"><option value="">'.__('Select a state&hellip;', 'woocommerce').'</option>';
foreach($states[$current_cc] as $ckey=>$cvalue) :
$field .= '<option value="'.$ckey.'" '.selected($current_r, $ckey, false).'>'.__($cvalue, 'woocommerce').'</option>';
endforeach;

View File

@ -137,7 +137,7 @@ class woocommerce {
add_filter( 'comments_template', array(&$this, 'comments_template_loader') );
add_action( 'init', array(&$this, 'include_template_functions'), 99 );
add_filter( 'wp_redirect', array(&$this, 'redirect'), 1, 2 );
add_action( 'template_redirect', array(&$this, 'frontend_scripts') );
add_action( 'wp_enqueue_scripts', array(&$this, 'frontend_scripts') );
add_action( 'wp_head', array(&$this, 'wp_head') );
add_filter( 'body_class', array(&$this, 'output_body_class') );
add_action( 'wp_footer', array(&$this, 'output_inline_js'), 25);
@ -226,6 +226,10 @@ class woocommerce {
*
* Templates are in the 'templates' folder. woocommerce looks for theme
* overides in /theme/woocommerce/ by default
*
* For beginners, it also looks for a woocommerce.php template first. If the user adds
* this to the theme (containing a woocommerce() inside) this will be used for all
* woocommerce templates.
*/
function template_loader( $template ) {
@ -235,13 +239,13 @@ class woocommerce {
$find = 'taxonomy-product_cat.php';
elseif ( is_tax('product_tag') )
$find = 'taxonomy-product_tag.php';
elseif ( is_post_type_archive('product') || is_page( get_option('woocommerce_shop_page_id') ))
elseif ( is_post_type_archive('product') || is_page( woocommerce_get_page_id('shop') ))
$find = 'archive-product.php';
else
$find = false;
if ($find) :
$template = locate_template( array( $find, $this->template_url . $find ) );
$template = locate_template( array( 'woocommerce.php', $find, $this->template_url . $find ) );
if ( ! $template ) $template = $this->plugin_path() . '/templates/' . $find;
endif;
@ -330,10 +334,10 @@ class woocommerce {
**/
function ssl_redirect() {
if (!is_ssl() && get_option('woocommerce_force_ssl_checkout')=='yes' && is_checkout()) :
wp_safe_redirect( str_replace('http:', 'https:', get_permalink(get_option('woocommerce_checkout_page_id'))), 301 );
wp_safe_redirect( str_replace('http:', 'https:', get_permalink(woocommerce_get_page_id('checkout'))), 301 );
exit;
// Break out of SSL if we leave the checkout (anywhere but thanks page)
elseif (is_ssl() && get_option('woocommerce_force_ssl_checkout')=='yes' && get_option('woocommerce_unforce_ssl_checkout')=='yes' && $_SERVER['REQUEST_URI'] && !is_checkout() && !is_page(get_option('woocommerce_thanks_page_id')) && !is_ajax()) :
elseif (is_ssl() && get_option('woocommerce_force_ssl_checkout')=='yes' && get_option('woocommerce_unforce_ssl_checkout')=='yes' && $_SERVER['REQUEST_URI'] && !is_checkout() && !is_page(woocommerce_get_page_id('thanks')) && !is_ajax()) :
wp_safe_redirect( str_replace('https:', 'http:', home_url($_SERVER['REQUEST_URI']) ) );
exit;
endif;
@ -355,7 +359,7 @@ class woocommerce {
if (is_account_page()) $this->add_body_class('woocommerce-account');
if (is_woocommerce() || is_checkout() || is_cart() || is_account_page() || is_page(get_option('woocommerce_order_tracking_page_id')) || is_page(get_option('woocommerce_thanks_page_id'))) $this->add_body_class('woocommerce-page');
if (is_woocommerce() || is_checkout() || is_cart() || is_account_page() || is_page(woocommerce_get_page_id('order_tracking')) || is_page(woocommerce_get_page_id('thanks'))) $this->add_body_class('woocommerce-page');
}
/**
@ -421,7 +425,7 @@ class woocommerce {
/**
* Slugs
**/
$shop_page_id = get_option('woocommerce_shop_page_id');
$shop_page_id = woocommerce_get_page_id('shop');
$base_slug = ($shop_page_id > 0 && get_page( $shop_page_id )) ? get_page_uri( $shop_page_id ) : 'shop';
@ -785,39 +789,27 @@ class woocommerce {
$chosen_en = (get_option('woocommerce_enable_chosen')=='yes') ? true : false;
$jquery_ui_en = (get_option('woocommerce_enable_jquery_ui')=='yes') ? true : false;
$scripts_position = (get_option('woocommerce_scripts_position') == 'yes') ? true : false;
wp_register_script( 'woocommerce', $this->plugin_url() . '/assets/js/woocommerce'.$suffix.'.js', 'jquery', '1.0', $scripts_position );
wp_register_script( 'woocommerce_plugins', $this->plugin_url() . '/assets/js/woocommerce_plugins'.$suffix.'.js', 'jquery', '1.0', $scripts_position );
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'woocommerce_plugins' );
wp_enqueue_script( 'woocommerce' );
// Woocommerce.min.js is minified and contains woocommerce_plugins
wp_enqueue_script( 'woocommerce', $this->plugin_url() . '/assets/js/woocommerce.min.js', array('jquery'), '1.0', $scripts_position );
if ($lightbox_en) :
wp_register_script( 'fancybox', $this->plugin_url() . '/assets/js/fancybox'.$suffix.'.js', 'jquery', '1.0', $scripts_position );
wp_enqueue_script( 'fancybox' );
endif;
if ($lightbox_en)
wp_enqueue_script( 'fancybox', $this->plugin_url() . '/assets/js/fancybox'.$suffix.'.js', array('jquery'), '1.0', $scripts_position );
if ($chosen_en && is_checkout()) :
wp_register_script( 'chosen', $this->plugin_url() . '/assets/js/chosen.jquery'.$suffix.'.js', array('jquery'), '1.0' );
wp_enqueue_script( 'chosen' );
endif;
if ($chosen_en && is_checkout())
wp_enqueue_script( 'chosen', $this->plugin_url() . '/assets/js/chosen.jquery'.$suffix.'.js', array('jquery'), '1.0' );
if ($jquery_ui_en) :
wp_register_script( 'jqueryui', $this->plugin_url() . '/assets/js/jquery-ui'.$suffix.'.js', 'jquery', '1.0', $scripts_position );
wp_register_script( 'wc_price_slider', $this->plugin_url() . '/assets/js/price_slider'.$suffix.'.js', 'jqueryui', '1.0', $scripts_position );
wp_enqueue_script( 'jqueryui' );
wp_enqueue_script( 'wc_price_slider' );
wp_enqueue_script( 'jqueryui', $this->plugin_url() . '/assets/js/jquery-ui'.$suffix.'.js', array('jquery'), '1.0', $scripts_position );
wp_enqueue_script( 'wc_price_slider', $this->plugin_url() . '/assets/js/price_slider'.$suffix.'.js', array('jqueryui'), '1.0', $scripts_position );
$woocommerce_price_slider_params = array(
'currency_symbol' => get_woocommerce_currency_symbol(),
'currency_pos' => get_option('woocommerce_currency_pos'),
'currency_symbol' => get_woocommerce_currency_symbol(),
'currency_pos' => get_option('woocommerce_currency_pos'),
'min_price' => isset($_SESSION['min_price']) ? $_SESSION['min_price'] : '',
'max_price' => isset($_SESSION['max_price']) ? $_SESSION['max_price'] : ''
);
if (isset($_SESSION['min_price'])) $woocommerce_price_slider_params['min_price'] = $_SESSION['min_price'];
if (isset($_SESSION['max_price'])) $woocommerce_price_slider_params['max_price'] = $_SESSION['max_price'];
wp_localize_script( 'wc_price_slider', 'woocommerce_price_slider_params', $woocommerce_price_slider_params );
endif;
@ -835,18 +827,16 @@ class woocommerce {
'update_shipping_method_nonce' => wp_create_nonce("update-shipping-method"),
'option_guest_checkout' => get_option('woocommerce_enable_guest_checkout'),
'checkout_url' => admin_url('admin-ajax.php?action=woocommerce-checkout'),
'option_ajax_add_to_cart' => get_option('woocommerce_enable_ajax_add_to_cart')
'option_ajax_add_to_cart' => get_option('woocommerce_enable_ajax_add_to_cart'),
'is_checkout' => ( is_page(woocommerce_get_page_id('checkout')) ) ? 1 : 0,
'is_pay_page' => ( is_page(woocommerce_get_page_id('pay')) ) ? 1 : 0,
'is_cart' => ( is_cart() ) ? 1 : 0
);
$woocommerce_params['is_checkout'] = ( is_page(get_option('woocommerce_checkout_page_id')) ) ? 1 : 0;
$woocommerce_params['is_pay_page'] = ( is_page(get_option('woocommerce_pay_page_id')) ) ? 1 : 0;
$woocommerce_params['is_cart'] = ( is_cart() ) ? 1 : 0;
if (is_checkout() || is_cart()) :
if (is_checkout() || is_cart())
$woocommerce_params['locale'] = json_encode( $this->countries->get_country_locale() );
endif;
wp_localize_script( 'woocommerce', 'woocommerce_params', $woocommerce_params );
wp_localize_script( 'woocommerce', 'woocommerce_params', apply_filters('woocommerce_params', $woocommerce_params) );
}
/** Load Instances on demand **********************************************/
@ -1010,7 +1000,7 @@ class woocommerce {
// IIS fix
if ($is_IIS) session_write_close();
return $location;
return apply_filters('woocommerce_redirect', $location);
}
/** Attribute Helpers ****************************************************************/