Hiển thị sản phẩm flash sale đã bán như Shopee

Hiển thị sản phẩm flash sale đã bán như Shopee, hiển thị sản phẩm đã bán bao nhiêu, hiển thị sản phẩm đã bán cho khuyến mãi vào các ngày đặc biệt, hiển thị số lượng sản phẩm đã bán giúp tăng mức độ uy tín khi bán hàng. hiển thị đẹp mắt.

Demo đây nhé:

Thêm code vào function.php của theme, nếu xài child theme thì up vào function.php của child theme

add_action('woocommerce_after_shop_loop_item_title', 'isures_2718_product_stock', 11); function isures_2718_product_stock() { global $product; $stock = $product->get_stock_quantity(); $buy = get_post_meta($product->get_id(), 'total_sales', true); if (!empty($stock) && $buy > 0) { $round = round(100 - ($buy * 100 / $stock), 0); ?> <div class="flash-sale-process-isures"> <div class="flash-sale-process_bought"></div> <div class="flash-sale-process-bar_text stock"><?php echo sprintf(__('Đã bán %s', 'woocommerce'), $buy); ?></div> <div class="flash-sale-complete-wapper"> <div class="flash-sale-sizer-stock" style="width:<?php echo $round . '%'; ?>"> <div class="flash-sale-bought-size"></div> </div> </div> <?php if ($buy > 10) { echo '<div class="flash-sale-process_fire"></div>'; } ?> </div> <?php } ?> <?php }

Thêm css ở file Style.css hoặc Flatsome -> Custom CSS

.flash-sale-process-isures{ width: 100%; height: 16px; background: url(https://deo.shopeemobile.com/shopee/shopee-pcmall-live-sg/assets/934cc0df9edb42d22c38044417c8a94a.png) 0 100% no-repeat; background-size: cover; position: relative; border-radius: 8px; margin: 5px 0; } .flash-sale-process_bought{ background: #002bff73; overflow: hidden; bottom: 0; right: 0; position: absolute; z-index: 1; height: 16px; border-radius: 8px; } .flash-sale-process_fire{ background: url(https://deo.shopeemobile.com/shopee/shopee-pcmall-live-sg/assets/d224da21491f6660be6e020e12aff419.png) 0 no-repeat; width: 18px; height: 21px; background-size: contain; position: absolute; left: 3px; top: -6px; } .flash-sale-process-bar_text.stock{ text-transform: uppercase; font-size: 12px; color: #fff; text-align: center; position: relative; z-index: 2; } .flash-sale-complete-wapper{ width: 100%; background: transparent; overflow: hidden; bottom: 0; right: 0; position: absolute; z-index: 1; height: 16px; border-radius: 8px; } .flash-sale-bought-size{ position: absolute; width: 100%; height: 100%; background: #ffbda6; } .flash-sale-sizer-stock{ background: #fff; float: right; position: relative; height: 18px; }

Bạn có thể quan tâm:

Hướng dẫn tăng các thông số PHP trong hosting CPanel

Hướng dẫn tăng các thông số PHP trong hosting với trình quản lý Cpanel. WordPress thường có upload theme và plugin bị quá thời gian phản hồi không thể upload, các plugin như elementor load lâu nên bị treo hay lỗi, hoặc các plugin hoặc khi cài dem..

(Khoảng 1 tháng trước)0

Sửa lỗi Gói lưu trữ không tương thích (Incompatible Archive)

Chào tất cả mọi người, ở phiên bản WordPress 6.4.3 nếu ae gặp lỗi khi upload theme hoặc plugin: Gói lưu trữ không tương thích (Incompatible Archive). Thì hãy giải nén ra rồi Zip lại file bên trong nhé là được nhé. Window thì zip bình thường bằng..

(Khoảng 1 năm trước)0

Xóa đường dẫn /product và /product-category Woocommerce

Mặc định khi cài WordPress và Woocommerce ngôn ngữ tiếng anh sẽ hiện đường dẫn&nbsp;product hoặc product-category, nhưng đường dẫn quá dài và bạn muốn bỏ hết danh mục đó đi chỉ để lại đường dẫn sản phẩm hoặc đường dẫn danh mục cho gọn. Để&nbsp..

(Khoảng 1 năm trước)0

Xóa bỏ đường dẫn /san-pham/ Trong Url Sản Phẩm Woocommerce

Đường dẫn hay còn gọi là Permalink trong WooCommerce sẽ mặc định thêm product-category (danh mục sản phẩm) và product (sản phẩm) &ndash; để phân biệt đường dẫn giữa danh mục sản phẩm và sản phẩm. Mặc định khi cài&nbsp;WooCommerce xong nếu là t..

(Khoảng 1 năm trước)0