Làm sao để Thêm nút MUA NGAY vào chi tiết sản phẩm Woocommerce vậy mọi người, hiện tại nó chỉ có mỗi nút thêm vào giỏ hàng, giờ làm sao để thêm nút Mua Ngay vào sau cái nút thêm vào giỏ hàng được giúp mình với. Giống như hình dưới mình chụp nè, làm soa để có được nút ngày thêm vào
Bạn thêm code sau vào function.php của themes nhé. PHP: add_action('woocommerce_after_add_to_cart_button','cs_quickbuy_after_addtocart_button');function cs_quickbuy_after_addtocart_button(){ global $product; ?> <style> .cs-quickbuy button.single_add_to_cart_button.loading:after { display: none; } .cs-quickbuy button.single_add_to_cart_button.button.alt.loading { color: #fff; pointer-events: none !important; } .cs-quickbuy button.buy_now_button { position: relative; color: rgba(255,255,255,0.05); } .cs-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', 'cstp'); ?> </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('cs-quickbuy'); jQuery('.is_buy_now', thisParent).val('1'); jQuery('.single_add_to_cart_button', thisParent).trigger('click'); }); }); </script> <?php}add_filter('woocommerce_add_to_cart_redirect', 'redirect_to_checkout');function redirect_to_checkout($redirect_url) { if (isset($_REQUEST['is_buy_now']) && $_REQUEST['is_buy_now']) { $redirect_url = wc_get_checkout_url(); //or wc_get_cart_url() } return $redirect_url;} Code mình trước sử dụng lấy của bạn: Lê Văn Toản. Link gốc ở dưới: Mã: https://levantoan.com/them-nut-mua-mgay-vao-woocommerce-mot-cach-don-gian/