Change button link cart checkout woocommerce_mini_cart woocommerce

Thảo luận trong 'Mã nguồn mở Wordpress' bắt đầu bởi seolagi, 20/2/24.

  1. seolagi
    Tham gia ngày:
    16/4/14
    Bài viết:
    1,030
    Đã được thích:
    81
    Điểm thành tích:
    48
    Cho em hỏi làm sao để: Change button link cart checkout woocommerce_mini_cart woocommerce vậy cả nhà nhi?

    cart-button.jpg

    Mặc định nó là Xem giỏ hàng và Thanh Toán, nay bên em gộp cái giỏ hàng với thanh toán là 1, giờ em muốn đổi các nút này theo ý thích thì làm như thế nào?

    Bạn nào biết cách thay đổi cho mình cái code với, cảm ơn.

    Em sử dụng themes Flatsome mới nhất 17.7 và plugin woocommerce, code wordpress mới nhất
     
    Cảm ơn đã xem bài:

    Change button link cart checkout woocommerce_mini_cart woocommerce

  2. admin
    Tham gia ngày:
    22/5/13
    Bài viết:
    4,909
    Đã được thích:
    1,201
    Điểm thành tích:
    113
    Giới tính:
    Nam
    Em thử code sau nhé, add nó vào function.php của themes.
    Mã:
    add_action( 'woocommerce_widget_shopping_cart_buttons', function(){
        // Removing Buttons
        remove_action( 'woocommerce_widget_shopping_cart_buttons', 'woocommerce_widget_shopping_cart_button_view_cart', 10 );
        remove_action( 'woocommerce_widget_shopping_cart_buttons', 'woocommerce_widget_shopping_cart_proceed_to_checkout', 20 );
    
        // Adding customized Buttons
        add_action( 'woocommerce_widget_shopping_cart_buttons', 'custom_widget_shopping_cart_button_view_cart', 10 );
        add_action( 'woocommerce_widget_shopping_cart_buttons', 'custom_widget_shopping_cart_proceed_to_checkout', 20 );
    }, 1 );
    
    // Custom cart button
    function custom_widget_shopping_cart_button_view_cart() {
        $original_link = wc_get_cart_url();
        $custom_link = home_url( '/cart/?id=1' ); // HERE replacing cart link
        echo '<a href="' . esc_url( $custom_link ) . '" class="button wc-forward">' . esc_html__( 'View cart', 'woocommerce' ) . '</a>';
    }
    
    // Custom Checkout button
    function custom_widget_shopping_cart_proceed_to_checkout() {
        $original_link = wc_get_checkout_url();
        $custom_link = home_url( '/checkout/?id=1' ); // HERE replacing checkout link
        echo '<a href="' . esc_url( $custom_link ) . '" class="button checkout wc-forward">' . esc_html__( 'Checkout', 'woocommerce' ) . '</a>';
    }
     
    Chỉnh sửa cuối: 20/2/24


Chủ để tương tự : Change button
Diễn đàn Tiêu đề Date
Mã nguồn mở Wordpress Change Variation Select Dropdown to Radio Buttons on WooCommerce 8/6/21
Mã nguồn mở Wordpress Change gallery thumbnails count & number default 4 Woocommerce 3/8/23
Mã nguồn mở Wordpress Đổi vị trí hiện thị Fixed Toc từ nội dung vào sidebar, Change position Fixed TOC 12/10/21
Mã nguồn mở Wordpress Change userName Via Twitter sharing post on newspaper 7/1/21