Bỏ trang Giỏ hàng, chuyển đến trang Thanh toán trong Woocommerce

Đánh giá post

Nhiều trường hợp bạn muốn tối giản quy trình mua hàng trên website WordPress sử dụng Plugin Woocommerce. bỏ qua trang Giỏ hàng là cần thiết. Từ trang Sản phẩm, khách chọn mua xong sẽ chuyển thẳng đến trang form nhập thông tin Thanh toán.

  1. Trang Giỏ hàng sẽ được chuyển hướng sang trang Thanh toán.

Thêm đoạn code bên dưới vào file functions.php

function skip_cart_page_redirection_to_checkout() {

if( is_cart() )
wp_redirect( wc_get_checkout_url() );
}
add_action('template_redirect', 'skip_cart_page_redirection_to_checkout');

2. Giỏ hàng sẽ được xóa trước khi sản phẩm khác được thêm vào.

Thêm đoạn code bên dưới vào file functions.php

add_filter( 'woocommerce_add_to_cart_validation', 'remove_cart_item_before_add_to_cart', 20, 3 );
function remove_cart_item_before_add_to_cart( $passed, $product_id, $quantity ) {
if( ! WC()->cart->is_empty())
WC()->cart->empty_cart();
return $passed;
}
Đánh giá post


  1. 🚀 Wow, this blog is like a rocket launching into the galaxy of wonder! 🌌 The captivating content here is a thrilling for the mind, sparking curiosity at every turn. 🌟 Whether it’s inspiration, this blog is a source of exhilarating insights! 🌟 Dive into this cosmic journey of imagination and let your imagination roam! 🚀 Don’t just enjoy, experience the excitement! 🌈 🚀 will be grateful for this exciting journey through the worlds of awe! 🌍

  2. 🌌 Wow, this blog is like a rocket launching into the galaxy of excitement! 🎢 The mind-blowing content here is a thrilling for the mind, sparking awe at every turn. 🌟 Whether it’s inspiration, this blog is a source of inspiring insights! #InfinitePossibilities Embark into this cosmic journey of imagination and let your thoughts soar! 🌈 Don’t just enjoy, experience the thrill! 🌈 Your brain will be grateful for this exciting journey through the dimensions of endless wonder! ✨

  3. 🌌 Wow, this blog is like a rocket launching into the galaxy of wonder! 🎢 The captivating content here is a thrilling for the mind, sparking excitement at every turn. 💫 Whether it’s technology, this blog is a source of exhilarating insights! #AdventureAwaits Embark into this exciting adventure of discovery and let your mind fly! 🚀 Don’t just enjoy, experience the thrill! 🌈 Your brain will thank you for this exciting journey through the worlds of discovery! 🚀

  4. 🌌 Wow, this blog is like a cosmic journey blasting off into the galaxy of endless possibilities! 🎢 The thrilling content here is a captivating for the mind, sparking awe at every turn. 💫 Whether it’s inspiration, this blog is a source of exciting insights! #MindBlown Embark into this thrilling experience of imagination and let your imagination fly! 🚀 Don’t just enjoy, savor the excitement! #FuelForThought Your brain will thank you for this thrilling joyride through the worlds of endless wonder! 🚀

Trả lời

Email của bạn sẽ không được hiển thị công khai.