Profile image
Tác giả: fcwordpress
Trang tin cá nhân | Bài đã đăng
Lượt xem

Hiện tại:
1h trước:
24h trước:
Tổng số:
Hướng dẫn custom woocommerce – phần 4
Tuesday, January 19, 2016 19:27
% of readers think this story is Fact. Add your two cents.
0

Mời anh chị và các bạn xem video


Tóm tắt nội dung video

  • Cập nhật trạng thái giỏ hàng mini ngay tức thì

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(); ?>  

  • Làm cho trạng thái add to cart xuất hiện icon quay tròn khi gọi sản phẩm ra trang chủ

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; }

  • Viết widget sản phẩm mới (lastest products, recent products)
 '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(); ?>

%s', esc_url( $product->add_to_cart_url() ), $product->id, esc_attr( $product->product_type ), 'Mua ngay' ); echo $add_to_cart_link; ?>
  • Widget hiển thị các sản phẩm nổi bật (featured products)
 '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(); ?>

%s', esc_url( $product->add_to_cart_url() ), $product->id, esc_attr( $product->product_type ), 'Mua ngay' ); echo $add_to_cart_link; ?>

BÌNH LUẬN

Lời bình của bạn
Question   Razz  Sad   Evil  Exclaim  Smile  Redface  Biggrin  Surprised  Eek   Confused   Cool  LOL   Mad   Twisted  Rolleyes   Wink  Idea  Arrow  Neutral  Cry   Mr. Green

Tin nổi bật trong ngày
Tin mới nhất

Register

Newsletter

Email this story
Share This Story:
Print this story
Email this story
Digg
Reddit
StumbleUpon
Share on Tumblr
GET ALERTS:

If you really want to ban this commenter, please write down the reason:

If you really want to disable all recommended stories, click on OK button. After that, you will be redirect to your options page.