Skip to content

Instantly share code, notes, and snippets.

@webantam43
webantam43 / Hiển thị "(có 0 đánh giá)" khi sản phẩm chưa có đánh giá - WooCommerce & Flatsome
Created May 3, 2025 11:46
Hiển thị "(có 0 đánh giá)" khi sản phẩm chưa có đánh giá - WooCommerce & Flatsome
<?php
/**
* Single Product Rating
*
* This template can be overridden by copying it to yourtheme/woocommerce/single-product/rating.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
@webantam43
webantam43 / Get danh mục bài viết Wordpress
Last active May 1, 2025 15:15
Get danh mục bài viết Wordpress
<?php
/**
* Code để hiển thị danh mục bài viết dạng nút
*/
/**
* Tạo shortcode [category_buttons_getdm_wat] để hiển thị danh mục dạng nút
*/
@webantam43
webantam43 / Thu gọn nội dung chi tiết sản phẩm Woocommerce
Created April 16, 2025 13:53
Thu gọn nội dung chi tiết sản phẩm Woocommerce
<?php
add_action('wp_footer', 'wat_product_description_expand_feature');
function wat_product_description_expand_feature() {
// Chỉ thực thi cho trang sản phẩm đơn lẻ
if (!is_product()) {
return;
}
?>
<style>
@webantam43
webantam43 / Hook thay đổi layout plugin review WAT
Created April 5, 2025 11:50
Hook thay đổi layout plugin review WAT
<?php
// Gỡ bỏ action hiển thị số lượng đã bán của plugin
function remove_original_sold_quantity_display_review_woo_wat() {
// Xóa cả class và function (phải thực hiện sau khi class đã được khởi tạo)
global $wp_filter;
// Xóa hook hiển thị ở trang chi tiết sản phẩm
if (isset($wp_filter['woocommerce_single_product_summary'])) {
foreach ($wp_filter['woocommerce_single_product_summary']->callbacks as $priority => $callbacks) {
foreach ($callbacks as $key => $callback) {
@webantam43
webantam43 / Tự động cập nhật giá khi tăng giảm số lượng ở trang sản phẩm Woocommerce
Last active April 1, 2025 12:46
Code tự động cập nhật giá khi tăng giảm số lượng ở trang sản phẩm Woocommerce
/**
* Tự động cập nhật giá khi tăng giảm số lượng ở trang sản phẩm Woocommerce webantam.com
*/
function add_quantity_price_update_script_pod_wat() {
if (is_product()) {
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
var originalPrice_pod_wat = 0;
var pricePerUnit_pod_wat = 0;
@webantam43
webantam43 / Code ảnh xe máy chở hoa mai chạy qua lại như ĐMX đón Tết
Created January 25, 2025 12:50
Code ảnh xe máy chở hoa mai chạy qua lại như ĐMX đón Tết
/* anh motobike tet */
.webantam-motobike-tet{
animation: motorbikeAnimation 24s infinite ease-in-out;
}
@keyframes motorbikeAnimation {
0% {
left: 0;
transform: scaleX(1)
}
@webantam43
webantam43 / Nút liên hệ
Created January 17, 2025 09:06
Nút liên hệ
<!-- nut lien he -->
<style>
.arcontactus-widget.right.arcontactus-message{right:7px}
.arcontactus-widget.right.arcontactus-message{bottom:70px}
.arcontactus-widget .arcontactus-message-button
.pulsation{-webkit-animation-duration:2s;animation-duration:2s}
.arcontactus-widget.md .arcontactus-message-button,.arcontactus-widget.md.arcontactus-message{width:60px;height:60px}
.arcontactus-widget{opacity:0;transition:.2s opacity}
@webantam43
webantam43 / Thêm nút xóa và tăng giảm số lượng, ảnh đại diện sản phẩm trong trang thanh toán WooCommerce cho Flatsome
Last active January 12, 2025 20:55
Thêm nút xóa và tăng giảm số lượng, ảnh đại diện sản phẩm trong trang thanh toán WooCommerce cho Flatsome
/**
* Thêm nút xóa và tăng giảm số lượng sản phẩm trong trang thanh toán WooCommerce cho Flatsome
* Bổ sung thêm ảnh đại diện sản phẩm
*/
// Thêm ảnh sản phẩm vào trước tên sản phẩm
function add_product_image_before_name_wat($product_name, $cart_item, $cart_item_key) {
if (!is_checkout()) {
return $product_name;
}
@webantam43
webantam43 / Tải điều kiện file flatsome-swatches-frontend.css theme Flatsome
Last active January 9, 2025 11:47
Tải điều kiện file flatsome-swatches-frontend.css theme Flatsome
// Tải điều kiện file flatsome-swatches-frontend.css
add_action('wp_enqueue_scripts', function() {
wp_dequeue_style('flatsome-swatches-frontend');
wp_deregister_style('flatsome-swatches-frontend');
}, 20);
// Thêm CSS khi cần thiết
add_action('wp_enqueue_scripts', function() {
// Kiểm tra các điều kiện để load CSS
if (
@webantam43
webantam43 / Thêm nút Edit nhanh cho Admin trên Mobile WordPress
Last active January 2, 2025 14:19
Thêm nút Edit nhanh cho Admin trên Mobile WordPress
function add_admin_mobile_edit_button_edit_wat() {
// Kiểm tra user có phải là admin không
if (!current_user_can('edit_posts') && !current_user_can('edit_pages')) {
return;
}
// Kiểm tra có phải đang ở trang single, page hoặc product không
if (!is_singular()) {
return;
}