Cart Shortcode: `wc_get_cart_url` should only return current URL if on the cart page (#51384)
* Narrow logic further by only checking if the current page is the cart, not WOOCOMMERCE_CART * changelog
This commit is contained in:
parent
b98236a25e
commit
554434ea3d
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
|
||||
wc_get_cart_url should only return current URL if on the cart page. This excludes the usage of WOOCOMMERCE_CART.
|
|
@ -1484,7 +1484,11 @@ function wc_transaction_query( $type = 'start', $force = false ) {
|
|||
* @return string Url to cart page
|
||||
*/
|
||||
function wc_get_cart_url() {
|
||||
if ( is_cart() && isset( $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'] ) ) {
|
||||
// We don't use is_cart() here because that also checks for a defined constant. We are only interested in the page.
|
||||
$page_id = wc_get_page_id( 'cart' );
|
||||
$is_cart_page = ( $page_id && is_page( $page_id ) ) || wc_post_content_has_shortcode( 'woocommerce_cart' );
|
||||
|
||||
if ( $is_cart_page && isset( $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'] ) ) {
|
||||
$protocol = is_ssl() ? 'https' : 'http';
|
||||
$current_url = esc_url_raw( $protocol . '://' . wp_unslash( $_SERVER['HTTP_HOST'] ) . wp_unslash( $_SERVER['REQUEST_URI'] ) );
|
||||
$cart_url = remove_query_arg( array( 'remove_item', 'add-to-cart', 'added-to-cart', 'order_again', '_wpnonce' ), $current_url );
|
||||
|
|
Loading…
Reference in New Issue