Move price before discount above discounted price

  • Posts: 42
  • Thank you received: 0
12 years 7 months ago #46230

Hello. In the attached image you can see how the price with discount is displayed in my products. Which code do I have to edit so that the price before the discount (linethrough) is shown above the discounted price?
Thank you!

Attachments:

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

  • Posts: 82818
  • Thank you received: 13361
  • MODERATOR
12 years 7 months ago #46309

It's the file "listing_price" of the view "product" via the menu Display->views.

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

  • Posts: 42
  • Thank you received: 0
12 years 7 months ago #46311

Thank you Nicolas. I have already tried moving some code in that file but I was messing something.. Can you be more specific on which piece of code do I have to move in that file?

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

  • Posts: 42
  • Thank you received: 0
12 years 7 months ago #46769

After a lot of struggle in "listing_price" file, I managed to make the price display as shown in the attachement.

1. €500,00 (Initial Price)
2. -25% (Discount Percentage)
3. €375,00 (Final Price)

There is one last thing though that I would like to be displayed and I've tried everything with no luck.
Which code do I have to add/modify so that the Discount Amount (i.e €125,00) is also displayed?
Your advice would be very helpful!
Thank you.

Attachments:
Last edit: 12 years 7 months ago by ALEXIAC.

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

  • Posts: 82818
  • Thank you received: 13361
  • MODERATOR
12 years 7 months ago #46790

You can use that line:
echo $this->currencyHelper->format(-1*$this->row->discount->discount_flat_amount,$price->price_currency_id);

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

  • Posts: 42
  • Thank you received: 0
12 years 7 months ago #46797

For some reason this returns €0,00. Any idea what might be wrong?
Thanks

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

  • Posts: 42
  • Thank you received: 0
12 years 7 months ago #46818

Any advice please?

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

  • Posts: 82818
  • Thank you received: 13361
  • MODERATOR
12 years 7 months ago #46916

Ah yes, that's because you're using percentages. In that case, you'll have to calculate the discount, like that:

echo $this->currencyHelper->format($price->price_value_without_discount-$price->price_value,$price->price_currency_id);

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

  • Posts: 42
  • Thank you received: 0
12 years 7 months ago #47053

Almost there Nicolas. The problem now is that the Discount Amount (100,00-80,00 see attachement) is displayed without the VAT (17,09 instead of 20,00). VAT is 17%.
One of my attempts was to add the line

echo $this->currencyHelper->format($price->price_value_without_discount_with_tax-$price->price_value,$price->price_currency_id);
but again the discount amount is wrong. I also have enabled the option my discounts to be applied After Taxes.

I've been busting my head to solve this but unfortunately I need your help again.
Below is my listing_price.php after the modifications I've made to make the price display as shown in the attachement.
<?php
/**
 * @package    HikaShop for Joomla!
 * @version    1.5.6
 * @author    hikashop.com
 * @copyright  (C) 2010-2012 HIKARI SOFTWARE. All rights reserved.
 * @license    GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?>
  <span class="hikashop_product_price_full">
  <?php
  if(empty($this->row->prices)){
    echo JText::_('FREE_PRICE');
  }else{
    $first=true;
    echo JText::_('PRICE_BEGINNING');
    $i=0;
    foreach($this->row->prices as $price){
      if($first)$first=false;
      else echo JText::_('PRICE_SEPARATOR');
      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.'">';
      }
 if(!empty($this->row->discount)){
      if($this->params->get('show_discount')==1){
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>';
    
        }elseif($this->params->get('show_discount')==2){
echo '<span class="hikashop_product_price_before_discount">'.JText::_('PRICE_BEFORE_ORIG');
   
          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_AFTER_ORIG').'</span>';
  
 
echo '<span class="hikashop_product_discount">'   .JText::_('PRICE_DISCOUNT_START') .JText::_('PRICE_DISCOUNT_START1');
          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 $this->currencyHelper->format($price->price_value_without_discount-$price->price_value,$price->price_currency_id);
echo -1*$this->row->discount->discount_percent_amount.'%';    

    }
          echo JText::_('PRICE_DISCOUNT_END').'</span>';  
  
    }elseif($this->params->get('show_discount')==3){
        }
      }

      if(isset($price->price_min_quantity) && empty($this->cart_product_price)){
        if($price->price_min_quantity>1){
          echo JText::sprintf('PER_UNIT_AT_LEAST_X_BOUGHT',$price->price_min_quantity);
        }else{
    
          echo JText::_('PER_UNIT');$first=true;
   $i=0;
        }
      }  
    
   
      echo '<span class="hikashop_product_price hikashop_product_price_'.$i.'">';
      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($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>';
      }
      $i++;
    }
    echo JText::_('PRICE_END');

  }
  ?>    
      
    </span>

Thank you!

Attachments:

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

  • Posts: 82818
  • Thank you received: 13361
  • MODERATOR
12 years 6 months ago #47313

Try with that:
echo $this->currencyHelper->format($price->price_value_without_discount_with_tax-$price->price_value_with_tax,$price->price_currency_id);

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

  • Posts: 42
  • Thank you received: 0
12 years 6 months ago #47323

Thank you very much! That solved the problem..

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

  • Posts: 28
  • Thank you received: 2
12 years 5 months ago #54047

following on from this post I've done a very similar thing (thanks for directing me here nicolas)

The product listing works fine where the product is viewed in a product listing with other, but when you click to go to the main product page I can't find the code to alter that as well

The result is that the product listing looks like the first picture and the product page looks like the second

Am I being a bit thick because I can't find which code to alter!

Attachments:
Last edit: 12 years 5 months ago by bendraper.

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

  • Posts: 82818
  • Thank you received: 13361
  • MODERATOR
12 years 5 months ago #54122

It's the same code actually.
However, the options for the product page are in the "Display" tab of the configuration while the options of the products listing are in the menu/module's hikashop options.
So you should look in your configuration for the product prices options so that you have the same values as for your listing.

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

  • Posts: 28
  • Thank you received: 2
12 years 4 months ago #54928

right as always, thanks for the help it's looking much better now

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

  • Posts: 3
  • Thank you received: 0
12 years 18 hours ago #76814

I would like the same layout displayed when a discount is applied.

I've tried editing the code myself but keep getting the incorrect result. The result like the result you have where the Sale price is shown along with the old price and the saving amount.

Any chance sombody would be nice enough to show me the code to put into product / listing_price.php?

using Hika 2.0

thanks!

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

  • Posts: 13201
  • Thank you received: 2322
12 years 6 hours ago #76919

Hi,

Try to replace your file content by the content of the following file:

File Attachment:

File Name: product-li...rice.txt
File Size:7 KB

Attachments:

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

  • Posts: 3
  • Thank you received: 0
12 years 3 hours ago #76947

Xavier wrote: Hi,

Try to replace your file content by the content of the following file:

File Attachment:

File Name: product-li...rice.txt
File Size:7 KB


Hi Xavier, thank you for your reply.

although this had no effect on my layout.

site: www.dp2u.ivisioneers.com

:(

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

  • Posts: 13201
  • Thank you received: 2322
12 years 39 minutes ago #77046

Hi,

I think that you have replaced the content of the file in the wrong template.

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

Time to create page: 0.076 seconds
Powered by Kunena Forum