dongshang1768 2019-01-25 15:16
浏览 44
已采纳

带链接的消息和滚动到Woocommerce结帐详细信息

I got this answer from LoicTheAztec which solves the problem with the message. But, when clicking the button, it does not scroll down to the customer details on the Checkout page, which is the idea.

Hers's the code from LoicTheAztec:

add_filter('woocommerce_add_message', 'change_cart_message', 10, 1 );
function change_cart_message( $message ) {

    $subtotal = WC()->cart->subtotal;

    $href = is_checkout() ? '#customer_details' : wc_get_checkout_url();

    return sprintf(  __("Your new order subtotal is: %s. %s"), wc_price($subtotal),
        '<a class="button alt" href="'.$href.'">' . __("Ready to checkout?") . '</a>' );
}

Can I please get help with that? Here's the link that question.

  • 写回答

1条回答 默认 最新

  • doushi1964 2019-01-25 15:48
    关注

    To get the scroll to checkout "Customer details" section, you will need to replace the following line:

    $href = is_checkout() ? '#customer_details' : wc_get_checkout_url();
    

    by:

    $href = is_checkout() ? '#customer_details' : wc_get_checkout_url() . '#customer_details';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?