Chuyên mục

How to

76 bài viết

Banner minh hoa xu ly status order WooCommerce khi refund tu PayPal
How toWooCommerce Tips

Xử lý change status order Woocommerce khi refund từ Paypal

1. Webhook của PayPal cho Refund PayPal cung cấp webhook sự kiện “PAYMENT.SALE.REFUNDED”, bạn có thể đăng ký webhook này để nhận thông báo khi có refund xảy ra. 2. Cấu hình Webhook trong PayPal Truy cập PayPal Developer Dashboard: https://developer.paypal.com/ Chọn ứng dụng của bạn trong My Apps & Credentials. Trong phần Webhook, thêm […]

19/03/2025·1 phút đọc
Banner minh hoa build lai anh hoac media tai len trong WordPress
How to

Hướng dẫn build lại ảnh hoặc media tải lên trong WordPress

Yêu cầu: tôi muốn sử dụng dịch vụ lưu trữ ở Amazon (S3) tuy nhiên website của tôi đã có hình ảnh tải lên media trước, vậy bây giờ làm sao tôi đưa những ảnh này lên S3 lại Giải pháp: Sử dụng plugin: Force Regenerate Thumbnails Plugin này có chứ năng tự động build lại […]

11/02/2025·1 phút đọc
Update post meta ACF sử dụng Rest API WordPresss
How to

Update post meta ACF sử dụng Rest API WordPresss

Bước 1: Tạo Application Passwords Đối với WordPress phiên bản < 5.6 thì bạn cần phải cài đặt plugin Application Passwords, còn phiên bản >= 5.6 thì bạn không cần phải cài đặt plugin Bạn đăng nhập vào website, vào chỉnh sửa profile user, tại phần mật khẩu ứng dụng Bạn đặt tên mật khẩu ứng […]

31/12/2024·2 phút đọc
Jquery ngăn không cho ô input type number nhập ký tự không hợp lệ
How to

Jquery ngăn không cho ô input type number nhập ký tự không hợp lệ

Giả sử ta có input có ô input như sau <input type=”number” class=”input-text qty text” name=”qty” value=”9″ min=”1″ max=”9″ step=”1″> jQuery(document).ready(function($) { // Ngăn không cho nhập ký tự không hợp lệ $(document).on(‘keydown’, ‘.qty’, function(e) { const allowedKeys = [8, 9, 27, 13, 46, 37, 38, 39, 40]; // Backspace, Tab, Escape, Enter, Delete, Arrow […]

30/12/2024·1 phút đọc
Hướng dẫn làm phần compare products trong Woocommerce
How to

Hướng dẫn làm phần compare products trong Woocommerce

Bước 1: Trong PHP <?php // Thêm extra fields class Extend_Attribute_Product extends WC_Product_Simple { public $fields; // Define new attribute, using for compare product } // 1. Thêm Nút So Sánh vào Sản Phẩm add_action( ‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_custom_add_quick_cta’, 4 ); function woocommerce_custom_add_quick_cta(){ $product_id = get_the_ID(); $compare_products = isset($_SESSION[‘compare_products’]) ? $_SESSION[‘compare_products’] : []; $wishlist = isset($_COOKIE[‘wishlist’]) ? […]

25/12/2024·7 phút đọc
Loadmore product woocommerce infinity scroll
How to

Loadmore product woocommerce infinity scroll

Bước 1: Register jquery <?php add_action(‘wp_enqueue_scripts’, ‘enqueue_infinite_scroll_scripts’); function enqueue_infinite_scroll_scripts(){ if ( !is_shop() && !is_product_taxonomy() ) { return; } global $wp_query; wp_enqueue_script( ‘infinite-scroll’, THEME_URL . ‘/assets/js/infinite-scroll.js’, [‘jquery’], ‘1.0’, true ); wp_localize_script(‘infinite-scroll’, ‘lmproduct_obj’, [ ‘ajax_url’ => admin_url(‘admin-ajax.php’), ‘query_vars’ => json_encode($wp_query->query_vars), ‘nonce’ => wp_create_nonce( ‘lmp_check_nonce’ ), ‘max_num_pages’ => $wp_query->max_num_pages, ]); } ?> trong file infinite-scroll.js thêm đoạn code […]

25/12/2024·2 phút đọc
Add the Meta Box Upload Multiple Images and multiple metabox
How to

Add the Meta Box Upload Multiple Images and multiple metabox

Step 1: Add Meta Boxes for Each Field Step 2: Display Each Meta Box // Profile Image Meta Box function profile_image_box_callback($post) { $image_ids = get_post_meta($post->ID, ‘profile_image_gallery’, true); $image_ids = is_array($image_ids) ? $image_ids : []; wp_nonce_field(‘profile_image_box_nonce’, ‘profile_image_box_nonce_field’); ?> <div id=”profile-image-gallery-wrapper”> <ul class=”custom-images-list”> <?php foreach ($image_ids as $image_id) : ?> <li> <?php echo wp_get_attachment_image($image_id, ‘thumbnail’); ?> <a […]

03/10/2024·3 phút đọc
Add the Meta Box Repeat
How to

Add the Meta Box Repeat

Add the Meta Box // Register the meta box function wp_custom_meta_box() { add_meta_box( ‘custom_meta_box’, // ID ‘Custom Meta Box’, // Title ‘wp_custom_meta_box_html’, // Callback function ‘post’, // Post type ‘normal’, // Context ‘high’ // Priority ); } add_action(‘add_meta_boxes’, ‘wp_custom_meta_box’); function wp_custom_meta_box_html($post) { wp_nonce_field(‘save_custom_meta_box’, ‘custom_meta_box_nonce’); // Get existing data if available $meta_data = get_post_meta($post->ID, ‘_custom_meta_box’, true); […]

03/10/2024·2 phút đọc
Kỹ thuật debounce trong javascript - Trì hoãn nhập từ khóa trong ô input
How toJavascript

Kỹ thuật debounce trong javascript – Trì hoãn nhập từ khóa trong ô input

HTML <div class=”seachbox”> <input type=”text” name=”seach-text” id=”seach-text”> </div> Javascript: function delay(callback, ms) { var timer = 0; return function () { var context = this, args = arguments; clearTimeout(timer); timer = setTimeout(function () { callback.apply(context, args); }, ms || 0); }; } $(‘#seach-text’).keyup( delay(function (e) { console.log(‘Time elapsed!’, this.value); }, 500) );  

03/10/2024·1 phút đọc
Thêm VS Code snippets
How to

Thêm VS Code snippets

{ // Place your snippets for php here. Each snippet is defined under a snippet name and has a prefix, body and // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: // $1, $2 for tab stops, $0 for the final […]

01/10/2024·2 phút đọc