Các bạn copy đoạn code dưới đây vào file function nhé.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
function footerfixed(){ ob_start();?> <?php if(wp_is_mobile() && is_product()){;?> <div class="footer-fixed"> <div class="col1"> <a href="#linkchatfb"> <i class="fab fa-facebook-messenger"></i> <span>Tư vấn</span> </a> </div> <div class="col2"> <a id="addtocart" href="#"> <i class="fa fa-cart-plus" aria-hidden="true"></i> <span> Mua ngay</span> </a> </div> </div> <?php };?> <?php $list_post = ob_get_contents(); ob_end_clean(); return $list_post; } add_shortcode('footerfixed','footerfixed'); |
Và đoạn script này
1 2 3 4 5 6 7 8 9 |
function script_menu_footer_pttuan(){;?> <script> jQuery(document).ready(function ($) { var id = $('.single_add_to_cart_button').val(); $('#addtocart').attr("href", "?add-to-cart="+id); }); </script> <?php } add_action('wp_footer','script_menu_footer_pttuan'); |
Và cuối cùng là css
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
.footer-fixed { display: flex; position: fixed; width: 100%; left: 0; bottom: 0; z-index: 10; border-top: 1px solid #e5e5e5; text-transform: uppercase; } .footer-fixed .col1 { background: #ffad00; } .footer-fixed div { text-align: center; width: 50%; padding: 10px 0; } .footer-fixed .col2 { background: #62862b; } .footer-fixed div span { margin-left: 10px; } |
Để có thể sử dụng được thì các bạn copy short code [footerfixed] và dán vào footer của website nhé.
Ở trên đây mình chỉ cho hiển thị ở trang sản phẩm thôi. Các bạn có thể thay link chat fb của mình vào link mặc định mà mình đang sử dụng nhé. Ngoài ra thì icon mình sử dụng thuộc font-awsome nên các bạn phải import vào trước nhé.
Phần này mình ngại viết một số mình coppy trên mạng xã hội.
Còn các bạn muốn tự động vào gian hàng trong woo nó hiện lên giống shoppe, thì liên hệ mình nhé. Mình sẽ lấy giá rẻ cho các bạn