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 11
Wednesday, March 16, 2016 21:27
% of readers think this story is Fact. Add your two cents.
0

Mời anh chị xem video Hướng dẫn custom woocommerce phần 11

Nội dung video: hướng dẫn custom feature image product (ảnh đại diện sản phẩm ) và gallery product (ảnh sản phẩm: nhiều hình ảnh về sản phẩm)

Trước khi anh chi vào bài viết này nên xem qua bài viết Các khái niệm featured image, thumbnail, add image size là gì?

Một số code liên quan đến video:

  • Remove ảnh đại diện và gallery product mặc định của woocoommerce
remove_action("woocommerce_before_single_product_summary","woocommerce_show_product_images",20);
  • Function lấy ảnh đại diện của sản phẩm và hiển thị thay thế cho hình ảnh mặc định của woocommerce
function custom_get_featured_image(){ global $post; echo get_the_post_thumbnail(get_the_ID(), 'shop_single' ); } add_action("woocommerce_before_single_product_summary","custom_get_featured_image",20);
  • Code thêm tab chứa hình ảnh sản phẩm (gallery product)
add_filter( 'woocommerce_product_tabs', 'add_new_product_tab' ); function add_new_product_tab( $tabs ) { // Adds the new tab $tabs['hinh_anh_san_pham'] = array( 'title' => __( 'Hình ảnh sản phẩm', 'woocommerce' ), 'priority' => 50, 'callback' => 'tab_hinh_san_pham' ); return $tabs; } function tab_hinh_san_pham(){ global $post; $_product_image_gallery = get_post_meta($post->ID,"_product_image_gallery",true); $_product_image_gallerys = explode("," ,$_product_image_gallery); if($_product_image_gallerys): foreach($_product_image_gallerys as $id_image): //$post_thumbnail_id = get_post_thumbnail_id($id_image); $src_thumbnail =wp_get_attachment_image_src($id_image ,'full'); ?> 

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.