Button for requesting a price instead of displaying it

Hallo is it possible to place also a button with “price on request” instead of the displayed price for a product ? Because some sellers did not want that the price will be shown in the listing or product description.

Kind regards

martin

You can also make the price optional via a code snippet. It gives vendor option to display price or not.

I have it, if that helps?

Only problem is that with woocommerce, this can later be an issue and not sure how that would workout with checkout.

Hi much thanks Code Snippet OKAY I think woocommerce I will not need at the moment. I will do it at the moment only with Hive Press Listing Hive.

kind regards

Martin

Wo kann ich das code snippet finden unter gifthub?

Hi wo kann ich das Code Snippet finden ??

Hi, sorry for the delay.

Use this php code snippet using the code snippet by pro plugin:

add_filter(
	'hivepress/v1/models/listing/attributes',
	function( $attributes ) {
		if ( isset( $attributes['price'] ) ) {
			$attributes['price']['edit_field']['required'] = false;
		}
 
		return $attributes;
	},
	1000
);

You can find both php and css code snippets here including the one above: Search · user:hivepress price · GitHub

I have collected additional code snippets that are not on github that peple have posted here on this forum, as well.

2 Likes

Hi no Problem you Work very fine :+1: the function ist good from this Code snippet :hugs: can you Tell me what Kind of Code should i insert that have the following Text: "Preis auf Anfrage’ in the empty field which ist Now empty?? Much regards

Martin

Hi, if you mean to change the text of price to Preis auf Anfrage

add_filter(
	'hivepress/v1/models/listing/fields',
	function( $fields, $model ) {
		if ( isset( $fields['price'] ) ) {
			$fields['price']['display_template'] = '%value% / Preis auf Anfrage';
		}

		return $fields;
	},
	1000,
	2
);

Hi much thanks for your work :wink: The only point is that this text " Preis auf Anfrage should be displayed at this place if I did not insert a price in the price field if I let the price field empty. But whith this code snippet the text is also be displayed if I insert a price in the pricxe field.That should not be only if a user let the price field empty.

kind regards

martin

Sorry for the delay. Please consider making the price optional (using the suggested snippet above), this will hide the price, but adding a custom text instead of it would require inserting a custom template part via the hivepress/v1/templates/listing_view_page/blocks hook.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.