Đổi tên Related Product trong Woocommerce luôn là điều mà nhiều bạn quan tâm. Thực tế nhiều themes họ cũng đã việt hóa thành sản phẩm liên quan. Có theme thì không cứ giữ y chang cái related product. Điều này khiến khách hàng hoặc bản thân chúng ta không hài lòng. Đang làm 1 cái Web thuần Việt mà lại mọc ra mấy cái tiêu đề tiếng Anh khó chịu.
Mục lục bài viết:
Đổi tên Related product thành sản phẩm tương tự trong Woocommerce
add_filter("gettext", "rename_relatedproduct_text", 10, 3);
add_filter("ngettext", "rename_relatedproduct_text", 10, 3);
function rename_relatedproduct_text($translated, $text, $domain)
{
if ($text === "Related products" && $domain === "woocommerce") {
$translated = esc_html__("Sản phẩm tương tự", $domain);
}
return $translated;
}
Bạn chèn đoạn code dưới đây vào file function.php của theme là có thể đổi tên Related product thành sản phẩm tương tự
Ngoài ra bạn có thể dùng những đoạn code dịch tương tự:
Dịch Add to cart
// Dịch trong trang Sản phẩm
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woocommerce_custom_single_add_to_cart_text' );
function woocommerce_custom_single_add_to_cart_text() {
return __( 'Buy Now', 'woocommerce' );
}
// Dịch trong trang
add_filter( 'woocommerce_product_add_to_cart_text', 'woocommerce_custom_product_add_to_cart_text' );
function woocommerce_custom_product_add_to_cart_text() {
return __( '', 'woocommerce' );
}
Dịch you may also like
add_filter( 'woocommerce_product_upsells_products_heading', 'bbloomer_translate_may_also_like' );
function bbloomer_translate_may_also_like() {
return 'Khách hàng cũng thường mua cùng';
}
Chúc các bạn thành công!
Bình luận bị cấm: Bình luận có chứa yếu tố SPAM và yếu tố quảng cáo.