Có rất nhiều bạn hỏi muốn thay đổi văn bản ( text ) Button Add To Cart . Hôm nay mình sẽ hướng dẫn thay đổi text Add To Cart bằng hook có sẵn của Woocommerce, tất cả code các bạn thêm vào file function.php của themes.
Thay đổi ở trang sản phẩm
Sử dụng móc lọc add_filter vào woocommerce_product_single_add_to_cart_text . Thay đổi nút add to cart trên trang chi tiết sản phẩm.
//* Change add to cart button text single product page
add_filter(
'woocommerce_product_single_add_to_cart_text'
,
'lv_custom_cart_button_text'
);
function
lv_custom_cart_button_text() {
return
__(
'Buy Product'
,
'woocommerce'
);
}
Thay đổi ở trang danh mục sản phẩm
// Change add to cart button text archive pages .
add_filter(
'woocommerce_product_add_to_cart_text'
,
'lvw_archive_custom_cart_button_text'
);
function
lvw_archive_custom_cart_button_text() {
return
__(
'Buy Product'
,
'woocommerce'
);
}
Thay đổi nút thêm vào giỏ hàng theo tên sản phẩm
// Change the add to cart button by product name.
add_filter(
'woocommerce_product_single_add_to_cart_text'
,
'lv_custom_cart_button_text'
);
add_filter(
'woocommerce_product_add_to_cart_text'
,
'lv_custom_cart_button_text'
);
function
lv_custom_cart_button_text() {
global
$product
;
$id
= get_the_ID();
$title
= get_the_title(
$id
);
return
__(
'Buy '
.
$title
,
'woocommerce'
);
}
Kết luận
Ở bài viết này chúng tôi đã thay đổi button Add To Cart mặc định thành bất kỳ văn bản nào mà chúng tôi muốn, các bạn cũng có thể làm như vậy. Thật sự dễ dàng để làm những điều mình muốn phải không nào.
Chúng tôi hy vọng bạn tìm thấy hướng dẫn này hữu ích. Nếu vậy, hãy xem xét chia sẻ nó với khán giả của bạn!
nice content!nice history!! boba 😀
nice content!nice history!! boba 😀
nice content!nice history!! boba 😀
wow, amazing
[url=https://teplica-teplourala.ru]Теплицы новгород купить.[/url]
[url=https://teplica-teplourala.ru]Прямостенные теплицы от производителя цены.[/url]
[url=https://teplica-teplourala.ru]Теплицы прямостенные от производителя.[/url]
wow, amazing
nice content!nice history!! boba 😀
wow, amazing
nice content!nice history!! boba 😀
nice content!nice history!! boba 😀
wow, amazing
nice content!nice history!! boba 😀
wow, amazing
wow, amazing
nice content!nice history!! boba 😀
wow, amazing
wow, amazing
wow, amazing
nice content!nice history!! boba 😀
nice content!nice history!! boba 😀
wow, amazing
nice content!nice history!! boba 😀
wow, amazing
nice content!nice history!! boba 😀
wow, amazing
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?
naturally like your web site however you need to take a look at the spelling on several of your posts. A number of them are rife with spelling problems and I find it very bothersome to tell the truth on the other hand I will surely come again again.