Add to cart button always visible

  • Posts: 1115
  • Thank you received: 12
  • Hikashop Business
9 years 8 months ago #224646

-- HikaShop version -- : 2.6.0
-- Joomla version -- : 3.4.5
-- PHP version -- : 5.4

Hello!

When the quantity of a product is 0, the add to cart button is not displayed.
I read in this topic that hikashop by default doesn't alow it.

My client wants the button to be always visible. I m guessing i have to change or add some php code?
Could you help me?

Thank you!

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

  • Posts: 84306
  • Thank you received: 13701
  • MODERATOR
9 years 8 months ago #224671

Hi,

There is indeed no system to allow for that in HikaShop.
You would have to change at least the code in the _checkQuantity function of the file administrator/components/com_hikashop/classes/cart.php
That's the main function controlling the quantity of the products added to the cart.
Then, you'll want to edit the file 'quantity' of the view "product" which displays the add to cart button itself.

The following user(s) said Thank You: verzevoul

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

  • Posts: 1115
  • Thank you received: 12
  • Hikashop Business
9 years 8 months ago #224826

Ok, maybe you could help me with the code?
I m not so familiar with php!

Actually, the retail price is only visible to registered group, which is correct, but they must not be able to perchuse, they just see the price.
So the add to cart button needs not to be visible to the registered group or to the unlogged users.

Thank you

Last edit: 9 years 8 months ago by verzevoul.

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

  • Posts: 84306
  • Thank you received: 13701
  • MODERATOR
9 years 8 months ago #224877

I don't see the link with your first message ?
In your first message you talk about always displaying the add to cart button regardless of the quantity of the product.
In your last message, you talk about displaying the add to cart button based on the user group.
So which one is it and what do you want ?

For such customizations I would recommend to ask a third party developer to help you with it:
www.hikashop.com/home/our-partners.html

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

  • Posts: 1115
  • Thank you received: 12
  • Hikashop Business
9 years 8 months ago #224959

Hi nicolas,

I made it work, sorry for confusing you! It 's my client's demands.
He finally decided that the add to cart button is visible only to the group "Πελάτες".
Anyway, i have one more question, the group "Πελάτες" can see both the retail and the wholesale price, which is correct.
The group "Registered" can see only the retail price, also correct, but instead of the wholesale price the see the title of it "Συνδεθείτε για Τιμές". (see the screenshot)


Is it possible that the group "Registered" see the retail price without seeing also the wholesale price title?

Thank you!

Attachments:

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

  • Posts: 13201
  • Thank you received: 2322
9 years 8 months ago #224999

Hi,

I think that you have done a view edition to display this title, so you have to edit again that view and add a php if condition around the HTML displaying this text in order to display it only when there is a wholesale price.

The view in question should be "product / listing_price".

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

  • Posts: 1115
  • Thank you received: 12
  • Hikashop Business
9 years 8 months ago #225053

This is my code now:

<?php
/**
 * @package	HikaShop for Joomla!
 * @version	2.6.0
 * @author	hikashop.com
 * @copyright	(C) 2010-2015 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 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 && $this->params->get('from_module','') == ''){
			echo '<span class="hikashop_product_our_price_title">'.JText::_('PRODUCT_MSRP_AFTER').'</span> ';
		}

		$config =& hikashop_config();
		if($this->params->get('price_with_tax',3)==3){
			$this->params->set('price_with_tax',$config->get('price_with_tax'));
		}
		if($this->params->get('show_discount',3)==3){
			$this->params->set('show_discount',$config->get('show_discount'));
		}
		if($this->params->get('show_original_price','-1')=='-1'){
			$this->params->set('show_original_price',$config->get('show_original_price'));
		}
		if($this->params->get('show_original_price','-1')=='-1'){
			$this->params->set('show_original_price',$config->get('show_original_price'));
		}

		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('hikashop_product_price 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')==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') && !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') && !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>
<?php $user = JFactory::getUser();
if($user->guest) return; ?>
<?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 && $this->params->get('from_module','') == ''){ ?>
	<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">
		<?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 } ?>

I have made changes with your help yes, i mnot really sure how to do that yet.
What exactly shoud i add to the code?

Last edit: 9 years 8 months ago by verzevoul.

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

  • Posts: 13201
  • Thank you received: 2322
9 years 8 months ago #225532

Hi,

This content seems to be correct, do you have edited another view related on the product listing page ?

Please give us a backend access to your website via our contact form with a link to that topic in the message.
hikashop.com/support/contact-us.html

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

  • Posts: 1115
  • Thank you received: 12
  • Hikashop Business
9 years 8 months ago #225537

Thank you Xavier,
i sent you email with backend access.

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

  • Posts: 13201
  • Thank you received: 2322
9 years 8 months ago #225549

Hi,

I misunderstood your issue, the string "Συνδεθείτε για Τιμές" is the translation for "FREE_PRICE", so the translation is maybe not correct.
To fix your issue I just added a translation override on the "FREE_PRICE" string in order to let it empty.
That way nothing is displayed when no price set.

Here is the documentation for the translation overrides:
hikashop.com/support/faq.html#tran

The following user(s) said Thank You: verzevoul

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

  • Posts: 1115
  • Thank you received: 12
  • Hikashop Business
9 years 8 months ago #225812

Hello Xavier!

It' s working now yes, but if i m not logged in at all i can't see the "Συνδεθείτε για Τιμές".
Non logged in users must be able to see the "Συνδεθείτε για Τιμές" so that they know that to see the prices they must login.

Thank you again for your help!

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

  • Posts: 13201
  • Thank you received: 2322
9 years 8 months ago #225831

Hi,

So you have to remove the translation override and edit the view "product / listing_price" and before the line:

echo JText::_('FREE_PRICE');
Add the code:
if(hikashop_loadUser() == null)

The following user(s) said Thank You: verzevoul

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

  • Posts: 1115
  • Thank you received: 12
  • Hikashop Business
9 years 8 months ago #225877

Thank you Xavier you have been very helpful!

It worked just fine! And i did not have to delete the overide, i renamed it to "Συνδεθείτε για τιμές".

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

Time to create page: 0.102 seconds
Powered by Kunena Forum