Trong shop woo của wordpress anh em hay thêm chức năng Mua hàng nhanh , cài Plugin mua hàng Nhanh của bác Toản ,
có 1 cách thêm mua hàng nhanh không cần cài Plugin , Thêm mua hàng nhanh với short code vừa nhẹ vừa có thể tùy chỉnh theo ý mình hj , bắt đầu nào !

Thêm mua hàng nhanh với short code
Thống kê bài viết
Đầu tiên các bạn cần mở file funcition.php trong thư mục theme mà bạn đang sử dụng lên. Sao chép toàn bộ code bên dưới rồi dán vào file và lưu lại.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
add_action('add_action('woocommerce_after_add_to_cart_button','devvn_quickbuy_after_addtocart_button'); function devvn_quickbuy_after_addtocart_button(){ global $product; ?> <style> .devvn-quickbuy button.single_add_to_cart_button.loading:after { display: none; } .devvn-quickbuy button.single_add_to_cart_button.button.alt.loading { color: #fff; pointer-events: none !important; } .devvn-quickbuy button.buy_now_button { position: relative; color: rgba(255,255,255,0.05); } .devvn-quickbuy button.buy_now_button:after { animation: spin 500ms infinite linear; border: 2px solid #fff; border-radius: 32px; border-right-color: transparent !important; border-top-color: transparent !important; content: ""; display: block; height: 16px; top: 50%; margin-top: -8px; left: 50%; margin-left: -8px; position: absolute; width: 16px; } </style> <button type="button" class="button buy_now_button"> <?php _e('Mua ngay', 'devvn'); ?> </button> <input type="hidden" name="is_buy_now" class="is_buy_now" value="0" autocomplete="off"/> <script> jQuery(document).ready(function(){ jQuery('body').on('click', '.buy_now_button', function(e){ e.preventDefault(); var thisParent = jQuery(this).parents('form.cart'); if(jQuery('.single_add_to_cart_button', thisParent).hasClass('disabled')) { jQuery('.single_add_to_cart_button', thisParent).trigger('click'); return false; } thisParent.addClass('devvn-quickbuy'); jQuery('.is_buy_now', thisParent).val('1'); jQuery('.single_add_to_cart_button', thisParent).trigger('click'); }); }); </script> <?php }','devvn_quickbuy_after_addtocart_button'); function devvn_quickbuy_after_addtocart_button(){ global $product; ?> <style> .devvn-quickbuy button.single_add_to_cart_button.loading:after { display: none; } .devvn-quickbuy button.single_add_to_cart_button.button.alt.loading { color: #fff; pointer-events: none !important; } .devvn-quickbuy button.buy_now_button { position: relative; color: rgba(255,255,255,0.05); } .devvn-quickbuy button.buy_now_button:after { animation: spin 500ms infinite linear; border: 2px solid #fff; border-radius: 32px; border-right-color: transparent !important; border-top-color: transparent !important; content: ""; display: block; height: 16px; top: 50%; margin-top: -8px; left: 50%; margin-left: -8px; position: absolute; width: 16px; } </style> <button type="button" class="button buy_now_button"> <?php _e('Mua ngay', 'devvn'); ?> </button> <input type="hidden" name="is_buy_now" class="is_buy_now" value="0" autocomplete="off"/> <script> jQuery(document).ready(function(){ jQuery('body').on('click', '.buy_now_button', function(e){ e.preventDefault(); var thisParent = jQuery(this).parents('form.cart'); if(jQuery('.single_add_to_cart_button', thisParent).hasClass('disabled')) { jQuery('.single_add_to_cart_button', thisParent).trigger('click'); return false; } thisParent.addClass('devvn-quickbuy'); jQuery('.is_buy_now', thisParent).val('1'); jQuery('.single_add_to_cart_button', thisParent).trigger('click'); }); }); </script> <?php } |
Đoạn code trên tạo ra Short
1 |
[woocommerce_after_add_to_cart_button] |
Thêm Short code vào web
bạn vào
Tùy biến / WooCommerce / Product Page / HTML after Add To Cart button thêm short vào như hình

CÓ THỂ BẠN QUAN TÂM
- AZDIGI bật mí deal bí mật, giảm 90% Hosting 09/2023
- Code phân trang wordpess – Code file functions.php 09/2023
- Code hiển thị các danh mục con trong WordPress 09/2023
- Thêm từ khóa tags đẹp cho wordpress 09/2023
- Hướng dẫn tăng điểm google pagespeed insights lên xanh 09/2023
- Hiển thị số lượng sản phẩm đã bán trong Woocommerce wordpress 09/2023
OK ra web xem kết quả và thử luôn chức năng nào 🙂
Ngoài ra , Nếu anh em quan tâm có thể dùng trực tiếp
Plugin của bác Toản tại đây Giá 300k / 1 domain nhé
Nếu bạn không làm được hoặc làm có vấn đề gì để lại commem tớ sẽ giúp nhé
Chúc bạn thành công nhé !