Merge remote-tracking branch 'woothemes/master'
This commit is contained in:
commit
f0671d6b91
File diff suppressed because one or more lines are too long
|
@ -1552,6 +1552,20 @@ p.demo_store {
|
|||
* Account page
|
||||
*/
|
||||
.woocommerce-account {
|
||||
.woocommerce {
|
||||
@include clearfix();
|
||||
}
|
||||
|
||||
.my-account-navigation {
|
||||
float: left;
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
.my-account-content {
|
||||
float: right;
|
||||
width: 68%;
|
||||
}
|
||||
|
||||
.addresses {
|
||||
.title {
|
||||
@include clearfix();
|
||||
|
@ -1923,7 +1937,7 @@ p.demo_store {
|
|||
}
|
||||
|
||||
/**
|
||||
* Password strength meter
|
||||
* Password strength meter
|
||||
*/
|
||||
.woocommerce-password-strength {
|
||||
text-align: center;
|
||||
|
|
|
@ -6,35 +6,237 @@ jQuery( function( $ ) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Shipping calculator
|
||||
$( document ).on( 'click', '.shipping-calculator-button', function() {
|
||||
$( '.shipping-calculator-form' ).slideToggle( 'slow' );
|
||||
return false;
|
||||
}).on( 'change', 'select.shipping_method, input[name^=shipping_method]', function() {
|
||||
var shipping_methods = [];
|
||||
// Gets a url for a given AJAX endpoint.
|
||||
var get_url = function( endpoint ) {
|
||||
return wc_cart_params.wc_ajax_url.toString().replace(
|
||||
'%%endpoint%%',
|
||||
endpoint
|
||||
);
|
||||
};
|
||||
|
||||
$( 'select.shipping_method, input[name^=shipping_method][type=radio]:checked, input[name^=shipping_method][type=hidden]' ).each( function() {
|
||||
shipping_methods[ $( this ).data( 'index' ) ] = $( this ).val();
|
||||
});
|
||||
// Check if a node is blocked for processing.
|
||||
var is_blocked = function( $node ) {
|
||||
return $node.is( '.processing' );
|
||||
};
|
||||
|
||||
$( 'div.cart_totals' ).block({
|
||||
// Block a node for processing.
|
||||
var block = function( $node ) {
|
||||
$node.addClass( 'processing' ).block( {
|
||||
message: null,
|
||||
overlayCSS: {
|
||||
background: '#fff',
|
||||
opacity: 0.6
|
||||
}
|
||||
});
|
||||
} );
|
||||
};
|
||||
|
||||
// Unblock a node after processing is complete.
|
||||
var unblock = function( $node ) {
|
||||
$node.removeClass( 'processing' ).unblock();
|
||||
};
|
||||
|
||||
// Updates the .woocommerce div with a string of html.
|
||||
var update_wc_div = function( html_str ) {
|
||||
var $html = $.parseHTML( html_str );
|
||||
var $new_div = $( 'div.woocommerce', $html );
|
||||
$( 'div.woocommerce' ).replaceWith( $new_div );
|
||||
};
|
||||
|
||||
// Shipping calculator
|
||||
$( document ).on( 'click', '.shipping-calculator-button', function() {
|
||||
$( '.shipping-calculator-form' ).slideToggle( 'slow' );
|
||||
return false;
|
||||
} ).on( 'change', 'select.shipping_method, input[name^=shipping_method]', function() {
|
||||
var shipping_methods = [];
|
||||
|
||||
$( 'select.shipping_method, input[name^=shipping_method][type=radio]:checked, input[name^=shipping_method][type=hidden]' ).each( function() {
|
||||
shipping_methods[ $( this ).data( 'index' ) ] = $( this ).val();
|
||||
} );
|
||||
|
||||
block( $( 'div.cart_totals' ) );
|
||||
|
||||
var data = {
|
||||
security: wc_cart_params.update_shipping_method_nonce,
|
||||
shipping_method: shipping_methods
|
||||
};
|
||||
|
||||
$.post( wc_cart_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'update_shipping_method' ), data, function( response ) {
|
||||
$.post( get_url( 'update_shipping_method' ), data, function( response ) {
|
||||
$( 'div.cart_totals' ).replaceWith( response );
|
||||
$( document.body ).trigger( 'updated_shipping_method' );
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
$( document ).on( 'submit', 'form.woocommerce-shipping-calculator', function( evt ) {
|
||||
evt.preventDefault();
|
||||
|
||||
var $form = $( evt.target );
|
||||
|
||||
block( $form );
|
||||
|
||||
// Provide the submit button value because wc-form-handler expects it.
|
||||
$( '<input />' ).attr( 'type', 'hidden' )
|
||||
.attr( 'name', 'calc_shipping' )
|
||||
.attr( 'value', 'x' )
|
||||
.appendTo( $form );
|
||||
|
||||
// Make call to actual form post URL.
|
||||
$.ajax( {
|
||||
type: $form.attr( 'method' ),
|
||||
url: $form.attr( 'action' ),
|
||||
data: $form.serialize(),
|
||||
dataType: 'html',
|
||||
success: function( response ) {
|
||||
update_wc_div(response );
|
||||
},
|
||||
complete: function() {
|
||||
unblock( $form );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
$( '.shipping-calculator-form' ).hide();
|
||||
});
|
||||
|
||||
// Update the cart after something has changed.
|
||||
var update_cart_totals = function() {
|
||||
block( $( 'div.cart_totals' ) );
|
||||
|
||||
$.ajax( {
|
||||
url: get_url( 'get_cart_totals' ),
|
||||
dataType: 'html',
|
||||
success: function( response ) {
|
||||
$( 'div.cart_totals' ).replaceWith( response );
|
||||
}
|
||||
} );
|
||||
};
|
||||
|
||||
// clears previous notices and shows new one above form.
|
||||
var show_notice = function( html_element ) {
|
||||
var $form = $( 'div.woocommerce > form' );
|
||||
|
||||
$( '.woocommerce-error, .woocommerce-message' ).remove();
|
||||
$form.before( html_element );
|
||||
};
|
||||
|
||||
// Handle form submit and route to correct logic.
|
||||
$( document ).on( 'submit', 'div.woocommerce > form', function( evt ) {
|
||||
evt.preventDefault();
|
||||
|
||||
var $form = $( evt.target );
|
||||
var $submit = $( document.activeElement );
|
||||
|
||||
window.console.log( $submit );
|
||||
|
||||
if ( is_blocked( $form ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $submit.is( '[name="update_cart"]' ) || $submit.is( 'input.qty' ) ) {
|
||||
window.console.log( 'update cart' );
|
||||
quantity_update( $form );
|
||||
|
||||
} else if ( $submit.is( '[name="apply_coupon"]' ) || $submit.is( '#coupon_code' ) ) {
|
||||
window.console.log( 'apply coupon' );
|
||||
apply_coupon( $form );
|
||||
}
|
||||
} );
|
||||
|
||||
// Coupon code
|
||||
var apply_coupon = function( $form ) {
|
||||
block( $form );
|
||||
|
||||
var $text_field = $( '#coupon_code' );
|
||||
var coupon_code = $text_field.val();
|
||||
|
||||
var data = {
|
||||
security: wc_cart_params.apply_coupon_nonce,
|
||||
coupon_code: coupon_code
|
||||
};
|
||||
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: get_url( 'apply_coupon' ),
|
||||
data: data,
|
||||
dataType: 'html',
|
||||
success: function( response ) {
|
||||
show_notice( response );
|
||||
},
|
||||
complete: function() {
|
||||
unblock( $form );
|
||||
$text_field.val( '' );
|
||||
update_cart_totals();
|
||||
}
|
||||
} );
|
||||
};
|
||||
|
||||
$( document ).on( 'click', 'a.woocommerce-remove-coupon', function( evt ) {
|
||||
evt.preventDefault();
|
||||
|
||||
var $tr = $( this ).parents( 'tr' );
|
||||
var coupon = $( this ).attr( 'data-coupon' );
|
||||
|
||||
block( $tr.parents( 'table' ) );
|
||||
|
||||
var data = {
|
||||
security: wc_cart_params.remove_coupon_nonce,
|
||||
coupon: coupon
|
||||
};
|
||||
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: get_url( 'remove_coupon' ),
|
||||
data: data,
|
||||
dataType: 'html',
|
||||
success: function( response ) {
|
||||
show_notice( response );
|
||||
unblock( $tr.parents( 'table' ) );
|
||||
},
|
||||
complete: function() {
|
||||
update_cart_totals();
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
// Quantity Update
|
||||
var quantity_update = function( $form ) {
|
||||
|
||||
// Provide the submit button value because wc-form-handler expects it.
|
||||
$( '<input />' ).attr( 'type', 'hidden' )
|
||||
.attr( 'name', 'update_cart' )
|
||||
.attr( 'value', 'Update Cart' )
|
||||
.appendTo( $form );
|
||||
|
||||
block( $form );
|
||||
|
||||
// Make call to actual form post URL.
|
||||
$.ajax( {
|
||||
type: $form.attr( 'method' ),
|
||||
url: $form.attr( 'action' ),
|
||||
data: $form.serialize(),
|
||||
dataType: 'html',
|
||||
success: update_wc_div,
|
||||
complete: function() {
|
||||
unblock( $form );
|
||||
}
|
||||
} );
|
||||
};
|
||||
|
||||
// Item Remove
|
||||
$( document ).on( 'click', 'td.product-remove > a', function( evt ) {
|
||||
evt.preventDefault();
|
||||
|
||||
var $a = $( evt.target );
|
||||
var $form = $a.parents( 'form' );
|
||||
|
||||
block( $form );
|
||||
|
||||
$.ajax( {
|
||||
type: 'GET',
|
||||
url: $a.attr( 'href' ),
|
||||
dataType: 'html',
|
||||
success: update_wc_div,
|
||||
complete: function() {
|
||||
unblock( $form );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
|
|
|
@ -1 +1 @@
|
|||
jQuery(function(a){return"undefined"==typeof wc_cart_params?!1:(a(document).on("click",".shipping-calculator-button",function(){return a(".shipping-calculator-form").slideToggle("slow"),!1}).on("change","select.shipping_method, input[name^=shipping_method]",function(){var b=[];a("select.shipping_method, input[name^=shipping_method][type=radio]:checked, input[name^=shipping_method][type=hidden]").each(function(){b[a(this).data("index")]=a(this).val()}),a("div.cart_totals").block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var c={security:wc_cart_params.update_shipping_method_nonce,shipping_method:b};a.post(wc_cart_params.wc_ajax_url.toString().replace("%%endpoint%%","update_shipping_method"),c,function(b){a("div.cart_totals").replaceWith(b),a(document.body).trigger("updated_shipping_method")})}),void a(".shipping-calculator-form").hide())});
|
||||
jQuery(function(a){if("undefined"==typeof wc_cart_params)return!1;var b=function(a){return wc_cart_params.wc_ajax_url.toString().replace("%%endpoint%%",a)},c=function(a){return a.is(".processing")},d=function(a){a.addClass("processing").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},e=function(a){a.removeClass("processing").unblock()},f=function(b){var c=a.parseHTML(b),d=a("div.woocommerce",c);a("div.woocommerce").replaceWith(d)};a(document).on("click",".shipping-calculator-button",function(){return a(".shipping-calculator-form").slideToggle("slow"),!1}).on("change","select.shipping_method, input[name^=shipping_method]",function(){var c=[];a("select.shipping_method, input[name^=shipping_method][type=radio]:checked, input[name^=shipping_method][type=hidden]").each(function(){c[a(this).data("index")]=a(this).val()}),d(a("div.cart_totals"));var e={security:wc_cart_params.update_shipping_method_nonce,shipping_method:c};a.post(b("update_shipping_method"),e,function(b){a("div.cart_totals").replaceWith(b),a(document.body).trigger("updated_shipping_method")})}),a(document).on("submit","form.woocommerce-shipping-calculator",function(b){b.preventDefault();var c=a(b.target);d(c),a("<input />").attr("type","hidden").attr("name","calc_shipping").attr("value","x").appendTo(c),a.ajax({type:c.attr("method"),url:c.attr("action"),data:c.serialize(),dataType:"html",success:function(a){f(a)},complete:function(){e(c)}})}),a(".shipping-calculator-form").hide();var g=function(){d(a("div.cart_totals")),a.ajax({url:b("get_cart_totals"),dataType:"html",success:function(b){a("div.cart_totals").replaceWith(b)}})},h=function(b){var c=a("div.woocommerce > form");a(".woocommerce-error, .woocommerce-message").remove(),c.before(b)};a(document).on("submit","div.woocommerce > form",function(b){b.preventDefault();var d=a(b.target),e=a(document.activeElement);return window.console.log(e),c(d)?!1:void(e.is('[name="update_cart"]')||e.is("input.qty")?(window.console.log("update cart"),j(d)):(e.is('[name="apply_coupon"]')||e.is("#coupon_code"))&&(window.console.log("apply coupon"),i(d)))});var i=function(c){d(c);var f=a("#coupon_code"),i=f.val(),j={security:wc_cart_params.apply_coupon_nonce,coupon_code:i};a.ajax({type:"POST",url:b("apply_coupon"),data:j,dataType:"html",success:function(a){h(a)},complete:function(){e(c),f.val(""),g()}})};a(document).on("click","a.woocommerce-remove-coupon",function(c){c.preventDefault();var f=a(this).parents("tr"),i=a(this).attr("data-coupon");d(f.parents("table"));var j={security:wc_cart_params.remove_coupon_nonce,coupon:i};a.ajax({type:"POST",url:b("remove_coupon"),data:j,dataType:"html",success:function(a){h(a),e(f.parents("table"))},complete:function(){g()}})});var j=function(b){a("<input />").attr("type","hidden").attr("name","update_cart").attr("value","Update Cart").appendTo(b),d(b),a.ajax({type:b.attr("method"),url:b.attr("action"),data:b.serialize(),dataType:"html",success:f,complete:function(){e(b)}})};a(document).on("click","td.product-remove > a",function(b){b.preventDefault();var c=a(b.target),g=c.parents("form");d(g),a.ajax({type:"GET",url:c.attr("href"),dataType:"html",success:f,complete:function(){e(g)}})})});
|
|
@ -57,6 +57,15 @@ class WC_Settings_Accounts extends WC_Settings_Page {
|
|||
|
||||
array( 'title' => __( 'My Account Endpoints', 'woocommerce' ), 'type' => 'title', 'desc' => __( 'Endpoints are appended to your page URLs to handle specific actions on the accounts pages. They should be unique.', 'woocommerce' ), 'id' => 'account_endpoint_options' ),
|
||||
|
||||
array(
|
||||
'title' => __( 'Orders', 'woocommerce' ),
|
||||
'desc' => __( 'Endpoint for the My Account → Orders page', 'woocommerce' ),
|
||||
'id' => 'woocommerce_myaccount_orders_endpoint',
|
||||
'type' => 'text',
|
||||
'default' => 'orders',
|
||||
'desc_tip' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'View Order', 'woocommerce' ),
|
||||
'desc' => __( 'Endpoint for the My Account → View Order page', 'woocommerce' ),
|
||||
|
@ -66,6 +75,15 @@ class WC_Settings_Accounts extends WC_Settings_Page {
|
|||
'desc_tip' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Downloads', 'woocommerce' ),
|
||||
'desc' => __( 'Endpoint for the My Account → Downloads page', 'woocommerce' ),
|
||||
'id' => 'woocommerce_myaccount_downloads_endpoint',
|
||||
'type' => 'text',
|
||||
'default' => 'downloads',
|
||||
'desc_tip' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Edit Account', 'woocommerce' ),
|
||||
'desc' => __( 'Endpoint for the My Account → Edit Account page', 'woocommerce' ),
|
||||
|
@ -84,6 +102,15 @@ class WC_Settings_Accounts extends WC_Settings_Page {
|
|||
'desc_tip' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Payment Methods', 'woocommerce' ),
|
||||
'desc' => __( 'Endpoint for the My Account → Payment Methods page', 'woocommerce' ),
|
||||
'id' => 'woocommerce_myaccount_payment_methods_endpoint',
|
||||
'type' => 'text',
|
||||
'default' => 'payment-methods',
|
||||
'desc_tip' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Lost Password', 'woocommerce' ),
|
||||
'desc' => __( 'Endpoint for the My Account → Lost Password page', 'woocommerce' ),
|
||||
|
|
|
@ -180,7 +180,7 @@ class WC_Settings_Shipping extends WC_Settings_Page {
|
|||
/**
|
||||
* Handles output of the shipping zones page in admin.
|
||||
*/
|
||||
private function output_zones_screen() {
|
||||
protected function output_zones_screen() {
|
||||
if ( isset( $_REQUEST['zone_id'] ) ) {
|
||||
$this->zone_methods_screen( absint( $_REQUEST['zone_id'] ) );
|
||||
} elseif ( isset( $_REQUEST['instance_id'] ) ) {
|
||||
|
@ -194,7 +194,7 @@ class WC_Settings_Shipping extends WC_Settings_Page {
|
|||
* Show method for a zone
|
||||
* @param int $zone_id
|
||||
*/
|
||||
private function zone_methods_screen( $zone_id ) {
|
||||
protected function zone_methods_screen( $zone_id ) {
|
||||
$wc_shipping = WC_Shipping ::instance();
|
||||
$zone = WC_Shipping_Zones::get_zone( $zone_id );
|
||||
$shipping_methods = $wc_shipping ->get_shipping_methods();
|
||||
|
@ -222,7 +222,7 @@ class WC_Settings_Shipping extends WC_Settings_Page {
|
|||
/**
|
||||
* Show zones
|
||||
*/
|
||||
private function zones_screen() {
|
||||
protected function zones_screen() {
|
||||
$allowed_countries = WC()->countries->get_allowed_countries();
|
||||
$continents = WC()->countries->get_continents();
|
||||
|
||||
|
@ -250,7 +250,7 @@ class WC_Settings_Shipping extends WC_Settings_Page {
|
|||
* Show instance settings
|
||||
* @param int $instance_id
|
||||
*/
|
||||
private function instance_settings_screen( $instance_id ) {
|
||||
protected function instance_settings_screen( $instance_id ) {
|
||||
$zone = WC_Shipping_Zones::get_zone_by( 'instance_id', $instance_id );
|
||||
$shipping_method = WC_Shipping_Zones::get_shipping_method( $instance_id );
|
||||
|
||||
|
@ -280,7 +280,7 @@ class WC_Settings_Shipping extends WC_Settings_Page {
|
|||
/**
|
||||
* Handles output of the shipping class settings screen.
|
||||
*/
|
||||
private function output_shipping_class_screen() {
|
||||
protected function output_shipping_class_screen() {
|
||||
$wc_shipping = WC_Shipping::instance();
|
||||
wp_localize_script( 'wc-shipping-classes', 'shippingClassesLocalizeScript', array(
|
||||
'classes' => $wc_shipping->get_shipping_classes(),
|
||||
|
|
|
@ -94,6 +94,7 @@ class WC_AJAX {
|
|||
'apply_coupon' => true,
|
||||
'remove_coupon' => true,
|
||||
'update_shipping_method' => true,
|
||||
'get_cart_totals' => true,
|
||||
'update_order_review' => true,
|
||||
'add_to_cart' => true,
|
||||
'checkout' => true,
|
||||
|
@ -254,6 +255,22 @@ class WC_AJAX {
|
|||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX receive updated cart_totals div.
|
||||
*/
|
||||
public static function get_cart_totals() {
|
||||
|
||||
if ( ! defined( 'WOOCOMMERCE_CART' ) ) {
|
||||
define( 'WOOCOMMERCE_CART', true );
|
||||
}
|
||||
|
||||
WC()->cart->calculate_totals();
|
||||
|
||||
woocommerce_cart_totals();
|
||||
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX update order review on checkout.
|
||||
*/
|
||||
|
|
|
@ -765,18 +765,22 @@ class WC_Checkout {
|
|||
}
|
||||
|
||||
// Get the billing_ and shipping_ address fields
|
||||
$address_fields = array_merge( WC()->countries->get_address_fields(), WC()->countries->get_address_fields( '', 'shipping_' ) );
|
||||
if ( isset( $this->checkout_fields['shipping'] ) && isset( $this->checkout_fields['billing'] ) ) {
|
||||
|
||||
if ( is_user_logged_in() && array_key_exists( $input, $address_fields ) ) {
|
||||
$current_user = wp_get_current_user();
|
||||
$address_fields = array_merge( $this->checkout_fields['billing'], $this->checkout_fields['shipping'] );
|
||||
|
||||
if ( $meta = get_user_meta( $current_user->ID, $input, true ) ) {
|
||||
return $meta;
|
||||
if ( is_user_logged_in() && is_array( $address_fields ) && array_key_exists( $input, $address_fields ) ) {
|
||||
$current_user = wp_get_current_user();
|
||||
|
||||
if ( $meta = get_user_meta( $current_user->ID, $input, true ) ) {
|
||||
return $meta;
|
||||
}
|
||||
|
||||
if ( $input == 'billing_email' ) {
|
||||
return $current_user->user_email;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $input == 'billing_email' ) {
|
||||
return $current_user->user_email;
|
||||
}
|
||||
}
|
||||
|
||||
switch ( $input ) {
|
||||
|
|
|
@ -289,6 +289,8 @@ class WC_Frontend_Scripts {
|
|||
'ajax_url' => WC()->ajax_url(),
|
||||
'wc_ajax_url' => WC_AJAX::get_endpoint( "%%endpoint%%" ),
|
||||
'update_shipping_method_nonce' => wp_create_nonce( "update-shipping-method" ),
|
||||
'apply_coupon_nonce' => wp_create_nonce( "apply-coupon" ),
|
||||
'remove_coupon_nonce' => wp_create_nonce( "remove-coupon" ),
|
||||
);
|
||||
break;
|
||||
case 'wc-cart-fragments' :
|
||||
|
|
|
@ -134,12 +134,11 @@ class WC_Product_Grouped extends WC_Product {
|
|||
$child_prices = array();
|
||||
|
||||
foreach ( $this->get_children() as $child_id ) {
|
||||
$child = wc_get_product( $child_id );
|
||||
$child_prices[] = $child->get_price();
|
||||
$child = wc_get_product( $child_id );
|
||||
$child_prices[] = 'incl' === $tax_display_mode ? $child->get_price_including_tax() : $child->get_price_excluding_tax();
|
||||
}
|
||||
|
||||
$child_prices = array_unique( $child_prices );
|
||||
$get_price_method = 'get_price_' . $tax_display_mode . 'uding_tax';
|
||||
|
||||
if ( ! empty( $child_prices ) ) {
|
||||
$min_price = min( $child_prices );
|
||||
|
@ -150,16 +149,11 @@ class WC_Product_Grouped extends WC_Product {
|
|||
}
|
||||
|
||||
if ( $min_price ) {
|
||||
if ( $min_price == $max_price ) {
|
||||
$display_price = wc_price( $this->$get_price_method( 1, $min_price ) );
|
||||
if ( $min_price === $max_price ) {
|
||||
$price = wc_price( $min_price ) . $this->get_price_suffix();
|
||||
} else {
|
||||
$from = wc_price( $this->$get_price_method( 1, $min_price ) );
|
||||
$to = wc_price( $this->$get_price_method( 1, $max_price ) );
|
||||
$display_price = sprintf( _x( '%1$s–%2$s', 'Price range: from-to', 'woocommerce' ), $from, $to );
|
||||
$price = sprintf( _x( '%1$s–%2$s', 'Price range: from-to', 'woocommerce' ), wc_price( $min_price ), wc_price( $max_price ) ) . $this->get_price_suffix();
|
||||
}
|
||||
|
||||
$price .= $display_price . $this->get_price_suffix();
|
||||
|
||||
$price = apply_filters( 'woocommerce_grouped_price_html', $price, $this );
|
||||
} else {
|
||||
$price = apply_filters( 'woocommerce_grouped_empty_price_html', '', $this );
|
||||
|
|
|
@ -376,68 +376,54 @@ class WC_Product_Variable extends WC_Product {
|
|||
* @return array of attributes and their available values
|
||||
*/
|
||||
public function get_variation_attributes() {
|
||||
global $wpdb;
|
||||
|
||||
$variation_attributes = array();
|
||||
$attributes = $this->get_attributes();
|
||||
$child_ids = $this->get_children( true );
|
||||
|
||||
if ( ! $this->has_child() ) {
|
||||
return $variation_attributes;
|
||||
}
|
||||
|
||||
$attributes = $this->get_attributes();
|
||||
|
||||
foreach ( $attributes as $attribute ) {
|
||||
if ( ! $attribute['is_variation'] ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$values = array();
|
||||
$attribute_field_name = 'attribute_' . sanitize_title( $attribute['name'] );
|
||||
|
||||
// Get used values from children variations
|
||||
foreach ( $this->get_children() as $child_id ) {
|
||||
$variation = $this->get_child( $child_id );
|
||||
|
||||
if ( ! empty( $variation->variation_id ) ) {
|
||||
if ( ! $variation->variation_is_visible() ) {
|
||||
continue; // Disabled or hidden
|
||||
}
|
||||
|
||||
$child_variation_attributes = $variation->get_variation_attributes();
|
||||
|
||||
if ( isset( $child_variation_attributes[ $attribute_field_name ] ) ) {
|
||||
$values[] = $child_variation_attributes[ $attribute_field_name ];
|
||||
}
|
||||
if ( ! empty( $child_ids ) ) {
|
||||
foreach ( $attributes as $attribute ) {
|
||||
if ( empty( $attribute['is_variation'] ) ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// empty value indicates that all options for given attribute are available
|
||||
if ( in_array( '', $values ) ) {
|
||||
$values = $attribute['is_taxonomy'] ? wp_get_post_terms( $this->id, $attribute['name'], array( 'fields' => 'slugs' ) ) : wc_get_text_attributes( $attribute['value'] );
|
||||
// Get possible values for this attribute, for only visible variations.
|
||||
$values = array_unique( $wpdb->get_col( $wpdb->prepare(
|
||||
"SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key = %s AND post_id IN (" . implode( ',', array_map( 'esc_sql', $child_ids ) ) . ")",
|
||||
wc_variation_attribute_name( $attribute['name'] )
|
||||
) ) );
|
||||
|
||||
// Get custom attributes (non taxonomy) as defined
|
||||
} elseif ( ! $attribute['is_taxonomy'] ) {
|
||||
$text_attributes = wc_get_text_attributes( $attribute['value'] );
|
||||
$assigned_text_attributes = $values;
|
||||
$values = array();
|
||||
// empty value indicates that all options for given attribute are available
|
||||
if ( in_array( '', $values ) ) {
|
||||
$values = $attribute['is_taxonomy'] ? wp_get_post_terms( $this->id, $attribute['name'], array( 'fields' => 'slugs' ) ) : wc_get_text_attributes( $attribute['value'] );
|
||||
|
||||
// Pre 2.4 handling where 'slugs' were saved instead of the full text attribute
|
||||
if ( version_compare( get_post_meta( $this->id, '_product_version', true ), '2.4.0', '<' ) ) {
|
||||
$assigned_text_attributes = array_map( 'sanitize_title', $assigned_text_attributes );
|
||||
// Get custom attributes (non taxonomy) as defined
|
||||
} elseif ( ! $attribute['is_taxonomy'] ) {
|
||||
$text_attributes = wc_get_text_attributes( $attribute['value'] );
|
||||
$assigned_text_attributes = $values;
|
||||
$values = array();
|
||||
|
||||
foreach ( $text_attributes as $text_attribute ) {
|
||||
if ( in_array( sanitize_title( $text_attribute ), $assigned_text_attributes ) ) {
|
||||
$values[] = $text_attribute;
|
||||
// Pre 2.4 handling where 'slugs' were saved instead of the full text attribute
|
||||
if ( version_compare( get_post_meta( $this->id, '_product_version', true ), '2.4.0', '<' ) ) {
|
||||
$assigned_text_attributes = array_map( 'sanitize_title', $assigned_text_attributes );
|
||||
|
||||
foreach ( $text_attributes as $text_attribute ) {
|
||||
if ( in_array( sanitize_title( $text_attribute ), $assigned_text_attributes ) ) {
|
||||
$values[] = $text_attribute;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ( $text_attributes as $text_attribute ) {
|
||||
if ( in_array( $text_attribute, $assigned_text_attributes ) ) {
|
||||
$values[] = $text_attribute;
|
||||
} else {
|
||||
foreach ( $text_attributes as $text_attribute ) {
|
||||
if ( in_array( $text_attribute, $assigned_text_attributes ) ) {
|
||||
$values[] = $text_attribute;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$variation_attributes[ $attribute['name'] ] = array_unique( $values );
|
||||
$variation_attributes[ $attribute['name'] ] = array_unique( $values );
|
||||
}
|
||||
}
|
||||
|
||||
return $variation_attributes;
|
||||
|
|
|
@ -60,16 +60,19 @@ class WC_Query {
|
|||
* Init query vars by loading options.
|
||||
*/
|
||||
public function init_query_vars() {
|
||||
// Query vars to add to WP
|
||||
// Query vars to add to WP.
|
||||
$this->query_vars = array(
|
||||
// Checkout actions
|
||||
// Checkout actions.
|
||||
'order-pay' => get_option( 'woocommerce_checkout_pay_endpoint', 'order-pay' ),
|
||||
'order-received' => get_option( 'woocommerce_checkout_order_received_endpoint', 'order-received' ),
|
||||
|
||||
// My account actions
|
||||
// My account actions.
|
||||
'orders' => get_option( 'woocommerce_myaccount_orders_endpoint', 'orders' ),
|
||||
'view-order' => get_option( 'woocommerce_myaccount_view_order_endpoint', 'view-order' ),
|
||||
'downloads' => get_option( 'woocommerce_myaccount_downloads_endpoint', 'downloads' ),
|
||||
'edit-account' => get_option( 'woocommerce_myaccount_edit_account_endpoint', 'edit-account' ),
|
||||
'edit-address' => get_option( 'woocommerce_myaccount_edit_address_endpoint', 'edit-address' ),
|
||||
'payment-methods' => get_option( 'woocommerce_myaccount_payment_methods_endpoint', 'payment-methods' ),
|
||||
'lost-password' => get_option( 'woocommerce_myaccount_lost_password_endpoint', 'lost-password' ),
|
||||
'customer-logout' => get_option( 'woocommerce_logout_endpoint', 'customer-logout' ),
|
||||
'add-payment-method' => get_option( 'woocommerce_myaccount_add_payment_method_endpoint', 'add-payment-method' ),
|
||||
|
@ -91,16 +94,29 @@ class WC_Query {
|
|||
case 'order-received' :
|
||||
$title = __( 'Order Received', 'woocommerce' );
|
||||
break;
|
||||
case 'orders' :
|
||||
if ( ! empty( $wp->query_vars['orders'] ) ) {
|
||||
$title = sprintf( __( 'Orders (page %d)', 'woocommerce' ), intval( $wp->query_vars['orders'] ) );
|
||||
} else {
|
||||
$title = __( 'Orders', 'woocommerce' );
|
||||
}
|
||||
break;
|
||||
case 'view-order' :
|
||||
$order = wc_get_order( $wp->query_vars['view-order'] );
|
||||
$title = ( $order ) ? sprintf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() ) : '';
|
||||
break;
|
||||
case 'downloads' :
|
||||
$title = __( 'Downloads', 'woocommerce' );
|
||||
break;
|
||||
case 'edit-account' :
|
||||
$title = __( 'Edit Account Details', 'woocommerce' );
|
||||
break;
|
||||
case 'edit-address' :
|
||||
$title = __( 'Edit Address', 'woocommerce' );
|
||||
break;
|
||||
case 'payment-methods' :
|
||||
$title = __( 'Payment Methods', 'woocommerce' );
|
||||
break;
|
||||
case 'add-payment-method' :
|
||||
$title = __( 'Add Payment Method', 'woocommerce' );
|
||||
break;
|
||||
|
@ -108,9 +124,10 @@ class WC_Query {
|
|||
$title = __( 'Lost Password', 'woocommerce' );
|
||||
break;
|
||||
default :
|
||||
$title = '';
|
||||
$title = apply_filters( 'woocommerce_endpoint_' . $endpoint . '_title', '' );
|
||||
break;
|
||||
}
|
||||
|
||||
return $title;
|
||||
}
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ class WC_Shipping_Zone implements WC_Data {
|
|||
}
|
||||
}
|
||||
|
||||
return $methods;
|
||||
return apply_filters( 'woocommerce_shipping_zone_shipping_methods', $methods, $raw_methods, $allowed_classes, $this );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -198,8 +198,9 @@ class WC_Shortcode_Checkout {
|
|||
|
||||
if ( $order_id > 0 ) {
|
||||
$order = wc_get_order( $order_id );
|
||||
if ( $order->order_key != $order_key )
|
||||
unset( $order );
|
||||
if ( $order->order_key != $order_key ) {
|
||||
$order = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Empty awaiting payment session
|
||||
|
|
|
@ -35,7 +35,6 @@ class WC_Shortcode_My_Account {
|
|||
}
|
||||
|
||||
if ( ! is_user_logged_in() ) {
|
||||
|
||||
$message = apply_filters( 'woocommerce_my_account_message', '' );
|
||||
|
||||
if ( ! empty( $message ) ) {
|
||||
|
@ -43,37 +42,23 @@ class WC_Shortcode_My_Account {
|
|||
}
|
||||
|
||||
if ( isset( $wp->query_vars['lost-password'] ) ) {
|
||||
|
||||
self::lost_password();
|
||||
|
||||
} else {
|
||||
|
||||
wc_get_template( 'myaccount/form-login.php' );
|
||||
|
||||
}
|
||||
|
||||
} else if (
|
||||
isset( $wp->query_vars['page'] ) // Regular page with shortcode.
|
||||
|| empty( $wp->query_vars ) // When My Account page is the front page.
|
||||
) {
|
||||
self::my_account( $atts );
|
||||
} else {
|
||||
foreach ( $wp->query_vars as $key => $value ) {
|
||||
// Ignore pagename param.
|
||||
if ( 'pagename' === $key ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ! empty( $wp->query_vars['view-order'] ) ) {
|
||||
|
||||
self::view_order( absint( $wp->query_vars['view-order'] ) );
|
||||
|
||||
} elseif ( isset( $wp->query_vars['edit-account'] ) ) {
|
||||
|
||||
self::edit_account();
|
||||
|
||||
} elseif ( isset( $wp->query_vars['edit-address'] ) ) {
|
||||
|
||||
self::edit_address( wc_edit_address_i18n( sanitize_title( $wp->query_vars['edit-address'] ), true ) );
|
||||
|
||||
} elseif ( isset( $wp->query_vars['add-payment-method'] ) ) {
|
||||
|
||||
self::add_payment_method();
|
||||
|
||||
} else {
|
||||
|
||||
self::my_account( $atts );
|
||||
|
||||
do_action( 'woocommerce_account_' . $key . '_endpoint', $value );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,28 +66,28 @@ class WC_Shortcode_My_Account {
|
|||
/**
|
||||
* My account page.
|
||||
*
|
||||
* @param array $atts
|
||||
* @param array $atts
|
||||
*/
|
||||
private static function my_account( $atts ) {
|
||||
extract( shortcode_atts( array(
|
||||
'order_count' => 15
|
||||
'order_count' => 15 // @deprecated 2.6.0. Keep for backward compatibility.
|
||||
), $atts ) );
|
||||
|
||||
wc_get_template( 'myaccount/my-account.php', array(
|
||||
'current_user' => get_user_by( 'id', get_current_user_id() ),
|
||||
'order_count' => 'all' == $order_count ? -1 : $order_count
|
||||
'current_user' => get_user_by( 'id', get_current_user_id() ),
|
||||
'order_count' => 'all' == $order_count ? -1 : $order_count
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* View order page.
|
||||
*
|
||||
* @param int $order_id
|
||||
* @param int $order_id
|
||||
*/
|
||||
private static function view_order( $order_id ) {
|
||||
public static function view_order( $order_id ) {
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
$order = wc_get_order( $order_id );
|
||||
$user_id = get_current_user_id();
|
||||
$order = wc_get_order( $order_id );
|
||||
|
||||
if ( ! current_user_can( 'view_order', $order_id ) ) {
|
||||
echo '<div class="woocommerce-error">' . __( 'Invalid order.', 'woocommerce' ) . ' <a href="' . wc_get_page_permalink( 'myaccount' ).'" class="wc-forward">'. __( 'My Account', 'woocommerce' ) .'</a>' . '</div>';
|
||||
|
@ -123,17 +108,16 @@ class WC_Shortcode_My_Account {
|
|||
/**
|
||||
* Edit account details page.
|
||||
*/
|
||||
private static function edit_account() {
|
||||
public static function edit_account() {
|
||||
wc_get_template( 'myaccount/form-edit-account.php', array( 'user' => get_user_by( 'id', get_current_user_id() ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit address page.
|
||||
*
|
||||
* @access public
|
||||
* @param string $load_address
|
||||
*/
|
||||
private static function edit_address( $load_address = 'billing' ) {
|
||||
public static function edit_address( $load_address = 'billing' ) {
|
||||
$current_user = wp_get_current_user();
|
||||
$load_address = sanitize_key( $load_address );
|
||||
|
||||
|
@ -204,7 +188,6 @@ class WC_Shortcode_My_Account {
|
|||
*
|
||||
* Based on retrieve_password() in core wp-login.php.
|
||||
*
|
||||
* @access public
|
||||
* @uses $wpdb WordPress Database object
|
||||
* @return bool True: when finish. False: on error
|
||||
*/
|
||||
|
@ -340,7 +323,7 @@ class WC_Shortcode_My_Account {
|
|||
/**
|
||||
* Show the add payment method page.
|
||||
*/
|
||||
private static function add_payment_method() {
|
||||
public static function add_payment_method() {
|
||||
|
||||
if ( ! is_user_logged_in() ) {
|
||||
|
||||
|
|
|
@ -0,0 +1,210 @@
|
|||
<?php
|
||||
/**
|
||||
* WooCommerce Account Functions
|
||||
*
|
||||
* Functions for account specific things.
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category Core
|
||||
* @package WooCommerce/Functions
|
||||
* @version 2.6.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the url to the lost password endpoint url.
|
||||
*
|
||||
* @access public
|
||||
* @param string $default_url
|
||||
* @return string
|
||||
*/
|
||||
function wc_lostpassword_url( $default_url = '' ) {
|
||||
$wc_password_reset_url = wc_get_page_permalink( 'myaccount' );
|
||||
|
||||
if ( false !== $wc_password_reset_url ) {
|
||||
return wc_get_endpoint_url( 'lost-password', '', $wc_password_reset_url );
|
||||
} else {
|
||||
return $default_url;
|
||||
}
|
||||
}
|
||||
|
||||
add_filter( 'lostpassword_url', 'wc_lostpassword_url', 10, 1 );
|
||||
|
||||
/**
|
||||
* Get the link to the edit account details page.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function wc_customer_edit_account_url() {
|
||||
$edit_account_url = wc_get_endpoint_url( 'edit-account', '', wc_get_page_permalink( 'myaccount' ) );
|
||||
|
||||
return apply_filters( 'woocommerce_customer_edit_account_url', $edit_account_url );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the edit address slug translation.
|
||||
*
|
||||
* @param string $id Address ID.
|
||||
* @param bool $flip Flip the array to make it possible to retrieve the values from both sides.
|
||||
*
|
||||
* @return string Address slug i18n.
|
||||
*/
|
||||
function wc_edit_address_i18n( $id, $flip = false ) {
|
||||
$slugs = apply_filters( 'woocommerce_edit_address_slugs', array(
|
||||
'billing' => sanitize_title( _x( 'billing', 'edit-address-slug', 'woocommerce' ) ),
|
||||
'shipping' => sanitize_title( _x( 'shipping', 'edit-address-slug', 'woocommerce' ) )
|
||||
) );
|
||||
|
||||
if ( $flip ) {
|
||||
$slugs = array_flip( $slugs );
|
||||
}
|
||||
|
||||
if ( ! isset( $slugs[ $id ] ) ) {
|
||||
return $id;
|
||||
}
|
||||
|
||||
return $slugs[ $id ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get My Account menu items.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @return array
|
||||
*/
|
||||
function wc_get_account_menu_items() {
|
||||
return apply_filters( 'woocommerce_account_menu_items', array(
|
||||
'dashboard' => __( 'Dashboard', 'woocommerce' ),
|
||||
'orders' => __( 'Orders', 'woocommerce' ),
|
||||
'downloads' => __( 'Downloads', 'woocommerce' ),
|
||||
'edit-address' => __( 'Addresses', 'woocommerce' ),
|
||||
'payment-methods' => __( 'Payment Methods', 'woocommerce' ),
|
||||
'edit-account' => __( 'Account Details', 'woocommerce' ),
|
||||
'customer-logout' => __( 'Logout', 'woocommerce' ),
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get account menu item classes.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @param string $endpoint
|
||||
* @return string
|
||||
*/
|
||||
function wc_get_account_menu_item_classes( $endpoint ) {
|
||||
global $wp;
|
||||
|
||||
$classes = array(
|
||||
'my-account-menu-item-' . $endpoint,
|
||||
);
|
||||
|
||||
// Set current item class.
|
||||
$current = isset( $wp->query_vars[ $endpoint ] );
|
||||
if ( 'dashboard' === $endpoint && ( isset( $wp->query_vars['page'] ) || empty( $wp->query_vars ) ) ) {
|
||||
$current = true; // Dashboard is not an endpoint, so needs a custom check.
|
||||
}
|
||||
|
||||
if ( $current ) {
|
||||
$classes[] = 'current-item';
|
||||
}
|
||||
|
||||
$classes = apply_filters( 'woocommerce_account_menu_item_classes', $classes, $endpoint );
|
||||
|
||||
return implode( ' ', array_map( 'sanitize_html_class', $classes ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get account endpoint URL.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @param string $endpoint
|
||||
* @return string
|
||||
*/
|
||||
function wc_get_account_endpoint_url( $endpoint ) {
|
||||
if ( 'dashboard' === $endpoint ) {
|
||||
return wc_get_page_permalink( 'myaccount' );
|
||||
}
|
||||
|
||||
return wc_get_endpoint_url( $endpoint );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get My Account > Orders columns.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @return array
|
||||
*/
|
||||
function wc_get_account_orders_columns() {
|
||||
$columns = apply_filters( 'woocommerce_account_orders_columns', array(
|
||||
'order-number' => __( 'Order', 'woocommerce' ),
|
||||
'order-date' => __( 'Date', 'woocommerce' ),
|
||||
'order-status' => __( 'Status', 'woocommerce' ),
|
||||
'order-total' => __( 'Total', 'woocommerce' ),
|
||||
'order-actions' => ' ',
|
||||
) );
|
||||
|
||||
// Deprecated filter since 2.6.0.
|
||||
return apply_filters( 'woocommerce_my_account_my_orders_columns', $columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get My Account > Orders query args.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @param int $current_page
|
||||
* @return array
|
||||
*/
|
||||
function wc_get_account_orders_query_args( $current_page = 1 ) {
|
||||
$args = array(
|
||||
'numberposts' => 15,
|
||||
'meta_key' => '_customer_user',
|
||||
'meta_value' => get_current_user_id(),
|
||||
'post_type' => wc_get_order_types( 'view-orders' ),
|
||||
'post_status' => array_keys( wc_get_order_statuses() ),
|
||||
);
|
||||
|
||||
// @deprecated 2.6.0.
|
||||
$args = apply_filters( 'woocommerce_my_account_my_orders_query', $args );
|
||||
|
||||
// Remove deprecated option.
|
||||
$args['posts_per_page'] = $args['numberposts'];
|
||||
unset( $args['numberposts'] );
|
||||
|
||||
if ( 1 < $current_page ) {
|
||||
$args['paged'] = absint( $current_page );
|
||||
}
|
||||
|
||||
return apply_filters( 'woocommerce_account_orders_query', $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get My Account > Downloads columns.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @return array
|
||||
*/
|
||||
function wc_get_account_downloads_columns() {
|
||||
return apply_filters( 'woocommerce_account_downloads_columns', array(
|
||||
'download-file' => __( 'File', 'woocommerce' ),
|
||||
'download-remaining' => __( 'Remaining', 'woocommerce' ),
|
||||
'download-expires' => __( 'Expires', 'woocommerce' ),
|
||||
'download-actions' => ' ',
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get My Account > Payment methods columns.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @return array
|
||||
*/
|
||||
function wc_get_account_payment_methods_columns() {
|
||||
return apply_filters( 'woocommerce_account_payment_methods_columns', array(
|
||||
'method' => __( 'Method', 'woocommerce' ),
|
||||
'expires' => __( 'Expires', 'woocommerce' ),
|
||||
'actions' => ' ',
|
||||
) );
|
||||
}
|
|
@ -49,6 +49,17 @@ function wc_attribute_taxonomy_name( $attribute_name ) {
|
|||
return 'pa_' . wc_sanitize_taxonomy_name( $attribute_name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attribute name used when storing values in post meta.
|
||||
*
|
||||
* @param string $attribute_name Attribute name.
|
||||
* @since 2.6.0
|
||||
* @return string
|
||||
*/
|
||||
function wc_variation_attribute_name( $attribute_name ) {
|
||||
return 'attribute_' . sanitize_title( $attribute_name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a product attribute name by ID.
|
||||
*
|
||||
|
|
|
@ -23,6 +23,7 @@ include( 'wc-formatting-functions.php' );
|
|||
include( 'wc-order-functions.php' );
|
||||
include( 'wc-page-functions.php' );
|
||||
include( 'wc-product-functions.php' );
|
||||
include( 'wc-account-functions.php' );
|
||||
include( 'wc-term-functions.php' );
|
||||
include( 'wc-attribute-functions.php' );
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
*
|
||||
* Functions related to pages and menus.
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category Core
|
||||
* @package WooCommerce/Functions
|
||||
* @version 2.1.0
|
||||
* @author WooThemes
|
||||
* @category Core
|
||||
* @package WooCommerce/Functions
|
||||
* @version 2.6.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
|
@ -107,60 +107,6 @@ function wc_get_endpoint_url( $endpoint, $value = '', $permalink = '' ) {
|
|||
return apply_filters( 'woocommerce_get_endpoint_url', $url, $endpoint, $value, $permalink );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the edit address slug translation.
|
||||
*
|
||||
* @param string $id Address ID.
|
||||
* @param bool $flip Flip the array to make it possible to retrieve the values from both sides.
|
||||
*
|
||||
* @return string Address slug i18n.
|
||||
*/
|
||||
function wc_edit_address_i18n( $id, $flip = false ) {
|
||||
$slugs = apply_filters( 'woocommerce_edit_address_slugs', array(
|
||||
'billing' => sanitize_title( _x( 'billing', 'edit-address-slug', 'woocommerce' ) ),
|
||||
'shipping' => sanitize_title( _x( 'shipping', 'edit-address-slug', 'woocommerce' ) )
|
||||
) );
|
||||
|
||||
if ( $flip ) {
|
||||
$slugs = array_flip( $slugs );
|
||||
}
|
||||
|
||||
if ( ! isset( $slugs[ $id ] ) ) {
|
||||
return $id;
|
||||
}
|
||||
|
||||
return $slugs[ $id ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the url to the lost password endpoint url.
|
||||
*
|
||||
* @access public
|
||||
* @param string $default_url
|
||||
* @return string
|
||||
*/
|
||||
function wc_lostpassword_url( $default_url = '' ) {
|
||||
$wc_password_reset_url = wc_get_page_permalink( 'myaccount' );
|
||||
|
||||
if ( false !== $wc_password_reset_url ) {
|
||||
return wc_get_endpoint_url( 'lost-password', '', $wc_password_reset_url );
|
||||
} else {
|
||||
return $default_url;
|
||||
}
|
||||
}
|
||||
add_filter( 'lostpassword_url', 'wc_lostpassword_url', 10, 1 );
|
||||
|
||||
/**
|
||||
* Get the link to the edit account details page.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function wc_customer_edit_account_url() {
|
||||
$edit_account_url = wc_get_endpoint_url( 'edit-account', '', wc_get_page_permalink( 'myaccount' ) );
|
||||
|
||||
return apply_filters( 'woocommerce_customer_edit_account_url', $edit_account_url );
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide menu items conditionally.
|
||||
*
|
||||
|
|
|
@ -202,23 +202,22 @@ function wc_get_featured_product_ids() {
|
|||
/**
|
||||
* Filter to allow product_cat in the permalinks for products.
|
||||
*
|
||||
* @access public
|
||||
* @param string $permalink The existing permalink URL.
|
||||
* @param WP_Post $post
|
||||
* @param string $permalink The existing permalink URL.
|
||||
* @param WP_Post $post
|
||||
* @return string
|
||||
*/
|
||||
function wc_product_post_type_link( $permalink, $post ) {
|
||||
// Abort if post is not a product
|
||||
// Abort if post is not a product.
|
||||
if ( $post->post_type !== 'product' ) {
|
||||
return $permalink;
|
||||
}
|
||||
|
||||
// Abort early if the placeholder rewrite tag isn't in the generated URL
|
||||
// Abort early if the placeholder rewrite tag isn't in the generated URL.
|
||||
if ( false === strpos( $permalink, '%' ) ) {
|
||||
return $permalink;
|
||||
}
|
||||
|
||||
// Get the custom taxonomy terms in use by this post
|
||||
// Get the custom taxonomy terms in use by this post.
|
||||
$terms = get_the_terms( $post->ID, 'product_cat' );
|
||||
|
||||
if ( ! empty( $terms ) ) {
|
||||
|
@ -228,7 +227,7 @@ function wc_product_post_type_link( $permalink, $post ) {
|
|||
$category_object = get_term( $category_object, 'product_cat' );
|
||||
$product_cat = $category_object->slug;
|
||||
|
||||
if ( $parent = $category_object->parent ) {
|
||||
if ( $category_object->parent ) {
|
||||
$ancestors = get_ancestors( $category_object->term_id, 'product_cat' );
|
||||
foreach ( $ancestors as $ancestor ) {
|
||||
$ancestor_object = get_term( $ancestor, 'product_cat' );
|
||||
|
|
|
@ -2023,5 +2023,84 @@ if ( ! function_exists( 'wc_dropdown_variation_attribute_options' ) ) {
|
|||
|
||||
echo apply_filters( 'woocommerce_dropdown_variation_attribute_options_html', $html, $args );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'woocommerce_account_orders' ) ) {
|
||||
|
||||
/**
|
||||
* My Account > Orders template.
|
||||
*
|
||||
* @param int $current_page Current page number.
|
||||
*/
|
||||
function woocommerce_account_orders( $current_page ) {
|
||||
$current_page = empty( $current_page ) ? 1 : $current_page;
|
||||
|
||||
wc_get_template( 'myaccount/orders.php', array( 'current_page' => absint( $current_page ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'woocommerce_account_view_order' ) ) {
|
||||
|
||||
/**
|
||||
* My Account > View order template.
|
||||
*
|
||||
* @param int $order_id Order ID.
|
||||
*/
|
||||
function woocommerce_account_view_order( $order_id ) {
|
||||
WC_Shortcode_My_Account::view_order( absint( $order_id ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'woocommerce_account_downloads' ) ) {
|
||||
|
||||
/**
|
||||
* My Account > Downloads template.
|
||||
*/
|
||||
function woocommerce_account_downloads() {
|
||||
wc_get_template( 'myaccount/downloads.php' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'woocommerce_account_edit_address' ) ) {
|
||||
|
||||
/**
|
||||
* My Account > Edit address template.
|
||||
*
|
||||
* @param string $type Address type.
|
||||
*/
|
||||
function woocommerce_account_edit_address( $type ) {
|
||||
$type = wc_edit_address_i18n( sanitize_title( $type ), true );
|
||||
|
||||
WC_Shortcode_My_Account::edit_address( $type );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'woocommerce_account_payment_methods' ) ) {
|
||||
|
||||
/**
|
||||
* My Account > Downloads template.
|
||||
*/
|
||||
function woocommerce_account_payment_methods() {
|
||||
wc_get_template( 'myaccount/payment-methods.php' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'woocommerce_account_add_payment_method' ) ) {
|
||||
|
||||
/**
|
||||
* My Account > Add payment method template.
|
||||
*/
|
||||
function woocommerce_account_add_payment_method() {
|
||||
WC_Shortcode_My_Account::add_payment_method();
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'woocommerce_account_edit_account' ) ) {
|
||||
|
||||
/**
|
||||
* My Account > Edit account template.
|
||||
*/
|
||||
function woocommerce_account_edit_account() {
|
||||
WC_Shortcode_My_Account::edit_account();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -239,3 +239,14 @@ add_action( 'woocommerce_auth_page_footer', 'woocommerce_output_auth_footer', 10
|
|||
* Disable Jetpack comments.
|
||||
*/
|
||||
add_filter( 'jetpack_comment_form_enabled_for_product', '__return_false' );
|
||||
|
||||
/**
|
||||
* My Account.
|
||||
*/
|
||||
add_action( 'woocommerce_account_orders_endpoint', 'woocommerce_account_orders' );
|
||||
add_action( 'woocommerce_account_view-order_endpoint', 'woocommerce_account_view_order' );
|
||||
add_action( 'woocommerce_account_downloads_endpoint', 'woocommerce_account_downloads' );
|
||||
add_action( 'woocommerce_account_edit-address_endpoint', 'woocommerce_account_edit_address' );
|
||||
add_action( 'woocommerce_account_payment-methods_endpoint', 'woocommerce_account_payment_methods' );
|
||||
add_action( 'woocommerce_account_add-payment-method_endpoint', 'woocommerce_account_add_payment_method' );
|
||||
add_action( 'woocommerce_account_edit-account_endpoint', 'woocommerce_account_edit_account' );
|
||||
|
|
|
@ -585,9 +585,9 @@ add_action( 'template_redirect', 'wc_disable_author_archives_for_customers' );
|
|||
/**
|
||||
* Hooks into the `profile_update` hook to set the user last updated timestamp.
|
||||
*
|
||||
* @since 2.6
|
||||
* @param int $user_id The user that was updated
|
||||
* @param array $old The profile fields pre-change
|
||||
* @since 2.6.0
|
||||
* @param int $user_id The user that was updated.
|
||||
* @param array $old The profile fields pre-change.
|
||||
*/
|
||||
function wc_update_profile_last_update_time( $user_id, $old ) {
|
||||
wc_set_user_last_update_time( $user_id );
|
||||
|
@ -598,11 +598,11 @@ add_action( 'profile_update', 'wc_update_profile_last_update_time', 10, 2 );
|
|||
/**
|
||||
* Hooks into the update user meta function to set the user last updated timestamp.
|
||||
*
|
||||
* @since 2.6
|
||||
* @param int $meta_id ID of the meta object that was changed
|
||||
* @param int $user_id The user that was updated
|
||||
* @param string $meta_key Name of the meta key that was changed
|
||||
* @param string $_meta_value Value of the meta that was changed
|
||||
* @since 2.6.0
|
||||
* @param int $meta_id ID of the meta object that was changed.
|
||||
* @param int $user_id The user that was updated.
|
||||
* @param string $meta_key Name of the meta key that was changed.
|
||||
* @param string $_meta_value Value of the meta that was changed.
|
||||
*/
|
||||
function wc_meta_update_last_update_time( $meta_id, $user_id, $meta_key, $_meta_value ) {
|
||||
$keys_to_track = apply_filters( 'woocommerce_user_last_update_fields', array( 'first_name', 'last_name' ) );
|
||||
|
@ -627,9 +627,20 @@ add_action( 'update_user_meta', 'wc_meta_update_last_update_time', 10, 4 );
|
|||
/**
|
||||
* Sets a user's "last update" time to the current timestamp.
|
||||
*
|
||||
* @since 2.6
|
||||
* @param int $user_id The user to set a timestamp for
|
||||
* @since 2.6.0
|
||||
* @param int $user_id The user to set a timestamp for.
|
||||
*/
|
||||
function wc_set_user_last_update_time( $user_id ) {
|
||||
update_user_meta( $user_id, 'last_update', time() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get customer saved payment methods list.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @param int $customer_id
|
||||
* @return array
|
||||
*/
|
||||
function wc_get_customer_saved_methods_list( $customer_id ) {
|
||||
return apply_filters( 'woocommerce_saved_payment_methods_list', array(), $customer_id );
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
=== WooCommerce ===
|
||||
Contributors: automattic, mikejolley, jameskoster, claudiosanches, royho, woothemes
|
||||
Contributors: automattic, mikejolley, jameskoster, claudiosanches, jshreve, coderkevin, woothemes
|
||||
Tags: ecommerce, e-commerce, store, sales, sell, shop, cart, checkout, downloadable, downloads, paypal, storefront
|
||||
Requires at least: 4.1
|
||||
Tested up to: 4.4
|
||||
|
@ -162,6 +162,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
|
|||
* Dev - Made coupon optional in cart has_discount() method.
|
||||
* Tweak - Removed tag/cat classes from loops since WP does the same.
|
||||
* Tweak - Added hash check for orders so that if the cart changes before payment, a new order is made.
|
||||
* Feature - Cart operations now use ajax (item quantities/remove, coupon apply/remove, shipping options)
|
||||
|
||||
[See changelog for all versions](https://raw.githubusercontent.com/woothemes/woocommerce/master/CHANGELOG.txt).
|
||||
|
||||
|
|
|
@ -35,12 +35,10 @@ if ( ! woocommerce_products_will_display() )
|
|||
$first = ( $per_page * $paged ) - $per_page + 1;
|
||||
$last = min( $total, $wp_query->get( 'posts_per_page' ) * $paged );
|
||||
|
||||
if ( 1 === $total ) {
|
||||
_e( 'Showing the single result', 'woocommerce' );
|
||||
} elseif ( $total <= $per_page || -1 === $per_page ) {
|
||||
printf( __( 'Showing all %d results', 'woocommerce' ), $total );
|
||||
if ( $total <= $per_page || -1 === $per_page ) {
|
||||
printf( _n( 'Showing the single result', 'Showing all %d results', $total, 'woocommerce' ), $total );
|
||||
} else {
|
||||
printf( _x( 'Showing %1$d–%2$d of %3$d results', '%1$d = first, %2$d = last, %3$d = total', 'woocommerce' ), $first, $last, $total );
|
||||
printf( _nx( 'Showing the single result', 'Showing %1$d–%2$d of %3$d results', $total, '%1$d = first, %2$d = last, %3$d = total', 'woocommerce' ), $first, $last, $total );
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
/**
|
||||
* Downloads
|
||||
*
|
||||
* Shows downloads on the account page.
|
||||
*
|
||||
* This template can be overridden by copying it to yourtheme/woocommerce/myaccount/downloads.php.
|
||||
*
|
||||
* HOWEVER, on occasion WooCommerce will need to update template files and you
|
||||
* (the theme developer) will need to copy the new files to your theme to
|
||||
* maintain compatibility. We try to do this as little as possible, but it does
|
||||
* happen. When this occurs the version of the template file will be bumped and
|
||||
* the readme will list any important changes.
|
||||
*
|
||||
* @see http://docs.woothemes.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.6.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$downloads = WC()->customer->get_downloadable_products();
|
||||
$has_downloads = (bool) $downloads;
|
||||
|
||||
wc_print_notices(); ?>
|
||||
|
||||
<?php wc_get_template( 'myaccount/navigation.php' ); ?>
|
||||
|
||||
<div class="my-account-content">
|
||||
|
||||
<?php do_action( 'woocommerce_before_account_downloads', $has_downloads ); ?>
|
||||
|
||||
<?php if ( $has_downloads ) : ?>
|
||||
|
||||
<?php do_action( 'woocommerce_before_available_downloads' ); ?>
|
||||
|
||||
<table class="shop_table shop_table_responsive account-downloads-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php foreach ( wc_get_account_downloads_columns() as $column_id => $column_name ) : ?>
|
||||
<th class="<?php echo esc_attr( $column_id ); ?>"><span class="nobr"><?php echo esc_html( $column_name ); ?></span></th>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<?php foreach ( $downloads as $download ) : ?>
|
||||
<tr class="download">
|
||||
<?php foreach ( wc_get_account_downloads_columns() as $column_id => $column_name ) : ?>
|
||||
<td class="<?php echo esc_attr( $column_id ); ?>" data-title="<?php echo esc_attr( $column_name ); ?>">
|
||||
<?php if ( has_action( 'woocommerce_account_downloads_column_' . $column_id ) ) : ?>
|
||||
<?php do_action( 'woocommerce_account_downloads_column_' . $column_id, $download ); ?>
|
||||
|
||||
<?php elseif ( 'download-file' === $column_id ) : ?>
|
||||
<a href="<?php echo esc_url( get_permalink( $download['product_id'] ) ); ?>">
|
||||
<?php echo esc_html( $download['download_name'] ); ?>
|
||||
</a>
|
||||
|
||||
<?php elseif ( 'download-remaining' === $column_id ) : ?>
|
||||
<?php
|
||||
if ( is_numeric( $download['downloads_remaining'] ) ) {
|
||||
echo esc_html( $download['downloads_remaining'] );
|
||||
} else {
|
||||
_e( '∞', 'woocommerce' );
|
||||
}
|
||||
?>
|
||||
|
||||
<?php elseif ( 'download-expires' === $column_id ) : ?>
|
||||
<?php if ( ! empty( $download['access_expires'] ) ) : ?>
|
||||
<time datetime="<?php echo date( 'Y-m-d', strtotime( $download['access_expires'] ) ); ?>" title="<?php echo esc_attr( strtotime( $download['access_expires'] ) ); ?>"><?php echo date_i18n( get_option( 'date_format' ), strtotime( $download['access_expires'] ) ); ?></time>
|
||||
<?php else : ?>
|
||||
<?php _e( 'Never', 'woocommerce' ); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php elseif ( 'download-actions' === $column_id ) : ?>
|
||||
<?php
|
||||
$actions = array(
|
||||
'download' => array(
|
||||
'url' => $download['download_url'],
|
||||
'name' => __( 'Download', 'woocommerce' )
|
||||
)
|
||||
);
|
||||
|
||||
if ( $actions = apply_filters( 'woocommerce_account_download_actions', $actions, $download ) ) {
|
||||
foreach ( $actions as $key => $action ) {
|
||||
echo '<a href="' . esc_url( $action['url'] ) . '" class="button ' . sanitize_html_class( $key ) . '">' . esc_html( $action['name'] ) . '</a>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
<?php do_action( 'woocommerce_after_available_downloads' ); ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php do_action( 'woocommerce_after_account_downloads', $has_downloads ); ?>
|
||||
</div>
|
|
@ -10,49 +10,55 @@
|
|||
* happen. When this occurs the version of the template file will be bumped and
|
||||
* the readme will list any important changes.
|
||||
*
|
||||
* @see http://docs.woothemes.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.1
|
||||
* @see http://docs.woothemes.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.6.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
<form id="add_payment_method" method="post">
|
||||
<div id="payment">
|
||||
<?php if ( $available_gateways = WC()->payment_gateways->get_available_payment_gateways() ) : ?>
|
||||
<ul class="payment_methods methods"><?php
|
||||
// Chosen Method
|
||||
if ( sizeof( $available_gateways ) ) {
|
||||
current( $available_gateways )->set_current();
|
||||
}
|
||||
wc_get_template( 'myaccount/navigation.php' ); ?>
|
||||
|
||||
foreach ( $available_gateways as $gateway ) {
|
||||
?>
|
||||
<li class="payment_method_<?php echo $gateway->id; ?>">
|
||||
<input id="payment_method_<?php echo $gateway->id; ?>" type="radio" class="input-radio" name="payment_method" value="<?php echo esc_attr( $gateway->id ); ?>" <?php checked( $gateway->chosen, true ); ?> />
|
||||
<label for="payment_method_<?php echo $gateway->id; ?>"><?php echo $gateway->get_title(); ?> <?php echo $gateway->get_icon(); ?></label>
|
||||
<?php
|
||||
if ( $gateway->has_fields() || $gateway->get_description() ) {
|
||||
echo '<div class="payment_box payment_method_' . $gateway->id . '" style="display:none;">';
|
||||
$gateway->payment_fields();
|
||||
echo '</div>';
|
||||
}
|
||||
?>
|
||||
</li>
|
||||
<div class="my-account-content">
|
||||
<?php if ( $available_gateways = WC()->payment_gateways->get_available_payment_gateways() ) : ?>
|
||||
<form id="add_payment_method" method="post">
|
||||
<div id="payment">
|
||||
<ul class="payment_methods methods">
|
||||
<?php
|
||||
}
|
||||
?></ul>
|
||||
<div class="form-row">
|
||||
<?php wp_nonce_field( 'woocommerce-add-payment-method' ); ?>
|
||||
<input type="submit" class="button alt" id="place_order" value="<?php esc_attr_e( 'Add Payment Method', 'woocommerce' ); ?>" />
|
||||
<input type="hidden" name="woocommerce_add_payment_method" value="1" />
|
||||
// Chosen Method.
|
||||
if ( count( $available_gateways ) ) {
|
||||
current( $available_gateways )->set_current();
|
||||
}
|
||||
|
||||
foreach ( $available_gateways as $gateway ) {
|
||||
?>
|
||||
<li class="payment_method_<?php echo $gateway->id; ?>">
|
||||
<input id="payment_method_<?php echo $gateway->id; ?>" type="radio" class="input-radio" name="payment_method" value="<?php echo esc_attr( $gateway->id ); ?>" <?php checked( $gateway->chosen, true ); ?> />
|
||||
<label for="payment_method_<?php echo $gateway->id; ?>"><?php echo $gateway->get_title(); ?> <?php echo $gateway->get_icon(); ?></label>
|
||||
<?php
|
||||
if ( $gateway->has_fields() || $gateway->get_description() ) {
|
||||
echo '<div class="payment_box payment_method_' . $gateway->id . '" style="display: none;">';
|
||||
$gateway->payment_fields();
|
||||
echo '</div>';
|
||||
}
|
||||
?>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
|
||||
<div class="form-row">
|
||||
<?php wp_nonce_field( 'woocommerce-add-payment-method' ); ?>
|
||||
<input type="submit" class="button alt" id="place_order" value="<?php esc_attr_e( 'Add Payment Method', 'woocommerce' ); ?>" />
|
||||
<input type="hidden" name="woocommerce_add_payment_method" value="1" />
|
||||
</div>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<p><?php _e( 'Sorry, it seems that there are no payment methods which support adding a new payment method. Please contact us if you require assistance or wish to make alternate arrangements.', 'woocommerce' ); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
||||
<?php else : ?>
|
||||
<p><?php esc_html_e( 'Sorry, it seems that there are no payment methods which support adding a new payment method. Please contact us if you require assistance or wish to make alternate arrangements.', 'woocommerce' ); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
|
|
@ -10,64 +10,66 @@
|
|||
* happen. When this occurs the version of the template file will be bumped and
|
||||
* the readme will list any important changes.
|
||||
*
|
||||
* @see http://docs.woothemes.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.5.1
|
||||
* @see http://docs.woothemes.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.6.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<?php wc_print_notices(); ?>
|
||||
wc_print_notices();
|
||||
|
||||
<form class="edit-account" action="" method="post">
|
||||
wc_get_template( 'myaccount/navigation.php' ); ?>
|
||||
|
||||
<?php do_action( 'woocommerce_edit_account_form_start' ); ?>
|
||||
<div class="my-account-content">
|
||||
<form class="edit-account" action="" method="post">
|
||||
|
||||
<p class="form-row form-row-first">
|
||||
<label for="account_first_name"><?php _e( 'First name', 'woocommerce' ); ?> <span class="required">*</span></label>
|
||||
<input type="text" class="input-text" name="account_first_name" id="account_first_name" value="<?php echo esc_attr( $user->first_name ); ?>" />
|
||||
</p>
|
||||
<p class="form-row form-row-last">
|
||||
<label for="account_last_name"><?php _e( 'Last name', 'woocommerce' ); ?> <span class="required">*</span></label>
|
||||
<input type="text" class="input-text" name="account_last_name" id="account_last_name" value="<?php echo esc_attr( $user->last_name ); ?>" />
|
||||
</p>
|
||||
<div class="clear"></div>
|
||||
<?php do_action( 'woocommerce_edit_account_form_start' ); ?>
|
||||
|
||||
<p class="form-row form-row-wide">
|
||||
<label for="account_email"><?php _e( 'Email address', 'woocommerce' ); ?> <span class="required">*</span></label>
|
||||
<input type="email" class="input-text" name="account_email" id="account_email" value="<?php echo esc_attr( $user->user_email ); ?>" />
|
||||
</p>
|
||||
|
||||
<fieldset>
|
||||
<legend><?php _e( 'Password Change', 'woocommerce' ); ?></legend>
|
||||
<p class="form-row form-row-first">
|
||||
<label for="account_first_name"><?php _e( 'First name', 'woocommerce' ); ?> <span class="required">*</span></label>
|
||||
<input type="text" class="input-text" name="account_first_name" id="account_first_name" value="<?php echo esc_attr( $user->first_name ); ?>" />
|
||||
</p>
|
||||
<p class="form-row form-row-last">
|
||||
<label for="account_last_name"><?php _e( 'Last name', 'woocommerce' ); ?> <span class="required">*</span></label>
|
||||
<input type="text" class="input-text" name="account_last_name" id="account_last_name" value="<?php echo esc_attr( $user->last_name ); ?>" />
|
||||
</p>
|
||||
<div class="clear"></div>
|
||||
|
||||
<p class="form-row form-row-wide">
|
||||
<label for="password_current"><?php _e( 'Current Password (leave blank to leave unchanged)', 'woocommerce' ); ?></label>
|
||||
<input type="password" class="input-text" name="password_current" id="password_current" />
|
||||
<label for="account_email"><?php _e( 'Email address', 'woocommerce' ); ?> <span class="required">*</span></label>
|
||||
<input type="email" class="input-text" name="account_email" id="account_email" value="<?php echo esc_attr( $user->user_email ); ?>" />
|
||||
</p>
|
||||
<p class="form-row form-row-wide">
|
||||
<label for="password_1"><?php _e( 'New Password (leave blank to leave unchanged)', 'woocommerce' ); ?></label>
|
||||
<input type="password" class="input-text" name="password_1" id="password_1" />
|
||||
|
||||
<fieldset>
|
||||
<legend><?php _e( 'Password Change', 'woocommerce' ); ?></legend>
|
||||
|
||||
<p class="form-row form-row-wide">
|
||||
<label for="password_current"><?php _e( 'Current Password (leave blank to leave unchanged)', 'woocommerce' ); ?></label>
|
||||
<input type="password" class="input-text" name="password_current" id="password_current" />
|
||||
</p>
|
||||
<p class="form-row form-row-wide">
|
||||
<label for="password_1"><?php _e( 'New Password (leave blank to leave unchanged)', 'woocommerce' ); ?></label>
|
||||
<input type="password" class="input-text" name="password_1" id="password_1" />
|
||||
</p>
|
||||
<p class="form-row form-row-wide">
|
||||
<label for="password_2"><?php _e( 'Confirm New Password', 'woocommerce' ); ?></label>
|
||||
<input type="password" class="input-text" name="password_2" id="password_2" />
|
||||
</p>
|
||||
</fieldset>
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php do_action( 'woocommerce_edit_account_form' ); ?>
|
||||
|
||||
<p>
|
||||
<?php wp_nonce_field( 'save_account_details' ); ?>
|
||||
<input type="submit" class="button" name="save_account_details" value="<?php esc_attr_e( 'Save changes', 'woocommerce' ); ?>" />
|
||||
<input type="hidden" name="action" value="save_account_details" />
|
||||
</p>
|
||||
<p class="form-row form-row-wide">
|
||||
<label for="password_2"><?php _e( 'Confirm New Password', 'woocommerce' ); ?></label>
|
||||
<input type="password" class="input-text" name="password_2" id="password_2" />
|
||||
</p>
|
||||
</fieldset>
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php do_action( 'woocommerce_edit_account_form' ); ?>
|
||||
|
||||
<p>
|
||||
<?php wp_nonce_field( 'save_account_details' ); ?>
|
||||
<input type="submit" class="button" name="save_account_details" value="<?php esc_attr_e( 'Save changes', 'woocommerce' ); ?>" />
|
||||
<input type="hidden" name="action" value="save_account_details" />
|
||||
</p>
|
||||
|
||||
<?php do_action( 'woocommerce_edit_account_form_end' ); ?>
|
||||
|
||||
</form>
|
||||
<?php do_action( 'woocommerce_edit_account_form_end' ); ?>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -10,47 +10,48 @@
|
|||
* happen. When this occurs the version of the template file will be bumped and
|
||||
* the readme will list any important changes.
|
||||
*
|
||||
* @see http://docs.woothemes.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.1.0
|
||||
* @see http://docs.woothemes.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.6.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
exit;
|
||||
}
|
||||
|
||||
$page_title = ( $load_address === 'billing' ) ? __( 'Billing Address', 'woocommerce' ) : __( 'Shipping Address', 'woocommerce' );
|
||||
?>
|
||||
$page_title = ( $load_address === 'billing' ) ? __( 'Billing Address', 'woocommerce' ) : __( 'Shipping Address', 'woocommerce' );
|
||||
|
||||
<?php wc_print_notices(); ?>
|
||||
wc_print_notices();
|
||||
|
||||
<?php if ( ! $load_address ) : ?>
|
||||
wc_get_template( 'myaccount/navigation.php' ); ?>
|
||||
|
||||
<?php wc_get_template( 'myaccount/my-address.php' ); ?>
|
||||
<div class="my-account-content">
|
||||
<?php if ( ! $load_address ) : ?>
|
||||
<?php wc_get_template( 'myaccount/my-address.php' ); ?>
|
||||
<?php else : ?>
|
||||
|
||||
<?php else : ?>
|
||||
<form method="post">
|
||||
|
||||
<form method="post">
|
||||
<h3><?php echo apply_filters( 'woocommerce_my_account_edit_address_title', $page_title ); ?></h3>
|
||||
|
||||
<h3><?php echo apply_filters( 'woocommerce_my_account_edit_address_title', $page_title ); ?></h3>
|
||||
<?php do_action( "woocommerce_before_edit_address_form_{$load_address}" ); ?>
|
||||
|
||||
<?php do_action( "woocommerce_before_edit_address_form_{$load_address}" ); ?>
|
||||
<?php foreach ( $address as $key => $field ) : ?>
|
||||
|
||||
<?php foreach ( $address as $key => $field ) : ?>
|
||||
<?php woocommerce_form_field( $key, $field, ! empty( $_POST[ $key ] ) ? wc_clean( $_POST[ $key ] ) : $field['value'] ); ?>
|
||||
|
||||
<?php woocommerce_form_field( $key, $field, ! empty( $_POST[ $key ] ) ? wc_clean( $_POST[ $key ] ) : $field['value'] ); ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php endforeach; ?>
|
||||
<?php do_action( "woocommerce_after_edit_address_form_{$load_address}" ); ?>
|
||||
|
||||
<?php do_action( "woocommerce_after_edit_address_form_{$load_address}" ); ?>
|
||||
<p>
|
||||
<input type="submit" class="button" name="save_address" value="<?php esc_attr_e( 'Save Address', 'woocommerce' ); ?>" />
|
||||
<?php wp_nonce_field( 'woocommerce-edit_address' ); ?>
|
||||
<input type="hidden" name="action" value="edit_address" />
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<input type="submit" class="button" name="save_address" value="<?php esc_attr_e( 'Save Address', 'woocommerce' ); ?>" />
|
||||
<?php wp_nonce_field( 'woocommerce-edit_address' ); ?>
|
||||
<input type="hidden" name="action" value="edit_address" />
|
||||
</p>
|
||||
</form>
|
||||
|
||||
</form>
|
||||
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
* happen. When this occurs the version of the template file will be bumped and
|
||||
* the readme will list any important changes.
|
||||
*
|
||||
* @see http://docs.woothemes.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.2.6
|
||||
* @see http://docs.woothemes.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.2.6
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
* happen. When this occurs the version of the template file will be bumped and
|
||||
* the readme will list any important changes.
|
||||
*
|
||||
* @see http://docs.woothemes.com/document/template-structure/
|
||||
* @see http://docs.woothemes.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.3.0
|
||||
|
|
|
@ -10,38 +10,53 @@
|
|||
* happen. When this occurs the version of the template file will be bumped and
|
||||
* the readme will list any important changes.
|
||||
*
|
||||
* @see http://docs.woothemes.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.0.0
|
||||
* @see http://docs.woothemes.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.6.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
exit;
|
||||
}
|
||||
|
||||
wc_print_notices(); ?>
|
||||
|
||||
<p class="myaccount_user">
|
||||
<?php wc_get_template( 'myaccount/navigation.php' ); ?>
|
||||
|
||||
<div class="my-account-content">
|
||||
<p class="myaccount_user">
|
||||
<?php
|
||||
printf(
|
||||
__( 'Hello <strong>%1$s</strong> (not %1$s? <a href="%2$s">Sign out</a>).', 'woocommerce' ) . ' ',
|
||||
$current_user->display_name,
|
||||
wc_get_endpoint_url( 'customer-logout', '', wc_get_page_permalink( 'myaccount' ) )
|
||||
);
|
||||
|
||||
_e( 'From your account dashboard you can view your recent orders, manage your shipping and billing addresses and edit your password and account details.', 'woocommerce' );
|
||||
?>
|
||||
</p>
|
||||
|
||||
<?php
|
||||
printf(
|
||||
__( 'Hello <strong>%1$s</strong> (not %1$s? <a href="%2$s">Sign out</a>).', 'woocommerce' ) . ' ',
|
||||
$current_user->display_name,
|
||||
wc_get_endpoint_url( 'customer-logout', '', wc_get_page_permalink( 'myaccount' ) )
|
||||
);
|
||||
/**
|
||||
* My Account dashboard.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*/
|
||||
do_action( 'woocommerce_account_dashboard' );
|
||||
|
||||
printf( __( 'From your account dashboard you can view your recent orders, manage your shipping and billing addresses and <a href="%s">edit your password and account details</a>.', 'woocommerce' ),
|
||||
wc_customer_edit_account_url()
|
||||
);
|
||||
/**
|
||||
* Deprecated woocommerce_before_my_account action.
|
||||
*
|
||||
* @deprecated 2.6.0
|
||||
*/
|
||||
do_action( 'woocommerce_before_my_account' );
|
||||
|
||||
/**
|
||||
* Deprecated woocommerce_after_my_account action.
|
||||
*
|
||||
* @deprecated 2.6.0
|
||||
*/
|
||||
do_action( 'woocommerce_after_my_account' );
|
||||
?>
|
||||
</p>
|
||||
|
||||
<?php do_action( 'woocommerce_before_my_account' ); ?>
|
||||
|
||||
<?php wc_get_template( 'myaccount/my-downloads.php' ); ?>
|
||||
|
||||
<?php wc_get_template( 'myaccount/my-orders.php', array( 'order_count' => $order_count ) ); ?>
|
||||
|
||||
<?php wc_get_template( 'myaccount/my-address.php' ); ?>
|
||||
|
||||
<?php do_action( 'woocommerce_after_my_account' ); ?>
|
||||
</div>
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
* happen. When this occurs the version of the template file will be bumped and
|
||||
* the readme will list any important changes.
|
||||
*
|
||||
* @see http://docs.woothemes.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.2.0
|
||||
* @see http://docs.woothemes.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.2.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
|
@ -24,13 +24,13 @@ $customer_id = get_current_user_id();
|
|||
|
||||
if ( ! wc_ship_to_billing_address_only() && wc_shipping_enabled() ) {
|
||||
$page_title = apply_filters( 'woocommerce_my_account_my_address_title', __( 'My Addresses', 'woocommerce' ) );
|
||||
$get_addresses = apply_filters( 'woocommerce_my_account_get_addresses', array(
|
||||
$get_addresses = apply_filters( 'woocommerce_my_account_get_addresses', array(
|
||||
'billing' => __( 'Billing Address', 'woocommerce' ),
|
||||
'shipping' => __( 'Shipping Address', 'woocommerce' )
|
||||
), $customer_id );
|
||||
} else {
|
||||
$page_title = apply_filters( 'woocommerce_my_account_my_address_title', __( 'My Address', 'woocommerce' ) );
|
||||
$get_addresses = apply_filters( 'woocommerce_my_account_get_addresses', array(
|
||||
$get_addresses = apply_filters( 'woocommerce_my_account_get_addresses', array(
|
||||
'billing' => __( 'Billing Address', 'woocommerce' )
|
||||
), $customer_id );
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ $col = 1;
|
|||
<div class="col-<?php echo ( ( $col = $col * -1 ) < 0 ) ? 1 : 2; ?> address">
|
||||
<header class="title">
|
||||
<h3><?php echo $title; ?></h3>
|
||||
<a href="<?php echo wc_get_endpoint_url( 'edit-address', $name ); ?>" class="edit"><?php _e( 'Edit', 'woocommerce' ); ?></a>
|
||||
<a href="<?php echo esc_url( wc_get_endpoint_url( 'edit-address', $name ) ); ?>" class="edit"><?php _e( 'Edit', 'woocommerce' ); ?></a>
|
||||
</header>
|
||||
<address>
|
||||
<?php
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
/**
|
||||
* My Orders
|
||||
* My Downloads
|
||||
*
|
||||
* Shows recent orders on the account page.
|
||||
* Shows downloads on the account page.
|
||||
*
|
||||
* This template can be overridden by copying it to yourtheme/woocommerce/myaccount/my-downloads.php.
|
||||
*
|
||||
|
@ -12,10 +12,11 @@
|
|||
* happen. When this occurs the version of the template file will be bumped and
|
||||
* the readme will list any important changes.
|
||||
*
|
||||
* @see http://docs.woothemes.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @see http://docs.woothemes.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.0.0
|
||||
* @depreacated 2.6.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
|
|
|
@ -12,10 +12,11 @@
|
|||
* happen. When this occurs the version of the template file will be bumped and
|
||||
* the readme will list any important changes.
|
||||
*
|
||||
* @see http://docs.woothemes.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.5.0
|
||||
* @see http://docs.woothemes.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.5.0
|
||||
* @depreacated 2.6.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
/**
|
||||
* My Account navigation
|
||||
*
|
||||
* This template can be overridden by copying it to yourtheme/woocommerce/myaccount/navigation.php.
|
||||
*
|
||||
* HOWEVER, on occasion WooCommerce will need to update template files and you
|
||||
* (the theme developer) will need to copy the new files to your theme to
|
||||
* maintain compatibility. We try to do this as little as possible, but it does
|
||||
* happen. When this occurs the version of the template file will be bumped and
|
||||
* the readme will list any important changes.
|
||||
*
|
||||
* @see http://docs.woothemes.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.6.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<nav class="my-account-navigation">
|
||||
<ul>
|
||||
<?php foreach ( wc_get_account_menu_items() as $endpoint => $label ) : ?>
|
||||
<li class="<?php echo wc_get_account_menu_item_classes( $endpoint ); ?>">
|
||||
<a href="<?php echo esc_url( wc_get_account_endpoint_url( $endpoint ) ); ?>"><?php echo esc_html( $label ); ?></a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</nav>
|
|
@ -0,0 +1,136 @@
|
|||
<?php
|
||||
/**
|
||||
* Orders
|
||||
*
|
||||
* Shows orders on the account page.
|
||||
*
|
||||
* This template can be overridden by copying it to yourtheme/woocommerce/myaccount/orders.php.
|
||||
*
|
||||
* HOWEVER, on occasion WooCommerce will need to update template files and you
|
||||
* (the theme developer) will need to copy the new files to your theme to
|
||||
* maintain compatibility. We try to do this as little as possible, but it does
|
||||
* happen. When this occurs the version of the template file will be bumped and
|
||||
* the readme will list any important changes.
|
||||
*
|
||||
* @see http://docs.woothemes.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.6.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$customer_orders = new WP_Query( wc_get_account_orders_query_args( $current_page ) );
|
||||
$has_orders = $customer_orders->have_posts();
|
||||
|
||||
wc_print_notices();
|
||||
|
||||
wc_get_template( 'myaccount/navigation.php' ); ?>
|
||||
|
||||
<div class="my-account-content">
|
||||
|
||||
<?php do_action( 'woocommerce_before_account_orders', $has_orders ); ?>
|
||||
|
||||
<?php if ( $has_orders ) : ?>
|
||||
|
||||
<table class="shop_table shop_table_responsive my_account_orders account-orders-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php foreach ( wc_get_account_orders_columns() as $column_id => $column_name ) : ?>
|
||||
<th class="<?php echo esc_attr( $column_id ); ?>"><span class="nobr"><?php echo esc_html( $column_name ); ?></span></th>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php foreach ( $customer_orders->posts as $customer_order ) :
|
||||
$order = wc_get_order( $customer_order );
|
||||
$item_count = $order->get_item_count();
|
||||
?>
|
||||
<tr class="order">
|
||||
<?php foreach ( wc_get_account_orders_columns() as $column_id => $column_name ) : ?>
|
||||
<td class="<?php echo esc_attr( $column_id ); ?>" data-title="<?php echo esc_attr( $column_name ); ?>">
|
||||
<?php if ( has_action( 'woocommerce_my_account_my_orders_column_' . $column_id ) ) : ?>
|
||||
<?php do_action( 'woocommerce_my_account_my_orders_column_' . $column_id, $order ); ?>
|
||||
|
||||
<?php elseif ( 'order-number' === $column_id ) : ?>
|
||||
<a href="<?php echo esc_url( $order->get_view_order_url() ); ?>">
|
||||
<?php echo _x( '#', 'hash before order number', 'woocommerce' ) . $order->get_order_number(); ?>
|
||||
</a>
|
||||
|
||||
<?php elseif ( 'order-date' === $column_id ) : ?>
|
||||
<time datetime="<?php echo date( 'Y-m-d', strtotime( $order->order_date ) ); ?>" title="<?php echo esc_attr( strtotime( $order->order_date ) ); ?>"><?php echo date_i18n( get_option( 'date_format' ), strtotime( $order->order_date ) ); ?></time>
|
||||
|
||||
<?php elseif ( 'order-status' === $column_id ) : ?>
|
||||
<?php echo wc_get_order_status_name( $order->get_status() ); ?>
|
||||
|
||||
<?php elseif ( 'order-total' === $column_id ) : ?>
|
||||
<?php echo sprintf( _n( '%s for %s item', '%s for %s items', $item_count, 'woocommerce' ), $order->get_formatted_order_total(), $item_count ); ?>
|
||||
|
||||
<?php elseif ( 'order-actions' === $column_id ) : ?>
|
||||
<?php
|
||||
$actions = array(
|
||||
'pay' => array(
|
||||
'url' => $order->get_checkout_payment_url(),
|
||||
'name' => __( 'Pay', 'woocommerce' )
|
||||
),
|
||||
'view' => array(
|
||||
'url' => $order->get_view_order_url(),
|
||||
'name' => __( 'View', 'woocommerce' )
|
||||
),
|
||||
'cancel' => array(
|
||||
'url' => $order->get_cancel_order_url( wc_get_page_permalink( 'myaccount' ) ),
|
||||
'name' => __( 'Cancel', 'woocommerce' )
|
||||
)
|
||||
);
|
||||
|
||||
if ( ! $order->needs_payment() ) {
|
||||
unset( $actions['pay'] );
|
||||
}
|
||||
|
||||
if ( ! in_array( $order->get_status(), apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) ) ) {
|
||||
unset( $actions['cancel'] );
|
||||
}
|
||||
|
||||
if ( $actions = apply_filters( 'woocommerce_my_account_my_orders_actions', $actions, $order ) ) {
|
||||
foreach ( $actions as $key => $action ) {
|
||||
echo '<a href="' . esc_url( $action['url'] ) . '" class="button ' . sanitize_html_class( $key ) . '">' . esc_html( $action['name'] ) . '</a>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php do_action( 'woocommerce_before_account_orders_pagination' ); ?>
|
||||
|
||||
<?php if ( 1 < $customer_orders->max_num_pages ) : ?>
|
||||
<div class="wc-account-orders-pagination">
|
||||
<?php if ( 1 !== $current_page ) : ?>
|
||||
<a class="button" href="<?php echo esc_url( wc_get_endpoint_url( 'orders', $current_page - 1 ) ); ?>"><?php _e( 'Previous', 'woocommerce' ); ?></a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( $current_page !== intval( $customer_orders->max_num_pages ) ) : ?>
|
||||
<a class="button" href="<?php echo esc_url( wc_get_endpoint_url( 'orders', $current_page + 1 ) ); ?>"><?php _e( 'Next', 'woocommerce' ); ?></a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php else : ?>
|
||||
<div class="woocommerce-info">
|
||||
<a class="button" href="<?php echo esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ); ?>">
|
||||
<?php _e( 'Go Shop', 'woocommerce' ) ?>
|
||||
</a>
|
||||
<?php _e( 'No order has been made yet.', 'woocommerce' ); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php do_action( 'woocommerce_after_account_orders', $has_orders ); ?>
|
||||
|
||||
</div>
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
/**
|
||||
* Payment methods
|
||||
*
|
||||
* Shows customer payment methods on the account page.
|
||||
*
|
||||
* This template can be overridden by copying it to yourtheme/woocommerce/myaccount/payment-methods.php.
|
||||
*
|
||||
* HOWEVER, on occasion WooCommerce will need to update template files and you
|
||||
* (the theme developer) will need to copy the new files to your theme to
|
||||
* maintain compatibility. We try to do this as little as possible, but it does
|
||||
* happen. When this occurs the version of the template file will be bumped and
|
||||
* the readme will list any important changes.
|
||||
*
|
||||
* @see http://docs.woothemes.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.6.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$saved_methods = wc_get_customer_saved_methods_list( get_current_user_id() );
|
||||
$has_methods = (bool) $saved_methods;
|
||||
|
||||
wc_print_notices(); ?>
|
||||
|
||||
<?php wc_get_template( 'myaccount/navigation.php' ); ?>
|
||||
|
||||
<div class="my-account-content">
|
||||
|
||||
<?php do_action( 'woocommerce_before_account_payment_methods', $has_methods ); ?>
|
||||
|
||||
<?php if ( $has_methods ) : ?>
|
||||
|
||||
<table class="shop_table shop_table_responsive account-payment-methods-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php foreach ( wc_get_account_payment_methods_columns() as $column_id => $column_name ) : ?>
|
||||
<th class="payment-method-<?php echo esc_attr( $column_id ); ?>"><span class="nobr"><?php echo esc_html( $column_name ); ?></span></th>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<?php foreach ( $saved_methods as $method ) : ?>
|
||||
<tr class="method">
|
||||
<?php foreach ( wc_get_account_payment_methods_columns() as $column_id => $column_name ) : ?>
|
||||
<td class="payment-method-<?php echo esc_attr( $column_id ); ?>" data-title="<?php echo esc_attr( $column_name ); ?>">
|
||||
<?php
|
||||
// @TODO
|
||||
?>
|
||||
</td>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
<?php else : ?>
|
||||
|
||||
<p><?php esc_html_e( 'No saved method found.', 'woocommerce' ); ?></p>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php do_action( 'woocommerce_after_account_payment_methods', $has_methods ); ?>
|
||||
|
||||
<a class="button" href="<?php echo esc_url( wc_get_endpoint_url( 'add-payment-method' ) ); ?>"><?php esc_html_e( 'Add New Payment Method', 'woocommerce' ); ?></a>
|
||||
|
||||
</div>
|
|
@ -12,42 +12,42 @@
|
|||
* happen. When this occurs the version of the template file will be bumped and
|
||||
* the readme will list any important changes.
|
||||
*
|
||||
* @see http://docs.woothemes.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.2.0
|
||||
* @see http://docs.woothemes.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.6.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
wc_print_notices(); ?>
|
||||
|
||||
<?php wc_print_notices(); ?>
|
||||
<?php wc_get_template( 'myaccount/navigation.php' ); ?>
|
||||
|
||||
<p class="order-info"><?php printf( __( 'Order #<mark class="order-number">%s</mark> was placed on <mark class="order-date">%s</mark> and is currently <mark class="order-status">%s</mark>.', 'woocommerce' ), $order->get_order_number(), date_i18n( get_option( 'date_format' ), strtotime( $order->order_date ) ), wc_get_order_status_name( $order->get_status() ) ); ?></p>
|
||||
<div class="my-account-content">
|
||||
<p class="order-info"><?php printf( __( 'Order #<mark class="order-number">%s</mark> was placed on <mark class="order-date">%s</mark> and is currently <mark class="order-status">%s</mark>.', 'woocommerce' ), $order->get_order_number(), date_i18n( get_option( 'date_format' ), strtotime( $order->order_date ) ), wc_get_order_status_name( $order->get_status() ) ); ?></p>
|
||||
|
||||
<?php if ( $notes = $order->get_customer_order_notes() ) :
|
||||
?>
|
||||
<h2><?php _e( 'Order Updates', 'woocommerce' ); ?></h2>
|
||||
<ol class="commentlist notes">
|
||||
<?php foreach ( $notes as $note ) : ?>
|
||||
<li class="comment note">
|
||||
<div class="comment_container">
|
||||
<div class="comment-text">
|
||||
<p class="meta"><?php echo date_i18n( __( 'l jS \o\f F Y, h:ia', 'woocommerce' ), strtotime( $note->comment_date ) ); ?></p>
|
||||
<div class="description">
|
||||
<?php echo wpautop( wptexturize( $note->comment_content ) ); ?>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
<?php
|
||||
endif;
|
||||
<?php if ( $notes = $order->get_customer_order_notes() ) : ?>
|
||||
<h2><?php _e( 'Order Updates', 'woocommerce' ); ?></h2>
|
||||
<ol class="commentlist notes">
|
||||
<?php foreach ( $notes as $note ) : ?>
|
||||
<li class="comment note">
|
||||
<div class="comment_container">
|
||||
<div class="comment-text">
|
||||
<p class="meta"><?php echo date_i18n( __( 'l jS \o\f F Y, h:ia', 'woocommerce' ), strtotime( $note->comment_date ) ); ?></p>
|
||||
<div class="description">
|
||||
<?php echo wpautop( wptexturize( $note->comment_content ) ); ?>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
<?php endif; ?>
|
||||
|
||||
do_action( 'woocommerce_view_order', $order_id );
|
||||
<?php do_action( 'woocommerce_view_order', $order_id ); ?>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
namespace WooCommerce\Tests\Account;
|
||||
|
||||
/**
|
||||
* Class Functions.
|
||||
* @package WooCommerce\Tests\Account
|
||||
*/
|
||||
class Functions extends \WC_Unit_Test_Case {
|
||||
|
||||
/**
|
||||
* Test wc_get_account_menu_items().
|
||||
*
|
||||
* @since 2.6.0
|
||||
*/
|
||||
public function test_wc_get_account_menu_items() {
|
||||
$this->assertEquals( array(
|
||||
'dashboard' => __( 'Dashboard', 'woocommerce' ),
|
||||
'orders' => __( 'Orders', 'woocommerce' ),
|
||||
'downloads' => __( 'Downloads', 'woocommerce' ),
|
||||
'edit-address' => __( 'Addresses', 'woocommerce' ),
|
||||
'payment-methods' => __( 'Payment Methods', 'woocommerce' ),
|
||||
'edit-account' => __( 'Account Details', 'woocommerce' ),
|
||||
'customer-logout' => __( 'Logout', 'woocommerce' ),
|
||||
), wc_get_account_menu_items() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test wc_get_account_orders_columns().
|
||||
*
|
||||
* @since 2.6.0
|
||||
*/
|
||||
public function test_wc_get_account_orders_columns() {
|
||||
$this->assertEquals( array(
|
||||
'order-number' => __( 'Order', 'woocommerce' ),
|
||||
'order-date' => __( 'Date', 'woocommerce' ),
|
||||
'order-status' => __( 'Status', 'woocommerce' ),
|
||||
'order-total' => __( 'Total', 'woocommerce' ),
|
||||
'order-actions' => ' ',
|
||||
), wc_get_account_orders_columns() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test wc_get_account_orders_query_args().
|
||||
*
|
||||
* @since 2.6.0
|
||||
*/
|
||||
public function test_wc_get_account_orders_query_args() {
|
||||
$this->assertEquals( array(
|
||||
'posts_per_page' => 15,
|
||||
'meta_key' => '_customer_user',
|
||||
'meta_value' => get_current_user_id(),
|
||||
'post_type' => wc_get_order_types( 'view-orders' ),
|
||||
'post_status' => array_keys( wc_get_order_statuses() ),
|
||||
), wc_get_account_orders_query_args() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test wc_get_account_downloads_columns().
|
||||
*
|
||||
* @since 2.6.0
|
||||
*/
|
||||
public function test_wc_get_account_downloads_columns() {
|
||||
$this->assertEquals( array(
|
||||
'download-file' => __( 'File', 'woocommerce' ),
|
||||
'download-remaining' => __( 'Remaining', 'woocommerce' ),
|
||||
'download-expires' => __( 'Expires', 'woocommerce' ),
|
||||
'download-actions' => ' ',
|
||||
), wc_get_account_downloads_columns() );
|
||||
}
|
||||
}
|
|
@ -153,5 +153,17 @@ class Core_Functions extends \WC_Unit_Test_Case {
|
|||
$this->assertEquals( '', $default['state'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test wc_format_country_state_string().
|
||||
*
|
||||
* @since 2.6.0
|
||||
*/
|
||||
public function test_wc_format_country_state_string() {
|
||||
// Test with correct values.
|
||||
$this->assertEquals( array( 'country' => 'US', 'state' => 'CA' ), wc_format_country_state_string( 'US:CA' ) );
|
||||
// Test what happens when we pass an incorrect value.
|
||||
$this->assertEquals( array( 'country' => 'US-CA', 'state' => '' ), wc_format_country_state_string( 'US-CA' ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue