Skip to main content

Show main Price

More
6 years 4 months ago #320127 by davec
Show main Price was created by davec
-- HikaShop version -- : 4.3.0
-- Joomla version -- : 3.9.18

Hi

I have products with variants and use the dropdown to select the price options. I would like to display the main price at the top of the product description, ideally below the ETA field as per the attachment.

Thanks

Dave B)

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

More
6 years 4 months ago - 6 years 4 months ago #320133 by Philip
Replied by Philip on topic Show main Price
Hello,

For this I see 2 solutions :
1. Directly add the main price in the description part, and if needed some html tag
=> This solution will be enough IF there are for all you customers the same price, I mean not location specific taxes from different area.
2. The other solution is create an override view, this will required html & php knowledge.
=> See this tutorial , and in details you will have to find the part that manage the main price, and duplicate it to add it where you need it, before description part.

Hope this will help you to get what you need.
Regards
Last edit: 6 years 4 months ago by Philip.

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

More
6 years 4 months ago #320180 by davec
Replied by davec on topic Show main Price
Hi Philip

I had found that code already. However copying it to the another position displays the deposit price which is the first characteristic. I need the full price displayed only at the top. The site is live and has a fairly large inventory so adding it as part of the description is not really an option.

Thanks

Dave

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

More
6 years 4 months ago - 6 years 4 months ago #320184 by Philip
Replied by Philip on topic Show main Price
Hello,

I'm not sure to follow you can you what do you mean by the first characteristics price ? And the difference in your mind with the full price ?

But I will details the override process in order to guide you.
1. Have a look from Main HikaShop Configuration, in Advanced tab, and in first Advanced settings part


This option will add on the frontend view reference that display each part.
2. From this in the show_default view you will have some code that call the view listing_price view, the idea is to add this "view call" to have the main price display, by main I mean default product variant but I'm awaiting news from you to better understand this point.

Hope this will help you to progress on your subject.
Regards
Last edit: 6 years 4 months ago by Philip.

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

More
6 years 4 months ago #320230 by davec
Replied by davec on topic Show main Price
Hi Philip

I have this code but when adding it to the default show it displays the lower price as this is set as the default in the characteristics.
Code:
<span class="hikashop_product_price_full<?php echo $class; ?>"><?php if(empty($this->row->prices)) { echo JText::_('FREE_PRICE'); } else { $first = true; echo JText::_('PRICE_BEGINNING'); $i = 0; if(!empty($show_msrp)) { echo '<span class="hikashop_product_our_price_title">'.JText::_('PRODUCT_MSRP_AFTER').'</span> '; } if($this->params->get('price_with_tax', 3) == 3) { $this->params->set('price_with_tax', (int)$config->get('price_with_tax')); } $microDataForCurrentProduct = false; foreach($this->row->prices as $k => $price) { if($first)$first=false; else echo JText::_('PRICE_SEPARATOR'); if(!empty($this->unit) && isset($price->unit_price)) { $price =& $price->unit_price; } if(empty($price->price_currency_id)) continue; $start = JText::_('PRICE_BEGINNING_'.$i); if($start != 'PRICE_BEGINNING_'.$i) { echo $start; } if(isset($price->price_min_quantity) && empty($this->cart_product_price) && $price->price_min_quantity > 1) { echo '<span class="hikashop_product_price_with_min_qty hikashop_product_price_for_at_least_'.$price->price_min_quantity.'">'; } $classes = array('hikashop_product_price hikashop_product_price_'.$i); if(!empty($this->row->discount)) { $classes[]='hikashop_product_price_with_discount'; } if(!empty($this->row->discount)) { if(in_array($this->params->get('show_discount'), array(1, 4))) { echo '<span class="hikashop_product_discount">'.JText::_('PRICE_DISCOUNT_START'); if(bccomp($this->row->discount->discount_flat_amount, 0, 5) !== 0) { echo $this->currencyHelper->format( -1 * $this->row->discount->discount_flat_amount, $price->price_currency_id); } elseif(bccomp($this->row->discount->discount_percent_amount, 0, 5) !== 0) { echo -1*$this->row->discount->discount_percent_amount.'%'; } echo JText::_('PRICE_DISCOUNT_END').'</span>'; } if(in_array($this->params->get('show_discount'), array(2, 4))) { echo '<span class="hikashop_product_price_before_discount">'.JText::_('PRICE_DISCOUNT_START'); if($this->params->get('price_with_tax')){ echo $this->currencyHelper->format($price->price_value_without_discount_with_tax, $price->price_currency_id); } if($this->params->get('price_with_tax') == 2) { echo JText::_('PRICE_BEFORE_TAX'); } if($this->params->get('price_with_tax') == 2 || !$this->params->get('price_with_tax')) { echo $this->currencyHelper->format($price->price_value_without_discount, $price->price_currency_id); } if($this->params->get('price_with_tax') == 2) { echo JText::_('PRICE_AFTER_TAX'); } if($this->params->get('show_original_price') && !empty($price->price_orig_value_without_discount_with_tax)) { echo JText::_('PRICE_BEFORE_ORIG'); if($this->params->get('price_with_tax')) { echo $this->currencyHelper->format($price->price_orig_value_without_discount_with_tax, $price->price_orig_currency_id); } if($this->params->get('price_with_tax') == 2) { echo JText::_('PRICE_BEFORE_TAX'); } if($this->params->get('price_with_tax') == 2 || !$this->params->get('price_with_tax') && !empty($price->price_orig_value_without_discount)) { echo $this->currencyHelper->format($price->price_orig_value_without_discount, $price->price_orig_currency_id); } if($this->params->get('price_with_tax') == 2) { echo JText::_('PRICE_AFTER_TAX'); } echo JText::_('PRICE_AFTER_ORIG'); } echo JText::_('PRICE_DISCOUNT_END').'</span>'; } elseif($this->params->get('show_discount') == 3) { } } $attributes = ''; if(!empty($this->element->product_id) && !$microDataForCurrentProduct) { $round = $this->currencyHelper->getRounding($price->price_currency_id, true); $prefix = 'data-'; $microDataForCurrentProduct = true; if(empty($this->displayed_price_microdata)) { $this->displayed_price_microdata = true; $prefix = ''; } if($this->params->get('price_with_tax')) { $attributes = ' '.$prefix.'itemprop="price" '.$prefix.'content="'. str_replace(',','.',$this->currencyHelper->round($price->price_value_with_tax, $round, 0, true)) .'"'; } else { $attributes = ' '.$prefix.'itemprop="price" '.$prefix.'content="'. str_replace(',','.',$this->currencyHelper->round($price->price_value, $round, 0, true)) .'"'; } } echo '<span class="'.implode(' ',$classes).'"'.$attributes.'>'; if($this->params->get('price_with_tax')) { echo $this->currencyHelper->format(@$price->price_value_with_tax, $price->price_currency_id); } if($this->params->get('price_with_tax') == 2) { echo JText::_('PRICE_BEFORE_TAX'); } if($this->params->get('price_with_tax') == 2 || !$this->params->get('price_with_tax')) { echo $this->currencyHelper->format(@$price->price_value, $price->price_currency_id); } if($this->params->get('price_with_tax') == 2) { echo JText::_('PRICE_AFTER_TAX'); } if($this->params->get('show_original_price') && !empty($price->price_orig_value)) { echo JText::_('PRICE_BEFORE_ORIG'); if($this->params->get('price_with_tax')) { echo $this->currencyHelper->format($price->price_orig_value_with_tax, $price->price_orig_currency_id); } if($this->params->get('price_with_tax') == 2) { echo JText::_('PRICE_BEFORE_TAX'); } if($this->params->get('price_with_tax') == 2 || !$this->params->get('price_with_tax')){ echo $this->currencyHelper->format($price->price_orig_value, $price->price_orig_currency_id); } if($this->params->get('price_with_tax') == 2) { echo JText::_('PRICE_AFTER_TAX'); } echo JText::_('PRICE_AFTER_ORIG'); } echo '</span> '; if(isset($price->price_min_quantity) && empty($this->cart_product_price) && $this->params->get('per_unit', 1)) { if($price->price_min_quantity > 1) { echo '<span class="hikashop_product_price_per_unit_x">'.JText::sprintf('PER_UNIT_AT_LEAST_X_BOUGHT',$price->price_min_quantity).'</span>'; } else { echo '<span class="hikashop_product_price_per_unit">'.JText::_('PER_UNIT').'</span>'; } } if($this->params->get('show_price_weight')){ if(!empty($this->element->product_id) && isset($this->row->product_weight) && bccomp($this->row->product_weight, 0, 3)) { echo JText::_('PRICE_SEPARATOR').'<span class="hikashop_product_price_per_weight_unit">'; if($this->params->get('price_with_tax')){ $weight_price = $price->price_value_with_tax / $this->row->product_weight; echo $this->currencyHelper->format($weight_price, $price->price_currency_id).' / '.JText::_($this->row->product_weight_unit); } if($this->params->get('price_with_tax') == 2) { echo JText::_('PRICE_BEFORE_TAX'); } if($this->params->get('price_with_tax') == 2 || !$this->params->get('price_with_tax')) { $weight_price = $price->price_value / $this->row->product_weight; echo $this->currencyHelper->format($weight_price, $price->price_currency_id).' / '.JText::_($this->row->product_weight_unit); } if($this->params->get('price_with_tax') == 2) { echo JText::_('PRICE_AFTER_TAX'); } echo '</span>'; } } if(isset($price->price_min_quantity) && empty($this->cart_product_price) && $price->price_min_quantity > 1) { echo '</span>'; } $end = JText::_('PRICE_ENDING_'.$i); if($end != 'PRICE_ENDING_'.$i) { echo $end; } $i++; } echo JText::_('PRICE_END'); } ?></span>

The full price would be £19.99 for instance the default characteristics price is £0.01 which is what is displayed if I add the code.

Thanks

Dave

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

More
6 years 4 months ago #320239 by nicolas
Replied by nicolas on topic Show main Price
Hi,

In product / show.php $this->row is likely the last variant of the product.
While the main product information is in $this->element->main (if the product has variants), or $this->element (without variants).
So I think you want to adapt that variable in your custom code.

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

More
6 years 4 months ago #320259 by davec
Replied by davec on topic Show main Price
Hi Nicolas

yes the products have a variant. The variant lower price is the default. The main price is £79.99 for instance this is what I would like to display at the top of the description.

Thanks

David

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

More
6 years 4 months ago #320266 by nicolas
Replied by nicolas on topic Show main Price
Hi,

I think you can just use this code then:
Code:
<?php echo $this->currencyHelper->format($this->element->prices[0]->price_value_with_tax, $this->element->prices[0]->price_currency_id); ?>

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

More
6 years 4 months ago - 6 years 4 months ago #320291 by davec
Replied by davec on topic Show main Price
Hi Nicolas

sorry but that code displays the deposit amount which is what I am trying to avoid. Please see the screenshot.

This message contains confidential information


Basically the code like others I have tried displays the lowest price variant price where as I need to show the full price.

Thanks

David
Last edit: 6 years 4 months ago by davec. Reason: add information

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

More
6 years 4 months ago #320293 by nicolas
Replied by nicolas on topic Show main Price
Hi,

The code I gave displays the price of the default variant.
If the full price is in the main product (which I'm guessing from your messages), then you can use this code instead:
Code:
<?php echo $this->currencyHelper->format($this->element->main->prices[0]->price_value_with_tax, $this->element->main->prices[0]->price_currency_id); ?>
The following user(s) said Thank You: davec

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

More
6 years 4 months ago #320403 by davec
Replied by davec on topic Show main Price
Hi Nicolas

thanks very much for the code, spot on!! :cheer:

David

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

More
6 years 3 months ago #320523 by davec
Replied by davec on topic Show main Price
Hi Nicolas

sorry the code hasn't quite fixed it for me. If there are no variants then the price shows as 0. Please see attached screenshot. Would appreciate your help?

Thanks

David

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

More
6 years 3 months ago - 6 years 3 months ago #320575 by Philip
Replied by Philip on topic Show main Price
Hello,

Maybe you can add a check condition in order to adapt the code to display from current product configuration :
if (isset($variants)) {
=> Use custom code
}
else {
=> Use default code
}

Hope this will help you.
Regards
Last edit: 6 years 3 months ago by Philip.

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

More
6 years 3 months ago #320580 by davec
Replied by davec on topic Show main Price
Hi Philip

Can you please provide a full code as I cannot see how this can be implemented?

Thanks

David

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

More
6 years 3 months ago #320584 by nicolas
Replied by nicolas on topic Show main Price
Hi,
Code:
<?php if (isset($this->element->main)) { echo $this->currencyHelper->format($this->element->main->prices[0]->price_value_with_tax, $this->element->main->prices[0]->price_currency_id); } else { echo $this->currencyHelper->format($this->element->prices[0]->price_value_with_tax, $this->element->prices[0]->price_currency_id); } ?>
The following user(s) said Thank You: davec

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

More
6 years 3 months ago #320598 by davec
Replied by davec on topic Show main Price
Morning Nicolas

all seems to be working now as expected. Thanks very much for your help with this B)

Dave

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

Time to create page: 0.305 seconds
Powered by Kunena Forum