From e814105728695be8dbb0e4fef34210b71575a44a Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Fri, 30 Aug 2019 13:06:50 -0300 Subject: [PATCH] Prefer wc_get_checkout_url() instead of wc_get_page_permalink( 'checkout' ) --- includes/abstracts/abstract-wc-payment-gateway.php | 8 ++------ includes/class-wc-order.php | 13 ++----------- templates/checkout/form-login.php | 4 ++-- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/includes/abstracts/abstract-wc-payment-gateway.php b/includes/abstracts/abstract-wc-payment-gateway.php index e8f30713a42..553fea67558 100644 --- a/includes/abstracts/abstract-wc-payment-gateway.php +++ b/includes/abstracts/abstract-wc-payment-gateway.php @@ -216,11 +216,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API { if ( $order ) { $return_url = $order->get_checkout_order_received_url(); } else { - $return_url = wc_get_endpoint_url( 'order-received', '', wc_get_page_permalink( 'checkout' ) ); - } - - if ( is_ssl() || get_option( 'woocommerce_force_ssl_checkout' ) == 'yes' ) { - $return_url = str_replace( 'http:', 'https:', $return_url ); + $return_url = wc_get_endpoint_url( 'order-received', '', wc_get_checkout_url() ); } return apply_filters( 'woocommerce_get_return_url', $return_url, $order ); @@ -524,7 +520,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API { esc_attr( $this->id ), esc_html__( 'Save to account', 'woocommerce' ) ); - + echo apply_filters( 'woocommerce_payment_gateway_save_new_payment_method_option_html', $html, $this ); } diff --git a/includes/class-wc-order.php b/includes/class-wc-order.php index d20cd5620db..71d5c301c06 100644 --- a/includes/class-wc-order.php +++ b/includes/class-wc-order.php @@ -1510,11 +1510,7 @@ class WC_Order extends WC_Abstract_Order { * @return string */ public function get_checkout_payment_url( $on_checkout = false ) { - $pay_url = wc_get_endpoint_url( 'order-pay', $this->get_id(), wc_get_page_permalink( 'checkout' ) ); - - if ( 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) || is_ssl() ) { - $pay_url = str_replace( 'http:', 'https:', $pay_url ); - } + $pay_url = wc_get_endpoint_url( 'order-pay', $this->get_id(), wc_get_checkout_url() ); if ( $on_checkout ) { $pay_url = add_query_arg( 'key', $this->get_order_key(), $pay_url ); @@ -1537,12 +1533,7 @@ class WC_Order extends WC_Abstract_Order { * @return string */ public function get_checkout_order_received_url() { - $order_received_url = wc_get_endpoint_url( 'order-received', $this->get_id(), wc_get_page_permalink( 'checkout' ) ); - - if ( 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) || is_ssl() ) { - $order_received_url = str_replace( 'http:', 'https:', $order_received_url ); - } - + $order_received_url = wc_get_endpoint_url( 'order-received', $this->get_id(), wc_get_checkout_url() ); $order_received_url = add_query_arg( 'key', $this->get_order_key(), $order_received_url ); return apply_filters( 'woocommerce_get_checkout_order_received_url', $order_received_url, $this ); diff --git a/templates/checkout/form-login.php b/templates/checkout/form-login.php index 3c2e6e3208c..b838a59f90c 100644 --- a/templates/checkout/form-login.php +++ b/templates/checkout/form-login.php @@ -12,7 +12,7 @@ * * @see https://docs.woocommerce.com/document/template-structure/ * @package WooCommerce/Templates - * @version 3.4.0 + * @version 3.8.0 */ defined( 'ABSPATH' ) || exit; @@ -30,7 +30,7 @@ if ( is_user_logged_in() || 'no' === get_option( 'woocommerce_enable_checkout_lo woocommerce_login_form( array( 'message' => esc_html__( 'If you have shopped with us before, please enter your details below. If you are a new customer, please proceed to the Billing section.', 'woocommerce' ), - 'redirect' => wc_get_page_permalink( 'checkout' ), + 'redirect' => wc_get_checkout_url(), 'hidden' => true, ) );