Join our new community forum for support & discussion

Join Now

Home Support Extensions Marketplace Add word to price

Add word to price

  • Author
    Posts
  • Bemay1

    So, I been trying with loco translate and did not find a way…
    – How can I add a word before the price, example: “ Only 9.90£ “

    ihor developer

    Please try this code snippet instead:

    add_filter(
    	'hivepress/v1/models/listing/attributes',
    	function( $attributes ) {
    		if ( isset( $attributes['price'] ) ) {
    			$attributes['price']['display_format'] = 'Only %value%£';
    		}
    
    		return $attributes;
    	},
    	1000
    );
    Bemay1

    I tried to adapt this code to add a word to description field but was not able to make it work… Can you please provide?
    Request:
    – Add word “Info” to description field on the listing display.

    ihor developer

    Sorry, if you mean adding some heading to the front-end (the listing page), not to the form field itself, this would require customizations (to include a custom HTML block into the listing page).

    Bemay1

    No, just show the name on the form itself!

    Bemay1

    Show the name of the form on the form; (hope it is a clear way to say it)

    ihor developer

    If I understand correctly you mean changing the Description label, please try this code snippet:

    add_filter(
    	'hivepress/v1/forms/listing_update',
    	function( $form ) {
    		$form['fields']['description']['label']  = 'Info';
    
    		return $form;
    	}
    );

    You can also change it via Loco Translate but this will affect all texts.

    Bemay1

    I mean display %label% and then %value% for this section
    https://ibb.co/pzk40f8

    ihor developer

    This is the listing details page (not the listing form) – if you mean adding some label above the description please try this code snippet:

    add_filter(
    	'hivepress/v1/templates/listing_view_page',
    	function( $template ) {
    		return hivepress()->helper->merge_trees(
    			$template,
    			[
    				'blocks' => [
    					'page_content' => [
    						'blocks' => [
    							'listing_description_title' => [
    								'type'    => 'content',
    								'content' => '<h2 class="hp-section__title">Info</h3>',
    								'_order'  => 59,
    							],
    						],
    					],
    				],
    			]
    		);
    	},
    	1000
    );
    artshareco

    I’ve got a question connected to the description attribute. Is it possible to display an <hr> line break after the description field?

    https://prnt.sc/22y11mq

    The <hr> line break would go after the description field and before the ‘host type’ attribute.

    ihor developer

    Sure, please try using the same code snippet and adjusting the order (59), also replacing “

    ” or any other HTML content.

    artshareco

    I’ve created another code snippet, with the following details:

    ‘type’ => ‘content’,
    ‘content’ => ‘<hr>’,
    ‘_order’ => 36,

    and it works, but it overrides the description label (description label disappears). Is there a way of having both ‘description label’ and ‘line break’ after the text?

    artshareco

    To be more specific, I want the ‘description label’ to appear before the text, and the ‘line break’ to appear after the text.

    ihor developer

    Please make sure that you set some unique name for this block with <hr>, for example the block name in the snippet above is “‘listing_description_title'”. It should be unique for each block you define.

Viewing 14 posts - 1 through 14 (of 14 total)

New Reply

This forum has been archived and is no longer accepting new posts or replies. Please join our new community forum for support & discussion.