• Bỏ qua primary navigation
  • Skip to main content
  • Bỏ qua primary sidebar

Thủ thuật thiết kế website

Chia sẻ kinh nghiệm thiết kế website

  • Trang chủ
  • Joomla
    • Thủ thuật Joomla
    • Joomla Extensions
    • Joomla Themes
  • WordPress
    • Thủ thuật WordPress
    • WordPress Plugins
    • WordPress Themes
  • Web Development
    • HTML/CSS
    • Javascript
    • PHP
  • PHP Framework
    • Codeigniter
    • Laravel
    • Laminas
  • App Developer
    • React Native
    • Flutter
  • SEO
  • Chia sẻ
  • Phần mềm
Bạn đang ở:Trang chủ / Wordpress / Thủ thuật WordPress / [Woocommerce] Mã dán thay đổi giá tiền, thay đổi giá tiền thuộc tính, giá tiền biến thể Woocommerce

[Woocommerce] Mã dán thay đổi giá tiền, thay đổi giá tiền thuộc tính, giá tiền biến thể Woocommerce

10/08/2021 - admin Để lại bình luận

Mã dán thay đổi giá tiền, thay đổi giá tiền thuộc tính, giá tiền biến thể woo wordpress

Trong woocommerce cho phép ta chọn loại sản phẩm (Sản phẩm 1 giá, sản phẩm nhiều giá theo nhiều kiểu hình …) Khi chọn sản phẩm có giá tùy vào từng loại của sản phẩm thì giá khi hiển thị ra sẽ có dạng giá min – giá max (VD: 20.000 VNĐ – 90.000 VNĐ)

Mã số 1 dán ở flatsome / advanted : ô thẻ body :

<script type="text/javascript">
    (function ($) {
        'use strict';
        jQuery(document).ready(function ($) {
            $(document).on('change',function(){
                var price_html = $('.product .woocommerce-variation-price').html();
                console.log(price_html+"Price");
                if ( price_html == '') {
                    return;
                }
                else{
                    $('p.price' ).html($('.product .woocommerce-variation-price').html());
                    $('.product .woocommerce-variation-price').hide();
                }
                
            });
        });
    })(jQuery);
</script>

Mã số 2 dán ở funtions.php trong mục edit themes :

Thêm đoạn code sau vào file functions.php mà theme bạn đang sử dụng

function wc_wc20_variation_price_format( $price, $product ) {
 //Main Price
 $prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
 $price = $prices[0] !== $prices[1] ? sprintf( __( 'Giá từ: %1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
 
 // Sale Price
 $prices = array( $product->get_variation_regular_price( 'min', true ), $product->get_variation_regular_price( 'max', true ) );
 sort( $prices );
 $saleprice = $prices[0] !== $prices[1] ? wc_price( $prices[0] ) : wc_price( $prices[0] );
 
 if ( $price !== $saleprice ) {
 $price = '<del>' . $saleprice . '</del> <ins>' . $price . '</ins>';
 }
 return $price;
}
add_filter( 'woocommerce_variable_sale_price_html', 'wc_wc20_variation_price_format', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'wc_wc20_variation_price_format', 10, 2 );

Nguồn : https://thaibinhweb.net

0 0 đánh giá
Article Rating
Theo dõi
Đăng nhập
Thông báo của
guest
guest
0 Comments
Phản hồi nội tuyến
Xem tất cả bình luận

Sidebar chính

LỜI NGỎ

Đây là blog cá nhân, cung cấp các thông tin, kiến thức và kinh nghiệm về lập trình và cuộc sống. Những bài viết được mình sưu tập từ nhiều nguồn, mọi chi tiết liên quan đến bản quyền xin vui lòng liên hệ qua email kairu2607@gmail.com ! Cám ơn rất nhiều.

Tìm kiếm

Thủ thuật Wordpress

Chức năng theo dõi đơn hàng cho Woocommerce

Thay đổi cách hiển thị thông tin tài khoản ngân hàng của Woocommerce

Hướng dẫn thêm trường yêu cầu xuất hóa đơn VAT vào Woocommerce

Hướng dẫn thêm trạng thái sản phẩm trong Woocommerce

[Woocommrece] Thêm note phương thức thanh toán Woocommrece

Tự động điền các thuộc tính của ảnh dựa trên tiêu đề

Hướng dẫn cách truyền tiêu đề sản phẩm vào Contact Form 7

Codeigniter Framework

[CodeIgniter 4] Codeigniter 4 Remove Public and Index.php From URL

[CodeIgniter 4] How to upload Codeigniter 4 website on share hosting?

Sửa lỗi website Codeigniter 2.x không chạy được với PHP 7.x

[CodeIgniter 4] Sử dụng cURL trong CodeIgniter 4

[CodeIgniter 4] Sử dụng cache để tăng tốc website trong CodeIgniter 4

[CodeIgniter 4] Xử lý hình ảnh chuyên nghiệp trong CodeIgniter 4

[CodeIgniter 4] Hướng dẫn gửi mail trong CodeIgniter 4

Dịch vụ Thiết Kế Website

React Native

Setting ANDROID_HOME enviromental variable on Mac OS X

Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation

All Image/Fast Image in React Native app not working on iOS 14 beta and Xcode 12 beta – Fix image cannot show in iOS 14

Phần mềm hay

Remote System Explorer (SSH, Telnet, FTP and DStore protocols)

Update Control 2.0 – Công Cụ Tắt Update Trên Windows 10/11

Defender Control 2.1 – Vô Hiệu Hóa Windows Defender

Manga Comic Downloader

Phần mềm download truyện tranh KnightComic

Copyright © 2022 · Metro Pro on Genesis Framework · WordPress · Đăng nhập

wpDiscuz