Re: An "old price" field

  • Posts: 18
  • Thank you received: 0
12 years 2 months ago #70441

Hi!
Could you tell me is there an "old price" field. I mean, you can fill this field and on product's page you can see an old price, which was struck off (or something else...), and below is displayed a new one price.
If it's not provided, could you give me a hint of how to make this in a right way.

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
12 years 2 months ago #70476

Hi,

To do this, you can create a new custom field on the table "Product" and then, in the product edition page you can set the old price in this custom field.
You can find some documentation about custom fields here:
www.hikashop.com/en/support/documentatio...p-field-listing.html

Then you just have to edit the view "product / show_default" to display the field as you want.

Please Log in or Create an account to join the conversation.

  • Posts: 18
  • Thank you received: 0
12 years 2 months ago #70482

I just tried to do so, but as far as I see it's not exactly what I need. I mean something like that:
Old price: 800
New price: 900


Or did I understand something wrong?

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
12 years 2 months ago #70490

With the method explain before, it's possible.
Some edition in the view file and css customization are needed.

Please Log in or Create an account to join the conversation.

  • Posts: 50
  • Thank you received: 1
12 years 2 months ago #72105

imported the old prices but I do not website. how to make a website that would show? that CSS needs to be adjusted (correct)? I use my gk_mystore Templates

if($this->params->get('old_price')==2||!$this->params->get('old_price')){
echo $this->currencyHelper->format($price->old_price,$price->price_currency_id);

Last edit: 12 years 2 months ago by ag2r.

Please Log in or Create an account to join the conversation.

  • Posts: 18
  • Thank you received: 0
12 years 2 months ago #72212

Hi! I'm still fighting this problem.
New question is: is it possible to display an "old price" field not on the product's page, but on page where multiple products are shown? I tried to do it in this way:
in listing price add

foreach ($this->rows as $fieldName => $oneExtraField) {
	$value = trim($this->element-> $fieldName);
	if ($fieldName == "oldprice") {
		if ($oneExtraField->oldprice!=""){
		?>
			<span class="oldPrice">
				<?php echo $oneExtraField->oldprice." RUB for each<br>"; ?>
			</span><?
	}
}
}
but all I got is the same value through the all products.

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
12 years 2 months ago #72243

Hi,

To add the price in the product show page, you can use this kind of code:

	foreach ($this->fields as $fieldName => $oneExtraField) {
		$value = '';
		if(empty($this->element->$fieldName) && !empty($this->element->main->$fieldName))$this->element->$fieldName = $this->element->main->$fieldName;
		if(isset($this->element->$fieldName))
			$value = trim($this->element->$fieldName);
		if (!empty ($value) && $fieldName == 'old_price') {
			echo $this->fieldsClass->show($oneExtraField,$value);
		}
	}

To add under the code:
		if ($this->params->get('show_price')) {
			$this->row = & $this->element;
			$this->setLayout('listing_price');
			echo $this->loadTemplate();
		}

In the product listing, you just have to add the line:
echo $this->row->old_price;
$
Inthese examples your customfield must be named "old_price" you can replace "old_price" by your custome field name.

Last edit: 12 years 2 months ago by Xavier.
The following user(s) said Thank You: Samazar

Please Log in or Create an account to join the conversation.

  • Posts: 50
  • Thank you received: 1
12 years 2 months ago #72349

works! Thanks! but I do not know how to:

echo $this->row->old_price, EUR;

New price: 15 EUR
Old price: 25 EUR

This variant AMAZING :) i need.

A big thank you.

Last edit: 12 years 2 months ago by ag2r.

Please Log in or Create an account to join the conversation.

  • Posts: 83041
  • Thank you received: 13405
  • MODERATOR
12 years 2 months ago #72364

I'm not sure I understand your new question.
Could you please explain what you have now and what you want ?

Please Log in or Create an account to join the conversation.

  • Posts: 50
  • Thank you received: 1
12 years 2 months ago #72382

Now in my web site:



I wont:


Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 83041
  • Thank you received: 13405
  • MODERATOR
12 years 2 months ago #72582

So you want to add a line return before the old price.

Then, instead of:
echo $this->row->old_price, EUR;

you can use:
echo '<br/>'.$this->row->old_price, EUR;

The following user(s) said Thank You: ag2r

Please Log in or Create an account to join the conversation.

  • Posts: 16
  • Thank you received: 1
5 years 10 months ago #303492

is this still the way to achieve this.
I cant find the settings
if ($this->params->get('show_price')) {
$this->row = & $this->element;
$this->setLayout('listing_price');
echo $this->loadTemplate();
}

Please Log in or Create an account to join the conversation.

  • Posts: 83041
  • Thank you received: 13405
  • MODERATOR
5 years 10 months ago #303493

Hi,

This code changed a bit and is now:

if($this->params->get('show_price') && (empty($this->displayVariants['prices']) || $this->params->get('characteristic_display') != 'list')) {
		$this->row =& $this->element;
		$this->setLayout('listing_price');
		echo $this->loadTemplate();
?>
			<meta itemprop="availability" content="https://schema.org/<?php echo ($this->row->product_quantity != 0) ? 'InStock' : 'OutOfstock' ;?>" />
			<meta itemprop="priceCurrency" content="<?php echo $this->currency->currency_code; ?>" />
<?php
	}
You still can add the code we gave in this post www.hikashop.com/forum/4-how-to/70441-re...ice-field.html#72243 below this new code and it should still work provided that your custom field has the correct name as mentioned in that post.

Please Log in or Create an account to join the conversation.

  • Posts: 16
  • Thank you received: 1
5 years 10 months ago #303637

Maybe a stupid question.
But how do i add 2 custom items there?
i added
<?php
echo $this->row->gratisgemonteerd;
echo $this->row->gratisgeleverd;
?>
But how do i add a break.

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
5 years 10 months ago #303647

Hello,

If you want to add a separation between both prices you'll just have to use that kind of code :

<?php
echo $this->row->gratisgemonteerd . 'YOUR_SEPARATION_TEXT';
echo $this->row->gratisgeleverd;
?>
You'll just have to replace the "YOUR_SEPARATION_TEXT" by what you want to be displayed between both of your prices.

Kind regards,
Mohamed Thelji.

Please Log in or Create an account to join the conversation.

  • Posts: 16
  • Thank you received: 1
5 years 10 months ago #303688

thanks for the help.
But wat i want to do is align the 2 custom fields.
now i have this problem

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 83041
  • Thank you received: 13405
  • MODERATOR
5 years 10 months ago #303708

Hi,

Replace the YOUR_SEPARATION_TEXT in the code example of Mohamed by <br/> and you'll have them one on each line.
If you want something else, it would require some additional HTML tags with classes and CSS so that the texts could be styled.

You might want to contact our partners if you which for someone to help you with such customization:
www.hikashop.com/home/our-partners.html

Please Log in or Create an account to join the conversation.

Time to create page: 0.145 seconds
Powered by Kunena Forum