Cho em xin code tự động chuyển tât cả thông tin giá trên web về liên hệ khi giá điền là 0đ hay khi hết hàng thì nó tự chuyển về 0đ với ạ Hiện tại em đang điền cứng trong web phần giá là liên hệ, giờ e muốn tự nó chuyển về liên hệ, hay sđt khi điền giá 0đ thì làm như thế nào? cảm ơn
Code của bạn đây nhé, chèn vào function.php của themes nhé: PHP: ///giá 0đ + hết hàng chuyển về liên hệfunction cs_wc_custom_get_price_html( $price, $product ) { if ( $product->get_price() == 0 ) { if ( $product->is_on_sale() && $product->get_regular_price() ) { $regular_price = wc_get_price_to_display( $product, array( 'qty' => 1, 'price' => $product->get_regular_price() ) ); $price = wc_format_price_range( $regular_price, __( 'Free!', 'woocommerce' ) ); } else { $price = '<span class="amount">' . __( 'Liên hệ', 'woocommerce' ) . '</span>'; } } else if ( !is_admin() && !$product->is_in_stock()) { $price = '<span class="amount">' . __( 'Liên hệ', 'woocommerce' ) . '</span>'; } return $price;}add_filter( 'woocommerce_get_price_html', 'cs_wc_custom_get_price_html', 10, 2 ); Thay chữ Liên hệ thành nội dung bạn cần truyền tải.