Viewing 10 replies - 1 through 10 (of 10 total)
  • This may do what you want:

    <?php
      // code goes in functions.php for your child theme
      // output a message if the product price is nil
      add_filter('woocommerce_empty_price_html', 'nil_price_message');
      function nil_price_message() {
        return 'Ring for price';
      }

    Thread Starter Eelik

    (@eelik)

    Thanks lorro, tried that but still the same: outputting Free!
    Code placed in child theme / functions.php

    Please post the url to your site.

    Thread Starter Eelik

    (@eelik)

    Looks like its in coming-soon mode!

    Thread Starter Eelik

    (@eelik)

    Yes, I am updating the website from https://www.thaikitcheninlakeland.co.uk which I created about seven years ago.
    I am trying to integrate the menu at https://www.thaikitcheninlakeland.co.uk/pages/order.php which is an online php form into a better menu design using images and checkout.
    I don’t want the usual woocommerce checkout system because the prices are person and not per dish so it wouldn’t work.
    There will be a section for people to checkout with, say, 10 people at £34 a head, but all the dishes selected should have zero cost.
    I could leave the text as ‘Free’ but it would be better with something else or nothing at all.
    Thanks

    Have you tried:
    https://www.ads-software.com/plugins/loco-translate/
    There’s both a “Free” string and a “Free!”.
    In English, these are translated into the same strings, but you can change them into your words.

    https://docs.woothemes.com/document/woocommerce-localization/

    Thread Starter Eelik

    (@eelik)

    Thanks, I’ll try that.
    I think this may be a custom field.
    There is one called ‘local-sales’ and it may that this executes a nil amount as Free!.
    I am trying to figure out how to edit the content of the field.

    Thread Starter Eelik

    (@eelik)

    Hi Lorro, I am still trying to remove the ‘Free!’ from the product page when I add ‘0.00’ to either my variable or single product regular price conditions.
    The code you supplied above will replace the text, but then the ‘add to cart button’ does not appear, so the product cannot be added to cart.

    The variable price field has to be completed by default and when 0.00 is added the text Free! appears under the product description. I need to be able to change this to something more appropriate.

    I think I have found the source php code here: and I changed the condition ‘Free!’ to ‘Select’ but this does not display in the page.

    Editing woocommerce/includes/class-wc-product-variation.php (inactive)
    /**
    * Get variation price HTML. Prices are not inherited from parents.
    *
    * @return string containing the formatted price
    */

    public function get_price_html( $price = '' ) {
    
    		$display_price         = $this->get_display_price();
    		$display_regular_price = $this->get_display_price( $this->get_regular_price() );
    		$display_sale_price    = $this->get_display_price( $this->get_sale_price() );
    
    		if ( $this->get_price() !== '' ) {
    			if ( $this->is_on_sale() ) {
    				$price = apply_filters( 'woocommerce_variation_sale_price_html', '<del>' . wc_price( $display_regular_price ) . '</del> <ins>' . wc_price( $display_sale_price ) . '</ins>' . $this->get_price_suffix(), $this );
    			} elseif ( $this->get_price() > 0 ) {
    				$price = apply_filters( 'woocommerce_variation_price_html', wc_price( $display_price ) . $this->get_price_suffix(), $this );
    			} else {
    				$price = apply_filters( 'woocommerce_variation_free_price_html', __( 'SELECT', 'woocommerce' ), $this );
    			}
    		} else {
    			$price = apply_filters( 'woocommerce_variation_empty_price_html', '', $this );
    		}
    
    		return apply_filters( 'woocommerce_get_variation_price_html', $price, $this );
    	}

    Perhaps there is some more code relating to this.
    I will leave the site accessible this evening.
    https://www.thaikitcheninlakeland.co.uk/cedars/product/vegetable-tempura/
    Thanks

    Thread Starter Eelik

    (@eelik)

    I’ve discovered the solution here:
    https://www.ads-software.com/support/topic/remove-free-word-in-shipping-method-label?replies=5

    It works great now, the text Free! has gone on both product page and shipping page. I needed to use both pieces of code.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Change default text on zero priced product’ is closed to new replies.