Lượt xem | |
Hiện tại: | |
1h trước: | |
24h trước: | |
Tổng số: |
Mời anh chị và các bạn xem video
Tóm tắt nội dung video
Có nghĩa là khi khách hàng click vào nút add to cart thì ngay lập tức số lượng và tổng giá trị đơn hàng được hiển thị trên giỏ hàng mini mà không cần refresh trang
Code làm việt này:
add_filter('add_to_cart_fragments', 'woocommerce_header_add_to_cartplus_fragment', '1'); function woocommerce_header_add_to_cartplus_fragment( $fragments ) { global $woocommerce; ob_start(); ?> cart->cart_contents_count, 'woothemes'), WC()->cart->cart_contents_count);?> - cart->get_cart_total(); ?>
Khi khách hàng click add to cart thì anh chị thấy rằng có xuất hiện một icon quay tròn, để chỉ trạng thái sản phẩm được đang được thêm vào, tuy nhiên khi ngoài trang chủ class woocommerce không được add vào thẻ body nên chúng ta sẽ không thấy điều đó, bây giờ chúng ta phải đi add nó vào
add_filter( 'body_class', 'tung_class_names' ); function tung_class_names( $classes ) { // add 'class-name' to the $classes array $classes[] = 'woocommerce'; // return the $classes array return $classes; }
'Lastest products'); $control_ops = array('width' => 300, 'height' => 300); parent::WP_Widget(false,$name='Lastest products',$widget_ops,$control_ops); } function form($instance){ global $wpdb; //Defaults $instance = wp_parse_args( (array) $instance, array('title'=>'','numbershow'=>'') ); $title = htmlspecialchars($instance['title']); $numbershow = htmlspecialchars($instance['numbershow']); ?>
'product', 'posts_per_page' => $numbershow, 'post_status' => 'publish' ); $wp_query = new WP_Query( $args ); if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
'Products featured'); $control_ops = array('width' => 300, 'height' => 300); parent::WP_Widget(false,$name='Products featured',$widget_ops,$control_ops); } function form($instance){ global $wpdb; //Defaults $instance = wp_parse_args( (array) $instance, array('title'=>'','numbershow'=>'') ); $title = htmlspecialchars($instance['title']); $numbershow = htmlspecialchars($instance['numbershow']); ?>
'product', 'meta_key' => '_featured', 'meta_value' => 'yes', 'meta_compare' => '=', 'posts_per_page' => $numbershow, 'post_status' => 'publish' ); $wp_query = new WP_Query( $args ); if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
2016-01-19 18:26:06
Nguồn: http://fcwordpress.net/huong-dan-custom-woocommerce-phan-4.html