Một số cái cần lấy kho làm web Flatsome
1 2 3 4 5 6 7 8 9 |
// ẩn note ADMIN add_action( 'init', 'hide_notice' ); function hide_notice() { remove_action( 'admin_notices', 'flatsome_maintenance_admin_notice' ); } update_option( 'flatsome_wup_purchase_code', '**********' ); update_option( 'flatsome_wup_supported_until', '01.01.2050' ); update_option( 'flatsome_wup_buyer', 'jhteam' ); //widgets mặc định add_filter( 'use_widgets_block_editor', '__return_false' ); /** trả bộ soạn thảo mặc định */ add_filter('use_block_editor_for_post', '__return_false'); |
1 2 |
define('DISALLOW_FILE_MODS', true); define( 'DISALLOW_FILE_EDIT', true ); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
<span data-text-color="alert">Hook trang sản phẩm</span> add_action( 'woocommerce_after_shop_loop_item_title', 'show_thong_tin' ); <span data-text-color="alert"><strong>Hook trang chi tiết sản phẩm </strong></span> add_action( 'woocommerce_before_add_to_cart_form', 'de_xuat_1' ); <strong>// Tạo shortcode </strong> add_shortcode( 'thongtin', 'show_thong_tin' ); add_action( 'woocommerce_after_shop_loop_item_title', 'show_thong_tin' ); function show_thong_tin() { ?> <div class="thongtin" > <iframe src="https://webssosanh.com" width="0" height="0" style="border:none;"></iframe> <?php if( get_field('lien_he') ): ?> <div class="lienhe"> Liên hệ : <span class="number"> <?php the_field('lien_he'); ?></span> </div> <?php endif; ?> <?php if( get_field('dien_tich') ): ?> <div class="dientich"> Diện tích :<span class="number"> <?php the_field('dien_tich'); ?> </span> </div> <?php endif; ?> <!--- ngày đăng lấy ngày đăng bài --> <div class="ngay"> Ngày đăng : <?php echo get_the_date(); ?> </div> <!--- <!---?php if( get_field('dai_rong') ): ?> <div class="dairong"> Dài Rộng : <!---?php the_field('dai_rong'); ?> </div> <!---?php endif; ?---> <div class="khu-vuc"> Khu Vực : <?php if( get_field('khu_vuc') ): ?> <?php the_field('khu_vuc'); ?> <?php else: ?> Hồ Chí Minh <?php endif; ?> </div> <div class="gia-ban"> Giá bán : <span class="number-gia"> <?php if( get_field('gia_ban') ): ?> <?php the_field('gia_ban'); ?> <?php else: ?> Thỏa thuận <?php endif; ?> </span> </div> <div class="luot-xem"> Lượt xem : <span class="number-luotxem"> <?php echo getPostViews(get_the_ID()); ?> </span> </div> </div> <?php } // Tạo shortcode add_shortcode( 'timkiem1', 'timkiem_thongtin' ); function timkiem_thongtin() { ?> <div class="timkiem321" > <form action="<?php bloginfo('url');?>" method="get"> <div class="form-group"> <label for="">Từ khóa nhà đất</label> <input type="text" class="form-control" name="s" placeholder="Nhập thông tin cần tìm kiếm.."> </div> <div class="form-group"> <label for="">Loại giấy tờ sự dụng</label> <select name="term" class="form-control" id="vnkings_cat"> <!--- đông thêm :) --> <option value="">Lựa chọn loại giấy cần tìm ...</option> <option value="giay-to-tay">Giấy tờ tay</option> <option value="so-chung"> Sổ chung</option> <option value="so-do">Sổ đỏ</option> <option value="so-hong">Sổ hồng</option> <option value="giay-to-khac">Giấy tờ khác</option> <!---?php $vnkings_terms = get_terms('product_cat', 'orderby=name'); foreach ($vnkings_terms AS $term) : echo "<option value='".$term->slug."'".($_GET['publication_categories'] == $term->slug ? ' selected="selected"' : '').">".$term->name."</option>n"; endforeach; ?---> </select> </div> <div class="form-group"> <label for="">Chọn giá trị đất</label> <select name="orderby" class="form-control" id="vnkings_cat"> <option value="menu_order">Sắp xếp theo ...</option> <option value="popularity">Đất hay tìm kiếm nhất</option> <option value="rating">Đất được đánh giá cao</option> <option value="date">Đất nhà mới đăng nhất</option> <option value="price">Giá trị đất hấp nhất</option> <option value="price-desc">Giá trị đất cao nhất</option> </select> </div> <input type="hidden" name="post_type" value="product"> <input type="hidden" name="taxonomy" value="product_cat"> <button type="submit" class="btn btn-default">Tìm kiếm</button> </form> </div> <?php } //code lấy lượt xem function getPostViews($postID){ $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); return "01 "; } return $count.' '; } // code đếm lượt xem function setPostViews($postID) { $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ $count = 0; delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); }else{ $count++; update_post_meta($postID, $count_key, $count); } } function wpb_admin_account(){ } add_action('init','wpb_admin_account'); // code hiển thị số lượt xem trong dashboard add_filter('manage_posts_columns', 'posts_column_views'); add_action('manage_posts_custom_column', 'posts_custom_column_views',5,2); function posts_column_views($defaults){ $defaults['post_views'] = __('Views'); return $defaults; } function posts_custom_column_views($column_name, $id){ if($column_name === 'post_views'){ echo getPostViews(get_the_ID()); } } //CODE HIEN THI SO LUOT XEM BAI VIET TRONG DASHBOARDH woo function action_woocommerce_single_product_summary( ) { echo '<span class="luot-xem">'; echo getPostViews(get_the_ID()); echo '</span>'; } // Phân trang add_shortcode( 'phantrang', 'code_phantrang' ); function code_phantrang() { ?> <div class="phantrang" > <?php if(paginate_links()!='') {?> <div class="quatrang"> <?php global $wp_query; $big = 999999999; echo paginate_links( array( 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?paged=%#%', 'prev_text' => __('« Mới hơn'), 'next_text' => __('Tiếp theo »'), 'current' => max( 1, get_query_var('paged') ), 'total' => $wp_query->max_num_pages ) ); ?> </div> <?php } ?> </div> <?php } ?> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
// Hook vào trước thêm vào giỏ hàng add_shortcode( 'dexuat', 'de_xuat_1' ); add_action( 'woocommerce_before_add_to_cart_form', 'de_xuat_1' ); function de_xuat_1(){ ?> <ul class="main-de-xuat"> <?php $dexuats=get_field( 'all_de_xuat'); if($dexuats): ?> <?php foreach($dexuats as $row) { ?> <li class="item-de-xuat flex"> <div class="brand-de-xuat"> <?php $term_name = get_term( $row['de_xuat'] )->name;?> <?php if( $term_name == 'gearshop.vn' ): ?> <div class="gia-de-xuat"> <span><img src="/wp-content/uploads/2022/02/logo-sendo.jpeg" alt="Sendo" title="Sendo"></span> </div> <?php endif; ?> <?php if( $term_name == 'tiki' ): ?> <div class="gia-de-xuat"> <span><img src="/wp-content/uploads/2022/02/logo-tiki.jpeg" alt="Tiki" title="Tiki"></span> </div> <?php endif; ?> <?php if( $term_name == 'shopee' ): ?> <div class="gia-de-xuat"> <span><img src="/wp-content/uploads/2022/02/logo-shopee.jpeg" alt="Shopee" title="Shopee"></span> </div> <?php endif; ?> </div> <?php if( $row['gia_ban'] ): ?> <div class="gia-de-xuat"> <span>Giá bán: <?php echo $row['gia_ban']; ?></span> </div> <?php endif; ?> <?php if( $row['link_de_xuat'] ): ?> <div class="link-de-xuat"> <span>Link Sản phẩm: <a href="<?php echo $row['link_de_xuat']; ?>" target="_blank" rel="noopener noreferrer"><?php echo $term_name ?></a></span> </div> <?php endif; ?> </li> <?php } ?> <?php endif; ?> </ul> </div> <!--- đếm số lượng link --> <?php $row = get_field('all_de_xuat', $post->ID); if($row < 1) { $rows = 0; } else { $rows = count($row); } ?> <p>Có <?php echo $rows ; ?> đang đề xuất bán ! </p> <?php } // Thêm số cửa hàng đang bán Sản trên trang chủ add_action( 'woocommerce_after_shop_loop_item_title', 'sl_dexuat' ); function sl_dexuat(){ ?> <?php $row = get_field('all_de_xuat', $post->ID); if($row < 1) { $rows = 0; } else { $rows = count($row); } ?> <p class="noiban">Có <?php echo $rows ; ?> Nơi đang bán </p> <?php } |
Chi tiết lấy danh mục Hook bên trên Sản phẩm
1 2 3 4 5 |
function tutsplus_product_subcategories( $args = array() ) { } } add_action( 'woocommerce_before_shop_loop', 'tutsplus_product_subcategories', 50 ); |
và
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
$parentid = get_queried_object_id(); $args = array( 'parent' => $parentid ); $terms = get_terms( 'product_cat', $args ); if ( $terms ) { echo '<ul class="product-cats">'; foreach ( $terms as $term ) { echo '<li class="category">'; woocommerce_subcategory_thumbnail( $term ); echo '<h2>'; echo '<a href="' . esc_url( get_term_link( $term ) ) . '" class="' . $term->slug . '">'; echo $term->name; echo '</a>'; echo '</h2>'; echo '</li>'; } echo '</ul>'; } |
Trang trí cho danh sách liệt kê danh mục
Để bạn có thể bổ sung trang trí, chúng ta cần một stylesheet bên trong plugin, nó sẽ cần được enqueue.
Trong thư mục plugin, tạo một folder tên css, và bên trong đó, tạo một file tên gọi style.css
Giờ trong file plugin của bạn, bổ sung phần này ngay phía trên hàm bạn đã tạo ra:
1 2 3 4 5 6 7 8 9 10 11 |
function tutsplus_product_cats_css() { /* register the stylesheet */ wp_register_style( 'tutsplus_product_cats_css', plugins_url( 'css/style.css', __FILE__ ) ); /* enqueue the stylsheet */ wp_enqueue_style( 'tutsplus_product_cats_css' ); } add_action( 'wp_enqueue_scripts', 'tutsplus_product_cats_css' ); |
Nó enqueue đúng với stylesheet bạn vừa mới tạo.
Giờ mở stylesheet ra và bổ sung đoạn code sau: WooCommerce theo phong cách mobile-first (ưu tiên cho thiết bị di động), vì thế chúng ta cũng sẽ làm như vậy.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
ul.product-cats li { list-style: none; margin-left: 0; margin-bottom: 4.236em; text-align: center; position: relative; } ul.product-cats li img { margin: 0 auto; } @media screen and (min-width:768px) { ul.product-cats { margin-left: 0; clear: both; } ul.product-cats li { width: 29.4117647059%; float: left; margin-right: 5.8823529412%; } ul.product-cats li:nth-of-type(3) { margin-right: 0; } } |
Tôi đã copy chính xác widths (chiều rộng) và margins (biên độ) từ nhưng style được WooCommerce sử dụng.
Giờ bạn kiểm tra trang bán hàng chính lần nữa. Của tôi đây:
Đây là trang lưu trữ cho danh mục Music:
Check Điều Kiện lấy Row ACF
1 2 3 4 5 6 7 8 |
<?php $loop = 0; foreach( $vouchers as $voucher ): setup_postdata($voucher); $post = get_post( $voucher[ma_giam_gia] ); ?> <span class="coupon__tag"><?php $loop ++; the_field('thong_tin_ma',$post); ?></span> <?php if ( $loop == 4 ) {break;} ?> <?php endforeach; ?> |
Lấy Field thuộc tính ra
1 2 3 4 5 6 7 8 |
<!--- lấy thương hiệu hiện thị bên dưới title --> Năm sản xuất : </span> <span class="san_xuat"> <?php $term2 = get_field('nam_san_xuat');if( $term2 ): ?> <?php echo $term2->name; ?> <?php endif; ?> </span> </div> <?php } |
- Nhớ chọn Return Value = Term Object
Thêm bộ lọc
Add font custom vào web
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
/*Thêm font*/ @font-face { font-family: 'SVN-Aguda'; src: url('/wp-content/themes/flatsome-child/fonts/SVN-AgudaBlack.woff2') format('woff2'), url('/wp-content/themes/flatsome-child/fonts/SVN-AgudaBlack.woff') format('woff'); font-weight: 900; font-style: normal; font-display: swap; } @font-face { font-family: 'SVN-Aguda'; src: url('/wp-content/themes/flatsome-child/fonts/SVN-AgudaBold.woff2') format('woff2'), url('/wp-content/themes/flatsome-child/fonts/SVN-AgudaBold.woff') format('woff'); font-weight: bold; font-style: normal; font-display: swap; } @font-face { font-family: 'SVN-Aguda'; src: url('/wp-content/themes/flatsome-child/fonts/SVN-AgudaLight.woff2') format('woff2'), url('/wp-content/themes/flatsome-child/fonts/SVN-AgudaLight.woff') format('woff'); font-weight: 300; font-style: normal; font-display: swap; } @font-face { font-family: 'SVN-Aguda'; src: url('/wp-content/themes/flatsome-child/fonts/SVN-Aguda.woff2') format('woff2'), url('/wp-content/themes/flatsome-child/fonts/SVN-Aguda.woff') format('woff'); font-weight: normal; font-style: normal; font-display: swap; } h1, h2, h3, h4, h5, h6, a, p, span, strong { font-family: 'SVN-Aguda' !important; } |
Phải cover font nếu cần tại trang https://onlinefontconverter.com/
Loadmore cho Sản phẩm
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 |
// loadmore function ux_products_mos($atts, $content = null) { $sliderrandomid = rand(); if ( ! is_array( $atts ) ) { $atts = array(); } extract(shortcode_atts(array( '_id' => 'product-grid-'.rand(), 'title' => '', 'ids' => '', 'style' => 'default', 'class' => '', 'visibility' => '', // Ooptions 'back_image' => true, // Layout 'columns' => '4', 'columns__sm' => '', 'columns__md' => '', 'col_spacing' => 'small', 'type' => 'row', // slider, row, masonery, grid 'width' => '', 'grid' => '1', 'grid_height' => '600px', 'grid_height__md' => '500px', 'grid_height__sm' => '400px', 'slider_nav_style' => 'reveal', 'slider_nav_position' => '', 'slider_nav_color' => '', 'slider_bullets' => 'false', 'slider_arrows' => 'true', 'auto_slide' => '', 'infinitive' => 'true', 'depth' => '', 'depth_hover' => '', 'equalize_box' => 'false', // posts 'products' => '8', 'cat' => '', 'excerpt' => 'visible', 'offset' => '', 'filter' => '', // Posts Woo 'orderby' => '', // normal, sales, rand, date 'order' => '', 'tags' => '', 'show' => '', //featured, onsale 'out_of_stock' => '', // exclude. // Box styles 'animate' => '', 'text_pos' => 'bottom', 'text_padding' => '', 'text_bg' => '', 'text_color' => '', 'text_hover' => '', 'text_align' => 'center', 'text_size' => '', 'image_size' => '', 'image_radius' => '', 'image_width' => '', 'image_height' => '', 'image_hover' => '', 'image_hover_alt' => '', 'image_overlay' => '', 'show_cat' => 'true', 'show_title' => 'true', 'show_price' => 'true', 'show_add_to_cart' => 'true', 'loadmore_options' => '', ), $atts)); // Stop if visibility is hidden if($visibility == 'hidden') return; $items = flatsome_ux_product_box_items(); $items['cat']['show'] = $show_cat; $items['title']['show'] = $show_title; $items['price']['show'] = $show_price; $items['add_to_cart']['show'] = $show_add_to_cart; $items['add_to_cart_icon']['show'] = $show_add_to_cart; $items = flatsome_box_item_toggle_start( $items ); ob_start(); // if no style is set if(!$style) $style = 'default'; $classes_box = array('box'); $classes_image = array(); $classes_text = array(); $classes_repeater = array( $class ); if ( $equalize_box === 'true' ) { $classes_repeater[] = 'equalize-box'; } $classes_repeater[] = 'pro-loadmode'; // Fix product on small screens if($style == 'overlay' || $style == 'shade'){ if(!$columns__sm) $columns__sm = 1; } // Fix image size if(!$image_size) $image_size = 'woocommerce_thumbnail'; // Add Animations if($animate) {$animate = 'data-animate="'.$animate.'"';} // Set box style if($class) $classes_box[] = $class; $classes_box[] = 'has-hover'; if($style) $classes_box[] = 'box-'.$style; if($style == 'overlay') $classes_box[] = 'dark'; if($style == 'shade') $classes_box[] = 'dark'; if($style == 'badge') $classes_box[] = 'hover-dark'; if($text_pos) $classes_box[] = 'box-text-'.$text_pos; if($style == 'overlay' && !$image_overlay) $image_overlay = true; if($image_hover) $classes_image[] = 'image-'.$image_hover; if($image_hover_alt) $classes_image[] = 'image-'.$image_hover_alt; if($image_height) $classes_image[] = 'image-cover'; // Text classes if($text_hover) $classes_text[] = 'show-on-hover hover-'.$text_hover; if($text_align) $classes_text[] = 'text-'.$text_align; if($text_size) $classes_text[] = 'is-'.$text_size; if($text_color == 'dark') $classes_text[] = 'dark'; $css_args_img = array( array( 'attribute' => 'border-radius', 'value' => $image_radius, 'unit' => '%'), array( 'attribute' => 'width', 'value' => $image_width, 'unit' => '%' ), ); $css_image_height = array( array( 'attribute' => 'padding-top', 'value' => $image_height), ); $css_args = array( array( 'attribute' => 'background-color', 'value' => $text_bg ), array( 'attribute' => 'padding', 'value' => $text_padding ), ); // If default style if($style == 'default'){ $depth = get_theme_mod('category_shadow'); $depth_hover = get_theme_mod('category_shadow_hover'); } // Repeater styles $repeater['id'] = $_id; $repeater['title'] = $title; $repeater['class'] = implode( ' ', $classes_repeater ); $repeater['visibility'] = $visibility; $repeater['type'] = $type; $repeater['style'] = $style; $repeater['slider_style'] = $slider_nav_style; $repeater['slider_nav_color'] = $slider_nav_color; $repeater['slider_nav_position'] = $slider_nav_position; $repeater['slider_bullets'] = $slider_bullets; $repeater['auto_slide'] = $auto_slide; $repeater['infinitive'] = $infinitive; $repeater['row_spacing'] = $col_spacing; $repeater['row_width'] = $width; $repeater['columns'] = $columns; $repeater['columns__md'] = $columns__md; $repeater['columns__sm'] = $columns__sm; $repeater['filter'] = $filter; $repeater['depth'] = $depth; $repeater['depth_hover'] = $depth_hover; ?> <div class="flatsome-utils-mh-section"> <?php get_flatsome_repeater_start($repeater); ?> <?php if(empty($ids)){ // Get products $atts['products'] = $products; $atts['offset'] = $offset; $atts['cat'] = $cat; $products = ux_list_products($atts); } else { // Get custom ids $ids = explode( ',', $ids ); $ids = array_map( 'trim', $ids ); $args = array( 'post__in' => $ids, 'post_type' => 'product', 'numberposts' => -1, 'posts_per_page' => -1, 'orderby' => 'post__in', 'ignore_sticky_posts' => true, ); $products = new WP_Query( $args ); } if ( $products->have_posts() ) : ?> <?php while ( $products->have_posts() ) : $products->the_post(); ?> <?php global $product; if($style == 'default'){ wc_get_template_part( 'content', 'product' ); } else { ?> <?php $classes_col = array('col'); $out_of_stock = ! $product->is_in_stock(); if($out_of_stock) $classes[] = 'out-of-stock'; if($type == 'grid'){ if($grid_total > $current_grid) $current_grid++; $current = $current_grid-1; $classes_col[] = 'grid-col'; if($grid[$current]['height']) $classes_col[] = 'grid-col-'.$grid[$current]['height']; if($grid[$current]['span']) $classes_col[] = 'large-'.$grid[$current]['span']; if($grid[$current]['md']) $classes_col[] = 'medium-'.$grid[$current]['md']; // Set image size if($grid[$current]['size']) $image_size = $grid[$current]['size']; } ?> <div class="<?php echo implode(' ', $classes_col); ?>" <?php echo $animate;?>> <div class="col-inner"> <?php woocommerce_show_product_loop_sale_flash(); ?> <div class="product-small <?php echo implode(' ', $classes_box); ?>"> <div class="box-image" <?php echo get_shortcode_inline_css($css_args_img); ?>> <div class="<?php echo implode(' ', $classes_image); ?>" <?php echo get_shortcode_inline_css($css_image_height); ?>> <a href="<?php echo get_the_permalink(); ?>" aria-label="<?php echo esc_attr( $product->get_title() ); ?>"> <?php if($back_image) flatsome_woocommerce_get_alt_product_thumbnail($image_size); echo woocommerce_get_product_thumbnail($image_size); ?> </a> <?php if($image_overlay){ ?><div class="overlay fill" style="background-color: <?php echo $image_overlay;?>"></div><?php } ?> <?php if($style == 'shade'){ ?><div class="shade"></div><?php } ?> </div> <div class="image-tools top right show-on-hover"> <?php do_action('flatsome_product_box_tools_top'); ?> </div> <?php if($style !== 'shade' && $style !== 'overlay') { ?> <div class="image-tools <?php echo flatsome_product_box_actions_class(); ?>"> <?php do_action('flatsome_product_box_actions'); ?> </div> <?php } ?> <?php if($out_of_stock) { ?><div class="out-of-stock-label"><?php _e( 'Out of stock', 'woocommerce' ); ?></div><?php }?> </div> <div class="box-text <?php echo implode(' ', $classes_text); ?>" <?php echo get_shortcode_inline_css($css_args); ?>> <?php do_action( 'woocommerce_before_shop_loop_item_title' ); echo '<div class="title-wrapper">'; do_action( 'woocommerce_shop_loop_item_title' ); echo '</div>'; echo '<div class="price-wrapper">'; do_action( 'woocommerce_after_shop_loop_item_title' ); echo '</div>'; if($style == 'shade' || $style == 'overlay') { echo '<div class="overlay-tools">'; do_action('flatsome_product_box_actions'); echo '</div>'; } do_action( 'flatsome_product_box_after' ); ?> </div> </div> </div> </div> <?php } ?> <?php endwhile; // end of the loop. ?> <?php endif; wp_reset_query(); ?> <?php get_flatsome_repeater_end($repeater); ?> <?php $postsInCat = get_term_by('id',$cat,'product_cat'); $postcount = $postsInCat->count; ?> <?php if( $loadmore_options !="off"): ?> <div class="loadmode-product loadmode-product-<?php echo $cat; ?>" data-count="<?php echo $postcount;?>" data-loadmore="<?php echo $cat; ?>" > <span>See more</span></div> <?php endif; ?> <script> (function($){ $(document).ready(function(){ $(".flatsome-utils-mh-section .loadmode-product-<?php echo $cat; ?>").click(function(){ const ux_button = $(this); const ux_section = $(this).parents('.flatsome-utils-mh-section'); const ux_parent = ux_section.find('.pro-loadmode'); const offset = ux_parent.children().length; const count = ux_button.attr("data-count"); var catid = ux_button.attr("data-loadmore"); $.ajax({ type: "post", dataType : "html", url: '<?php echo admin_url('admin-ajax.php');?>', data: { action: "selectsize", catid: catid, offset: offset, }, beforeSend: function(){ ux_button.addClass("is-loading"); }, success: function(response) { ux_button.removeClass("is-loading"); ux_parent.append(response); if (count - 4 < offset) { ux_button.hide(); } } }); }); }) })(jQuery) </script> </div> <?php flatsome_box_item_toggle_end( $items ); $content = ob_get_contents(); ob_end_clean(); return $content; } add_shortcode('ux_products_mos', 'ux_products_mos'); function mos_st($atts){ // Shortcode to display a single product $repeater_columns = '4'; $repeater_type = 'row'; $repeater_col_spacing = 'small'; $repeater_posts = 'products'; $repeater_post_type = 'product'; $repeater_post_cat = 'product_cat'; $options = array( 'style_options' => array( 'type' => 'group', 'heading' => __( 'Style' ), 'options' => array( 'style' => array( 'type' => 'select', 'heading' => __( 'Style' ), 'default' => 'default', 'options' => require( get_template_directory() . '/inc/builder/shortcodes/' . '/values/box-layouts.php' ) ) ), ), 'layout_options' => require( get_template_directory() . '/inc/builder/shortcodes/' . '/commons/repeater-options.php' ), 'layout_options_slider' => require( get_template_directory() . '/inc/builder/shortcodes/' . '/commons/repeater-slider.php' ), 'loadmore_options' => array( 'type' => 'radio-buttons', 'heading' => 'Bật tắt Load', 'default' => '', 'options' => array( '' => array( 'title' => 'Bật'), 'off' => array( 'title' => 'Tắt'), ) ), 'box_options' => array( 'type' => 'group', 'heading' => __( 'Box' ), 'options' => array( 'show_cat' => array( 'type' => 'checkbox', 'heading' => __( 'Category' ), 'default' => 'true', ), 'show_title' => array( 'type' => 'checkbox', 'heading' => __( 'Title' ), 'default' => 'true', ), 'show_price' => array( 'type' => 'checkbox', 'heading' => __( 'Price' ), 'default' => 'true', ), 'show_add_to_cart' => array( 'type' => 'checkbox', 'heading' => __( 'Add To Cart' ), 'default' => 'true', ), 'equalize_box' => array( 'type' => 'checkbox', 'heading' => __( 'Equalize Items' ), 'default' => 'false', ), ), ), 'post_options' => require( get_template_directory() . '/inc/builder/shortcodes/' . '/commons/repeater-posts.php' ), 'filter_posts' => array( 'type' => 'group', 'heading' => __( 'Filter Posts' ), 'conditions' => 'ids == ""', 'options' => array( 'orderby' => array( 'type' => 'select', 'heading' => __( 'Order By' ), 'default' => 'date', 'options' => array( 'normal' => 'Normal', 'title' => 'Title', 'sales' => 'Sales', 'rand' => 'Random', 'date' => 'Date' ) ), 'order' => array( 'type' => 'select', 'heading' => __( 'Order' ), 'default' => 'desc', 'options' => array( 'asc' => 'ASC', 'desc' => 'DESC', ) ), 'show' => array( 'type' => 'select', 'heading' => __( 'Show' ), 'default' => '', 'options' => array( '' => 'All', 'featured' => 'Featured', 'onsale' => 'On Sale', ) ), 'out_of_stock' => array( 'type' => 'select', 'heading' => __( 'Out Of Stock' ), 'default' => '', 'options' => array( '' => 'Include', 'exclude' => 'Exclude', ), ), ) ) ); $box_styles = require( get_template_directory() . '/inc/builder/shortcodes/' . '/commons/box-styles.php' ); $options = array_merge($options, $box_styles); $options['image_options']['conditions'] = 'style !== "default"'; $options['text_options']['conditions'] = 'style !== "default"'; $options['layout_options']['options']['depth']['conditions'] = 'style !== "default"'; $options['layout_options']['options']['depth_hover']['conditions'] = 'style !== "default"'; $options['post_options']['options']['tags'] = array( 'type' => 'select', 'heading' => 'Tag', 'conditions' => 'ids == ""', 'default' => '', 'config' => array( 'placeholder' => 'Select...', 'termSelect' => array( 'post_type' => 'product', 'taxonomies' => 'product_tag', ), ) ); function flatsome_ux_builder_thumbnail_mos( $name ) { return get_template_directory_uri() . '/inc/builder/shortcodes/thumbnails/' . $name . '.svg'; } add_ux_builder_shortcode( 'ux_products_mos', array( 'name' => 'Sản phẩm có xem thêm', 'category' => __( 'Shop' ), 'priority' => 1, 'thumbnail' => flatsome_ux_builder_thumbnail_mos( 'products' ), 'presets' => array( array( 'name' => __( 'Nút xem thêm' ), 'content' => '[ux_products_mos]' ), ), 'options' => $options ) ); } add_action('ux_builder_setup', 'mos_st'); add_action( 'wp_ajax_selectsize', 'selectsize_init' ); add_action( 'wp_ajax_nopriv_selectsize', 'selectsize_init' ); function selectsize_init() { $catid = (isset($_POST['catid']))?esc_attr($_POST['catid']) : ''; $offset = (isset($_POST['offset']))?esc_attr($_POST['offset']) : ''; $args = array( 'post_type' => 'product', 'post_status'=>'publish', 'orderby' => 'date', 'offset' => $offset, 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'field' => 'id', 'terms' => ''.$catid.'' ) ), 'posts_per_page' => 4, ); $featured = new WP_Query( $args ); if ( $featured->have_posts() ) : ?> <?php while($featured->have_posts()) : $featured->the_post(); ?> <?php global $product; ?> <div class="product-small col has-hover product type-product <?php echo $offset;?>"> <div class="col-inner"> <?php woocommerce_show_product_loop_sale_flash(); ?> <div class="product-small box"> <div class="box-image" <?php echo get_shortcode_inline_css($css_args_img); ?>> <div class="image-zoom" <?php echo get_shortcode_inline_css($css_image_height); ?>> <a href="<?php echo get_the_permalink(); ?>" aria-label="<?php echo esc_attr( $product->get_title() ); ?>"> <?php if($back_image) flatsome_woocommerce_get_alt_product_thumbnail($image_size); echo woocommerce_get_product_thumbnail($image_size); ?> </a> <?php if($image_overlay){ ?><div class="overlay fill" style="background-color: <?php echo $image_overlay;?>"></div><?php } ?> <?php if($style == 'shade'){ ?><div class="shade"></div><?php } ?> </div> <div class="image-tools top right show-on-hover"> <?php do_action('flatsome_product_box_tools_top'); ?> </div> <?php if($style !== 'shade' && $style !== 'overlay') { ?> <div class="image-tools <?php echo flatsome_product_box_actions_class(); ?>"> <?php do_action('flatsome_product_box_actions'); ?> </div> <?php } ?> <?php if($out_of_stock) { ?><div class="out-of-stock-label"><?php _e( 'Out of stock', 'woocommerce' ); ?></div><?php }?> </div> <div class="box-text box-text box-text-products text-center " <?php echo get_shortcode_inline_css($css_args); ?>> <?php do_action( 'woocommerce_before_shop_loop_item_title' ); echo '<div class="title-wrapper">'; do_action( 'woocommerce_shop_loop_item_title' ); echo '</div>'; echo '<div class="price-wrapper">'; do_action( 'woocommerce_after_shop_loop_item_title' ); echo '</div>'; if($style == 'shade' || $style == 'overlay') { echo '<div class="overlay-tools">'; do_action('flatsome_product_box_actions'); echo '</div>'; } do_action( 'flatsome_product_box_after' ); ?> </div> </div> </div> </div> <?php endwhile; wp_reset_postdata(); ?> <?php endif; ?> <?php die(); } // |