Trouble swapping core/sale prices

  • Posts: 2
  • Thank you received: 0
9 years 7 months ago #198191

-- HikaShop version -- : 2.4.0
-- Joomla version -- : 3.4.1
-- PHP version -- : 5.3.29

I've found posts on swapping the core and sale prices, but not one for exactly what I'm looking to find. I swapped some code around and changed the prices around on the individual product page, but it then doesn't show the price on the overall products page. I assume it has to do with this part: echo JText::_('PRICE_END');, but don't know PHP more than just recognizing and moving parts around. I tried just swapping some around and got the text CORE PRICE and SALE PRICE to swap, but couldn't figure out how to swap the actual price without messing the price on the products page up.

Thanks for any help!

Here's what I have:
Display > VIews > Product - Listing Price:

<?php
/**
 * @package	HikaShop for Joomla!
 * @version	2.3.1
 * @author	hikashop.com
 * @copyright	(C) 2010-2014 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php
$class ='';
if(!empty($this->row->prices) && count($this->row->prices)>1){
        $class = ' hikashop_product_several_prices';
}
if(isset($this->element->main->product_msrp) && !(@$this->row->product_msrp > 0.0) )
        $this->row->product_msrp = $this->element->main->product_msrp;
if(isset($this->row->product_msrp) && @$this->row->product_msrp > 0.0 && JRequest::getCmd('layout') == 'show' && $this->params->get('from_module','') == ''){ ?>
<title>NEW  NEW  NEW  NEW</title>


        <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(isset($this->row->product_msrp) && @$this->row->product_msrp > 0.0 && JRequest::getCmd('layout') == 'show' && $this->params->get('from_module','') == ''){
                        echo '<span class="hikashop_product_our_price_title">'.JText::_('PRODUCT_MSRP_AFTER').'</span> ';
                }

                if($this->params->get('price_with_tax',3)==3){
                        $config =& hikashop_config();
                        $this->params->set('price_with_tax',$config->get('price_with_tax'));
                }
                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;
                        }
                        $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('price pull-right hikashop_product_price_'.$i);
                        if(!empty($this->row->discount)){
                                $classes[]='hikashop_product_price_with_discount';
                        }

                        if(!empty($this->row->discount)){
                                if($this->params->get('show_discount',3)==3){
                                        $config =& hikashop_config();
                                        $this->params->set('show_discount',$config->get('show_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_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','-1')=='-1'){
                                                $config =& hikashop_config();
                                                $this->params->set('show_original_price',$config->get('show_original_price'));
                                        }
                                        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){

                                }
                        }

                        echo '<span class="'.implode(' ',$classes).'">';
                        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','-1')=='-1'){
                                $config =& hikashop_config();
                                $this->params->set('show_original_price',$config->get('show_original_price'));
                        }
                        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_TPL').'</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>
<div style="clear: both;"></div>
<span class="hikashop_product_msrp_price hikashop_product_price_full">
                <span class="hikashop_product_msrp_price_title">
            <?php
                        echo JText::_('PRODUCT_MSRP_BEFORE');
?>
                </span>
                    <span class="hikashop_product_price">&nbsp; &nbsp;
                <?php
                        $mainCurr = $this->currencyHelper->mainCurrency();
                        $app = JFactory::getApplication();
                        $currCurrency = $app->getUserState( HIKASHOP_COMPONENT.'.currency_id', $mainCurr );
                        $msrpCurrencied = $this->currencyHelper->convertUniquePrice($this->row->product_msrp,$mainCurr,$currCurrency);
                        if($msrpCurrencied == $this->row->product_msrp)
                                echo $this->currencyHelper->format($this->row->product_msrp,$mainCurr);
                        else
                                echo $this->currencyHelper->format($msrpCurrencied,$currCurrency).' ('.$this->currencyHelper->format($this->row->product_msrp,$mainCurr).')';
                ?>
         </span>
</span>
<?php } ?>

Last edit: 9 years 7 months ago by Jerome. Reason: [code] is nice

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

  • Posts: 26159
  • Thank you received: 4028
  • MODERATOR
9 years 7 months ago #198254

Hi,

The content you posted is from HikaShop 2.3.1 but you wrote that you're using HikaShop 2.4.0
I see that you have modified some things (like adding the "title" at the beginning, even if I don't understand that code) but it's hard to see all of your modifications.

It will be easier if you explain us what you want to achieve and why you modified the view previously.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: InfoWeb

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

  • Posts: 2
  • Thank you received: 0
9 years 7 months ago #198314

I copied the code into Dreamweaver and it added the title. For the version, I probably started with 2.3.1 and upgraded while still working on this part. My question pertains to the unedited code.

I've been able to shift the php snippets around to swap the text leading into the prices, but the prices remain. When I do simply grab the second half and move it to the top, it then hides the price from the page listing multiple products.

I'm just hoping to list the sale price first and the higher price second.

I've adjusted other things thanks to this forum, but keep getting stuck on this. Regardless, thanks for a great product. HikaShop is excellent.

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
9 years 7 months ago #198403

Hi,

The same view file is used for the display of the prices on both the listing and the product page.
So if you want to modify the display for the product page and keep the display as it is on the listing, I would recommend to do something like that in the view file:

if(@$_GET['task']=='show'){
 //paste the whole code and modify the code for the price display of the product page
}else{
//paste the whole code and don't modify it as you want it "as is" for the listing.
}

Last edit: 9 years 7 months ago by nicolas.

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

Time to create page: 0.068 seconds
Powered by Kunena Forum