Change the text of 'View cart' button

2019-07-16 05:18发布

Iam using a woocommerce plugin but I got an problem on how to change the text of the view cart button hope there is a one who can help with my problem this is my site this is the image of the text that i want to change the image how can i edit it? all suggestion are appreciated.

3条回答
Anthone
2楼-- · 2019-07-16 05:48

Add the following to your functions.php file.

/**
 * Change text strings
 *
 * @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
 */
function my_text_strings( $translated_text, $text, $domain ) {
    switch ( strtolower( $translated_text ) ) {
        case 'View Cart' :
            $translated_text = __( 'View Shopping Cart', 'woocommerce' );
            break;
    }
    return $translated_text;
}
add_filter( 'gettext', 'my_text_strings', 20, 3 );

This will change View Cart to View Shopping Cart

查看更多
贪生不怕死
3楼-- · 2019-07-16 05:53

Go to wp-content\plugins\woocommerce\includes\wc-template-functions.php then edit raw 1429

function woocommerce_widget_shopping_cart_button_view_cart() {
        echo '<a href="' . esc_url( wc_get_cart_url() ) . '" class="button wc-forward">' . esc_html__( 'View cart', 'woocommerce' ) . '</a>';
    }
}
function woocommerce_widget_shopping_cart_button_view_cart() {
        echo '<a href="' . esc_url( wc_get_cart_url() ) . '" class="button wc-forward">' . esc_html__( 'your text', 'woocommerce' ) . '</a>';
    }
}

version woocommerce 3.0.3.

查看更多
爷的心禁止访问
4楼-- · 2019-07-16 05:54

Add the following code to your functions.php file

function change_view_cart_link( $params, $handle )
{
    switch ($handle) {
        case 'wc-add-to-cart':
            $params['i18n_view_cart'] = "Proceed to Cart"; //chnage Name of view cart button
            $params['cart_url'] = "http://myshop.com/custom-page"; //change URL of view cart button
        break;
    }
    return $params;
}
查看更多
登录 后发表回答