Don't trailingslash Order Cancel URLs with a Query String

With non-pretty permalinks enabled, this was producing a URI like
http://example.com/?page_id=7/  That final unnecessary trailing slash
messes up some redirect gateways that are passed the cancel URL
This commit is contained in:
justinstern 2014-03-11 00:04:49 -04:00
parent 2f5fb72a9c
commit 6dfce64e47
1 changed files with 7 additions and 1 deletions

View File

@ -1112,7 +1112,13 @@ class WC_Order {
*/
public function get_cancel_order_url( $redirect = '' ) {
$cancel_endpoint = get_permalink( wc_get_page_id( 'cart' ) );
$cancel_endpoint = trailingslashit( $cancel_endpoint ? $cancel_endpoint : home_url() );
if ( ! $cancel_endpoint ) {
$cancel_endpoint = home_url();
}
if ( false === strpos( $cancel_endpoint, '?' ) ) {
$cancel_endpoint = trailingslashit( $cancel_endpoint );
}
return apply_filters('woocommerce_get_cancel_order_url', wp_nonce_url( add_query_arg( array( 'cancel_order' => 'true', 'order' => $this->order_key, 'order_id' => $this->id, 'redirect' => $redirect ), $cancel_endpoint ), 'woocommerce-cancel_order' ) );
}