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';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题