Thay đổi Nhãn cho các sản phẩm giá 0 đồng

Tác giả: Dương Nguyễn Phú Cường
Ngày đăng: 4 năm trước


Tạo thêm hàm trong function.php
/**
 * Display "FREE" instead of $0 if the item is free.
 *
 * @param string $price The current price label.
 * @param object $product The product object.
 * @return string
 */
function neta_price_override( $price, $product ) {
   if ( empty( $product->get_price() ) ) {
      /*
       * Replace the word "Free" with whatever text you would like. Also
       * remember to update the textdomain for translation if required.
       */
      $price = __( 'CALL FOR PRICE', 'textdomain' );
   }
 
   return $price;
}
add_filter( 'woocommerce_get_price_html', 'neta_price_override', 100, 2 );