No stock display

  • Posts: 441
  • Thank you received: 24
11 years 1 week ago #154307

I would like in the product listings that in case that a product has no stock, the view should display a buttom to go to the product, like view product and it takes you to the product, once inside the buttom add to cart is not displayed as its out of stock and the message out of stock is displayed also.

Resuming, change the text out of stock for a buttom see the product in product listing view

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

  • Posts: 13201
  • Thank you received: 2322
11 years 1 week ago #154308

Hi,

You just have to do some views override.
www.hikashop.com/support/support/documen...ize-the-display.html

Edit "product / quantity" and check replace

echo JText::_('NO_STOCK');
By:
echo '<a href="'.hikashop_completeLink('product&task=show&product_id='.$this->row->product_id.'&name='.$this->row->alias.$url_itemid.$this->category_pathway).'" class="button btn">'.JText::_('SEE_THE_PRODUCT').'</a>';
And add a translation override like:

SEE_THE_PRODUCT="See product"

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

  • Posts: 441
  • Thank you received: 24
11 years 1 week ago #154452

This is quite close but not exact, i would like insede the product to be displayed no stock, the buttom should be in the product listing.
Inside the product just no stock.

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

  • Posts: 83779
  • Thank you received: 13567
  • MODERATOR
11 years 1 week ago #154495

Hi,

Replace the code of the product/quantity.php with this and it should do what you want:

<?php
global $Itemid;
$url_itemid = '';
if(!empty($Itemid))
	$url_itemid = '&Itemid='.$Itemid;
if($this->config->get('show_quantity_field')==-2){
	$this->params->set('show_quantity_field',$this->row->product_display_quantity_field);
}

$config =& hikashop_config();

$wishlistEnabled = $config->get('enable_wishlist', 1);
$hideForGuest = 1;
if(($config->get('hide_wishlist_guest', 1) && hikashop_loadUser() != null) || !$config->get('hide_wishlist_guest', 1)){
	$hideForGuest = 0;
}

if(!isset($this->cart)) $this->cart = hikashop_get('helper.cart');

$this->cart = hikashop_get('helper.cart');
$url = '';
$module_id = $this->params->get('from_module',0);
if(empty($this->ajax)){
	$this->ajax = 'return hikashopModifyQuantity(\''.$this->row->product_id.'\',field,1,0,\'cart\','.$module_id.')';
}
if(@$this->row->product_sale_start || empty($this->element->main)){
	$start_date = @$this->row->product_sale_start;
}else{
	$start_date = $this->element->main->product_sale_start;
}
if(@$this->row->product_sale_end || empty($this->element->main)){
	$end_date = @$this->row->product_sale_end;
}else{
	$end_date = $this->element->main->product_sale_end;
}
$formName = ',0';
if (!$this->config->get('ajax_add_to_cart', 0) || ($this->config->get('show_quantity_field')>=2 && !@$this->element->product_id)) {
	if(empty($this->formName)) {
		if(@$this->row->product_id)
			$formName = ',\'hikashop_product_form_'.$this->row->product_id.'_'.$this->params->get('main_div_name').'\'';
		else
			$formName = ',\'hikashop_product_form_'.$this->params->get('main_div_name').'\'';
	} else {
		$formName = $this->formName;
	}
}
if($end_date && $end_date<time()){
	?>
	<span class="hikashop_product_sale_end">
		<?php echo JText::_('ITEM_NOT_SOLD_ANYMORE'); ?>
	</span>
	<?php
}elseif($start_date && $start_date>time()){
	?>
	<span class="hikashop_product_sale_start">
		<?php
		echo JText::sprintf('ITEM_SOLD_ON_DATE',hikashop_getDate($start_date,$this->params->get('date_format','%d %B %Y')));
		//TODO echo $this->cart->displayButton(JText::_('Pre-order and add to cart'),'add',$this->params,$url,$ajax);
		?>
	</span>
	<?php
}elseif(!$this->params->get('catalogue') && ($this->config->get('display_add_to_cart_for_free_products') || !empty($this->row->prices))){
	if(@$this->row->product_min_per_order || empty($this->element->main)){
		$min = @$this->row->product_min_per_order;
	}else{
		$min = @$this->element->main->product_min_per_order;
	}
	if(@$this->row->product_max_per_order || empty($this->element->main)){
		$max = @$this->row->product_max_per_order;
	}else{
		$max = @$this->element->main->product_max_per_order;
	}
	if($min<=0){
		$min=1;
	}
	$wishlistAjax =	'if(hikashopCheckChangeForm(\'item\''.$formName.')){ return hikashopModifyQuantity(\'' . (int)@$this->row->product_id . '\',field,1' . $formName . ',\'wishlist\','.$module_id.'); } else { return false; }';

	if($this->row->product_quantity == -1 && !empty($this->element->main) && $this->element->main->product_quantity != -1){
		$this->row->product_quantity = $this->element->main->product_quantity;
	}
	$btnType = 'add';
	if($this->row->product_quantity==-1){
	?>
	<div class="hikashop_product_stock">
	<?php
		if(!empty($this->row->has_options)){
			if($this->params->get('add_to_cart',1)) echo $this->cart->displayButton(JText::_('CHOOSE_OPTIONS'),'choose_options',$this->params,hikashop_completeLink('product&task=show&product_id='.$this->row->product_id.'&name='.$this->row->alias.$url_itemid.$this->category_pathway),'window.location = \''.str_replace("'","\'",hikashop_completeLink('product&task=show&product_id='.$this->row->product_id.'&name='.$this->row->alias.$url_itemid.$this->category_pathway)).'\';return false;','');
		}else{
			if($this->params->get('add_to_cart',1)){
				echo $this->cart->displayButton(JText::_('ADD_TO_CART'),'add',$this->params,$url,$this->ajax,'',$max,$min);
				$btnType = 'wish';
			}
			if(hikashop_level(1) && $this->params->get('add_to_wishlist') && $wishlistEnabled && !$hideForGuest && $this->config->get('display_add_to_wishlist_for_free_products','1')){
				echo '<div id="hikashop_add_wishlist">';
					echo $this->cart->displayButton(JText::_('ADD_TO_WISHLIST'),$btnType,$this->params,$url,$wishlistAjax,'',$max,$min,'',false);
				echo '</div>';
			}
		}
	}elseif($this->row->product_quantity>0){
	?>
	<div class="hikashop_product_stock">
	<?php
		echo '<span class="hikashop_product_stock_count">'.JText::sprintf('X_ITEMS_IN_STOCK',$this->row->product_quantity).'<br/></span>';
		if($config->get('button_style','normal')=='css'){
			echo '<br />';
		}
		if($max<=0 || $max>$this->row->product_quantity) $max = $this->row->product_quantity;
		if(!empty($this->row->has_options)){
			if($this->params->get('add_to_cart',1)) echo $this->cart->displayButton(JText::_('CHOOSE_OPTIONS'),'choose_options',$this->params,hikashop_completeLink('product&task=show&product_id='.$this->row->product_id.'&name='.$this->row->alias.$url_itemid.$this->category_pathway),'window.location = \''.str_replace("'","\'",hikashop_completeLink('product&task=show&product_id='.$this->row->product_id.'&name='.$this->row->alias.$url_itemid.$this->category_pathway)).'\';return false;','');
		}else{
			if($this->params->get('add_to_cart',1)){
				echo $this->cart->displayButton(JText::_('ADD_TO_CART'),'add',$this->params,$url,$this->ajax,'',$max,$min);
				$btnType = 'wish';
			}
			if(hikashop_level(1) && $this->params->get('add_to_wishlist')  && $wishlistEnabled && !$hideForGuest && $this->config->get('display_add_to_wishlist_for_free_products','1')){
				echo '<div id="hikashop_add_wishlist">';
					echo $this->cart->displayButton(JText::_('ADD_TO_WISHLIST'),$btnType,$this->params,$url,$wishlistAjax,'',$max,$min,'',false);
				echo '</div>';
			}
		}
	}else{
		?>
	<div class="hikashop_product_no_stock">
	<?php
		echo JText::_('NO_STOCK').'<br/>';
		$waitlist = $this->config->get('product_waitlist',0);
		if(hikashop_level(1) && ($waitlist==2 || ($waitlist==1 && (!empty($this->element->main->product_waitlist) || !empty($this->element->product_waitlist))))){ ?>
			</div><div id="hikashop_product_waitlist_main" class="hikashop_product_waitlist_main">
			<?php
			$empty='';
			jimport('joomla.html.parameter');
			$params = new HikaParameter($empty);
			echo $this->cart->displayButton(JText::_('ADD_ME_WAITLIST'),'add_waitlist',$params,hikashop_completeLink('product&task=waitlist&cid='.$this->row->product_id.$url_itemid),'window.location=\''.str_replace("'","\'",hikashop_completeLink('product&task=waitlist&cid='.$this->row->product_id.$url_itemid)).'\';return false;');
		}
		if(hikashop_level(1) && $this->params->get('add_to_wishlist')  && $wishlistEnabled  && !$hideForGuest && $this->config->get('display_add_to_wishlist_for_free_products','1')){
			if(!empty($this->row->has_options)){
				if($this->params->get('add_to_cart',1)) echo $this->cart->displayButton(JText::_('CHOOSE_OPTIONS'),'choose_options',$this->params,hikashop_completeLink('product&task=show&product_id='.$this->row->product_id.'&name='.$this->row->alias.$url_itemid.$this->category_pathway),'window.location = \''.str_replace("'","\'",hikashop_completeLink('product&task=show&product_id='.$this->row->product_id.'&name='.$this->row->alias.$url_itemid.$this->category_pathway)).'\';return false;','');
			}else{
				echo '<div id="hikashop_add_wishlist">';
					echo $this->cart->displayButton(JText::_('ADD_TO_WISHLIST'),'add',$this->params,$url,$wishlistAjax,'',@$this->row->product_max_per_order,1,'',false);
				echo '</div>';
			}
		}
	}?>
	</div>
<?php
}elseif(hikashop_level(1) && $wishlistEnabled && $this->params->get('add_to_wishlist','1') && $this->config->get('display_add_to_wishlist_for_free_products','1') && !$hideForGuest && !$this->config->get('display_add_to_cart_for_free_products')){
	if(!empty($this->row->has_options)){
		if($this->params->get('add_to_cart',1)) echo $this->cart->displayButton(JText::_('CHOOSE_OPTIONS'),'choose_options',$this->params,hikashop_completeLink('product&task=show&product_id='.$this->row->product_id.'&name='.$this->row->alias.$url_itemid.$this->category_pathway),'window.location = \''.str_replace("'","\'",hikashop_completeLink('product&task=show&product_id='.$this->row->product_id.'&name='.$this->row->alias.$url_itemid.$this->category_pathway)).'\';return false;','');
	}else{
		$wishlistAjax =	'if(hikashopCheckChangeForm(\'item\''.$formName.')){ return hikashopModifyQuantity(\'' . (int)@$this->row->product_id . '\',field,1' . $formName . ',\'wishlist\','.$module_id.'); } else { return false; }';
		echo '<div id="hikashop_add_wishlist">';
			echo $this->cart->displayButton(JText::_('ADD_TO_WISHLIST'),'add',$this->params,$url,$wishlistAjax,'',@$this->row->product_max_per_order,1,'',false);
		echo '</div>';
	}
}

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

  • Posts: 441
  • Thank you received: 24
11 years 1 week ago #154543

copy/paste in the file but did not work, it continues displaying no stock in the product listing

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

  • Posts: 12953
  • Thank you received: 1778
11 years 1 week ago #154554

Hello,
1.Can you check that you replaced the code of the "quantity" file of the "product" view of the GOOD template through "Hikashop->Display->Views" ?
2. Can you show me through some screenshots what do yo exactly want to do ?

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

  • Posts: 441
  • Thank you received: 24
11 years 1 week ago #154710







As you can see nothing changed

Attachments:

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

  • Posts: 12953
  • Thank you received: 1778
11 years 1 week ago #154729

And did you check that you edited the file of the GOOD front-end template that you are currently using ?

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

  • Posts: 441
  • Thank you received: 24
11 years 1 week ago #154826

YES

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

  • Posts: 13201
  • Thank you received: 2322
11 years 1 week ago #154838

Hi,

Thanks to try to replace:

echo JText::_('NO_STOCK');
By:
$l = JRequest::getVar('layout','??');
if($l == 'listing'){
	echo '<a href="'.hikashop_completeLink('product&task=show&product_id='.$this->row->product_id.'&name='.$this->row->alias.$url_itemid.$this->category_pathway).'" class="button btn">'.JText::_('SEE_THE_PRODUCT').'</a>';
}else{
	echo JText::_('NO_STOCK').'<br/>';
}

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

  • Posts: 441
  • Thank you received: 24
11 years 1 week ago #154916

Great Xavier works like charm. Thanks

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

  • Posts: 36
  • Thank you received: 0
10 years 2 months ago #193688

Hello Xavier and Hikashop team,

I am trying to follow this post in order to get rid of the no stock display, or to include something similar in order to get rid of it.

The code above does not work. Maybe any changement from 10 months ago till date?
I even tried to delete the entire line

echo JText::_('NO_STOCK');

and the text does not even delete on page products.

Honored

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

  • Posts: 83779
  • Thank you received: 13567
  • MODERATOR
10 years 2 months ago #193698

Hi,

If you delete that line from the view file and you don't see any change it can come from two things:
- You're editing the file from the wrong template. Make sure that you're doing it for your frontend template.
- You have some caching on your website preventing you from seeing the change.

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

  • Posts: 36
  • Thank you received: 0
10 years 2 months ago #193969

Dear Nicolas,
This is strange, because when editing products, I try to put quantity, on the quantitity field,.
I tried to change it from Unlimited to 8 for example and still says no stock display.

No cache activated and all cache and browser cache cleaned.

So I went to HikaShop > Display > Views:

I go to my template and select front end. Then going to product quantity to edit it.
I try to delete the line :
echo JText::_('NO_STOCK');
and still the display No stock appears.

So I want to delete that display, by even delete the piece or code or by including some item quantity, but nothing happens and no item quantity even displayed.

Honored dear Nicolas

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

  • Posts: 36
  • Thank you received: 0
10 years 2 months ago #193993

waiting for reply

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

  • Posts: 83779
  • Thank you received: 13567
  • MODERATOR
10 years 2 months ago #193973

Hi,

I don't see how that's possible.
Can you give a link to the page ?

The following user(s) said Thank You: BloodyBakala

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

  • Posts: 36
  • Thank you received: 0
10 years 2 months ago #194230

Hello back dear,

unfortunately I am finishing it on localhost. if needed i will upload for you.

By the way, this is the complete product / quantity.php .

I just deleted the end:

line echo JText::_('NO_STOCK');

after

<div class="hikashop_product_no_stock">

***************************************

<?php
/**
 * @package	HikaShop for Joomla!
 * @version	2.3.0
 * @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

if($this->config->get('show_quantity_field')==-2){
	$this->params->set('show_quantity_field',$this->row->product_display_quantity_field);
}

$config =& hikashop_config();

$wishlistEnabled = $config->get('enable_wishlist', 1);
$hideForGuest = 1;
if(($config->get('hide_wishlist_guest', 1) && hikashop_loadUser() != null) || !$config->get('hide_wishlist_guest', 1)){
	$hideForGuest = 0;
}

if(!isset($this->cart)) $this->cart = hikashop_get('helper.cart');
if(!empty($this->row->has_options)){
	if($this->params->get('add_to_cart',1)) echo $this->cart->displayButton(JText::_('CHOOSE_OPTIONS'),'choose_options',$this->params,hikashop_completeLink('product&task=show&product_id='.$this->row->product_id.'&name='.$this->row->alias.$this->itemid.$this->category_pathway),'window.location = \''.str_replace("'","\'",hikashop_completeLink('product&task=show&product_id='.$this->row->product_id.'&name='.$this->row->alias.$this->itemid.$this->category_pathway)).'\';return false;','');
}else{
	$this->cart = hikashop_get('helper.cart');
	$url = '';
	$module_id = $this->params->get('from_module',0);
	if(empty($this->ajax)){
		$this->ajax = 'return hikashopModifyQuantity(\''.$this->row->product_id.'\',field,1,0,\'cart\','.$module_id.')';
	}
	if(@$this->row->product_sale_start || empty($this->element->main)){
		$start_date = @$this->row->product_sale_start;
	}else{
		$start_date = $this->element->main->product_sale_start;
	}
	if(@$this->row->product_sale_end || empty($this->element->main)){
		$end_date = @$this->row->product_sale_end;
	}else{
		$end_date = $this->element->main->product_sale_end;
	}
	$formName = ',0';
	if (!$this->config->get('ajax_add_to_cart', 0) || ($this->config->get('show_quantity_field')>=2 && !@$this->element->product_id)) {
		if(empty($this->formName)) {
			if(@$this->row->product_id)
				$formName = ',\'hikashop_product_form_'.$this->row->product_id.'_'.$this->params->get('main_div_name').'\'';
			else
				$formName = ',\'hikashop_product_form_'.$this->params->get('main_div_name').'\'';
		} else {
			$formName = $this->formName;
		}
	}
	if($end_date && $end_date<time()){
		?>
		<span class="hikashop_product_sale_end">
			<?php echo JText::_('ITEM_NOT_SOLD_ANYMORE'); ?>
		</span>
		<?php
	}elseif($start_date && $start_date>time()){
		?>
		<span class="hikashop_product_sale_start">
			<?php
			echo JText::sprintf('ITEM_SOLD_ON_DATE',hikashop_getDate($start_date,$this->params->get('date_format','%d %B %Y')));
			?>
		</span>
		<?php
	}elseif(!$this->params->get('catalogue') && ($this->config->get('display_add_to_cart_for_free_products') || !empty($this->row->prices))){
		if(@$this->row->product_min_per_order || empty($this->element->main)){
			$min = @$this->row->product_min_per_order;
		}else{
			$min = @$this->element->main->product_min_per_order;
		}
		if(@$this->row->product_max_per_order || empty($this->element->main)){
			$max = @$this->row->product_max_per_order;
		}else{
			$max = @$this->element->main->product_max_per_order;
		}
		if($min<=0){
			$min=1;
		}
		$wishlistAjax =	'if(hikashopCheckChangeForm(\'item\''.$formName.')){ return hikashopModifyQuantity(\'' . (int)@$this->row->product_id . '\',field,1' . $formName . ',\'wishlist\','.$module_id.'); } else { return false; }';

		if($this->row->product_quantity == -1 && !empty($this->element->main) && $this->element->main->product_quantity != -1){
			$this->row->product_quantity = $this->element->main->product_quantity;
		}
		$btnType = 'add';
		if($this->row->product_quantity==-1){
		?>
		<div class="hikashop_product_stock">
		<?php
			if($this->params->get('add_to_cart',1)){
				echo $this->cart->displayButton(JText::_('ADD_TO_CART'),'add',$this->params,$url,$this->ajax,'',$max,$min);
				$btnType = 'wish';
			}
			if(hikashop_level(1) && $this->params->get('add_to_wishlist') && $wishlistEnabled && !$hideForGuest && $this->config->get('display_add_to_wishlist_for_free_products','1')){
				echo '<div id="hikashop_add_wishlist">';
					echo $this->cart->displayButton(JText::_('ADD_TO_WISHLIST'),$btnType,$this->params,$url,$wishlistAjax,'',$max,$min,'',false);
				echo '</div>';
			}
		}elseif($this->row->product_quantity>0){
		?>
		<div class="hikashop_product_stock">
		<?php
			if($config->get('button_style','normal')=='css'){
				echo '<br />';
			}
			if($max<=0 || $max>$this->row->product_quantity) $max = $this->row->product_quantity;
			if($this->params->get('add_to_cart',1)){
				echo $this->cart->displayButton(JText::_('ADD_TO_CART'),'add',$this->params,$url,$this->ajax,'',$max,$min);
				$btnType = 'wish';
			}
			if(hikashop_level(1) && $this->params->get('add_to_wishlist')  && $wishlistEnabled && !$hideForGuest && $this->config->get('display_add_to_wishlist_for_free_products','1')){
				echo '<div id="hikashop_add_wishlist">';
					echo $this->cart->displayButton(JText::_('ADD_TO_WISHLIST'),$btnType,$this->params,$url,$wishlistAjax,'',$max,$min,'',false);
				echo '</div>';
			}
		}else{
			?>
		<div class="hikashop_product_no_stock">
		<?php
			$waitlist = $this->config->get('product_waitlist',0);
			if(hikashop_level(1) && ($waitlist==2 || ($waitlist==1 && (!empty($this->element->main->product_waitlist) || !empty($this->element->product_waitlist))))){ ?>
				</div><div id="hikashop_product_waitlist_main" class="hikashop_product_waitlist_main">
				<?php
				$empty='';
				jimport('joomla.html.parameter');
				$params = new HikaParameter($empty);
				echo $this->cart->displayButton(JText::_('ADD_ME_WAITLIST'),'add_waitlist',$params,hikashop_completeLink('product&task=waitlist&cid='.$this->row->product_id),'window.location=\''.str_replace("'","\'",hikashop_completeLink('product&task=waitlist&cid='.$this->row->product_id)).'\';return false;');
			}
			if(hikashop_level(1) && $this->params->get('add_to_wishlist')  && $wishlistEnabled  && !$hideForGuest && $this->config->get('display_add_to_wishlist_for_free_products','1')){
				echo '<div id="hikashop_add_wishlist">';
					echo $this->cart->displayButton(JText::_('ADD_TO_WISHLIST'),'add',$this->params,$url,$wishlistAjax,'',@$this->row->product_max_per_order,1,'',false);
				echo '</div>';
			}
		}?>
		</div>
	<?php
	}elseif(hikashop_level(1) && $wishlistEnabled && $this->params->get('add_to_wishlist','1') && $this->config->get('display_add_to_wishlist_for_free_products','1') && !$hideForGuest && !$this->config->get('display_add_to_cart_for_free_products')){
		$wishlistAjax =	'if(hikashopCheckChangeForm(\'item\''.$formName.')){ return hikashopModifyQuantity(\'' . (int)@$this->row->product_id . '\',field,1' . $formName . ',\'wishlist\','.$module_id.'); } else { return false; }';
		echo '<div id="hikashop_add_wishlist">';
			echo $this->cart->displayButton(JText::_('ADD_TO_WISHLIST'),'add',$this->params,$url,$wishlistAjax,'',@$this->row->product_max_per_order,1,'',false);
		echo '</div>';
	}
}

Last edit: 10 years 2 months ago by Xavier. Reason: Use of [code]...[/code] tags

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

  • Posts: 36
  • Thank you received: 0
10 years 2 months ago #194232

Here is a screen

Attachments:

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

  • Posts: 13201
  • Thank you received: 2322
10 years 2 months ago #194257

Hi,

The text don't seem to be coming from the view "product / quantity" but from another one.
We don't have that by default in HikaShop, so it is potentially a view override made by your template.

Please check in the view "product / show_default" if there is no code related on that.

The following user(s) said Thank You: BloodyBakala

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

  • Posts: 36
  • Thank you received: 0
10 years 2 months ago #194432

Thank you very much xavier and nicolas. Closed it.

This small code was at my template view "product / show_default" , I just deleted :
else{ echo '<span class="hikashop_product_stock_count">'.JText::_('NO_STOCK').'</span>';}

See all piece of code. Closed for me. i hope it to be useful to somebody else. Your are the best guys!

/////////////////

<?php
if( $this->row->main->product_quantity > 0){
echo '<span class="hikashop_product_stock_count">'.JText::sprintf('X_ITEMS_IN_STOCK',$this->row->main->product_quantity).'</span>';
}else{ echo '<span class="hikashop_product_stock_count">'.JText::_('NO_STOCK').'</span>';} ?>

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

Time to create page: 0.139 seconds
Powered by Kunena Forum