Quantity increase or decrease won't work

  • Posts: 43
  • Thank you received: 3
8 months 2 weeks ago #359655

-- HikaShop version -- : 5.0.2
-- Joomla version -- : 5.0.3
-- PHP version -- : 8.1.13
-- Browser(s) name and version -- : firefox

Hi, Hope u are all great.
I have a problem with the quantity box which does not increase or decrease the quantity when clicking on + or -.
for the first time when it is not shown, when you click on the add to cart button it increases quantity to 1 but it got frezed on number 1.
what should I do?
Thanks in advance

my show_default.php code:

<?php
/**
 * @package	HikaShop for Joomla!
 * @version	5.0.2
 * @author	hikashop.com
 * @copyright	(C) 2010-2023 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php
	$form = ',0';
	if(!$this->config->get('ajax_add_to_cart', 1)) {
		$form = ',\'hikashop_product_form\'';
	}
?>
<div id="hikashop_product_top_part" class="hikashop_product_top_part">
<!-- TOP BEGIN EXTRA DATA -->
<?php if(!empty($this->element->extraData->topBegin)) { echo implode("\r\n",$this->element->extraData->topBegin); } ?>
<!-- EO TOP BEGIN EXTRA DATA -->

<!-- TOP END EXTRA DATA -->
<?php if(!empty($this->element->extraData->topEnd)) { echo implode("\r\n", $this->element->extraData->topEnd); } ?>
<!-- EO TOP END EXTRA DATA -->

</div>

<div class="hk-row-fluid">
	<div id="hikashop_product_left_part" class="hikashop_product_left_part hkc-md-6">
<!-- LEFT BEGIN EXTRA DATA -->
<?php if(!empty($this->element->extraData->leftBegin)) { echo implode("\r\n",$this->element->extraData->leftBegin); } ?>
<!-- EO LEFT BEGIN EXTRA DATA -->

<!-- LEFT END EXTRA DATA -->
<?php if(!empty($this->element->extraData->leftEnd)) { echo implode("\r\n",$this->element->extraData->leftEnd); } ?>
<!-- EO LEFT END EXTRA DATA -->
	</div>

	<div id="hikashop_product_right_part" class="hikashop_product_right_part hkc-md-6">
<!-- RIGHT BEGIN EXTRA DATA -->
<?php if(!empty($this->element->extraData->rightBegin)) { echo implode("\r\n",$this->element->extraData->rightBegin); } ?>
<!-- EO RIGHT BEGIN EXTRA DATA -->


<!-- RIGHT MIDDLE EXTRA DATA -->
<?php if(!empty($this->element->extraData->rightMiddle)) { echo implode("\r\n",$this->element->extraData->rightMiddle); } ?>
<!-- EO RIGHT MIDDLE EXTRA DATA -->







<!-- RIGHT END EXTRA DATA -->
<?php if(!empty($this->element->extraData->rightEnd)) { echo implode("\r\n",$this->element->extraData->rightEnd); } ?>
<!-- EO RIGHT END EXTRA DATA -->
<span id="hikashop_product_id_main" class="hikashop_product_id_main">
	<input type="hidden" name="product_id" value="<?php echo (int)$this->element->product_id; ?>" />
</span>
</div>
</div>
<!-- END GRID -->
<div id="hikashop_product_bottom_part" class="hikashop_product_bottom_part">
<!-- BOTTOM BEGIN EXTRA DATA -->
<?php if(!empty($this->element->extraData->bottomBegin)) { echo implode("\r\n",$this->element->extraData->bottomBegin); } ?>
<!-- EO BOTTOM BEGIN EXTRA DATA -->


<!-- FILES -->
<?php
	$this->setLayout('show_block_product_files');
	echo $this->loadTemplate();
?>
<!-- EO FILES -->
<!-- BOTTOM MIDDLE EXTRA DATA -->
<?php if(!empty($this->element->extraData->bottomMiddle)) { echo implode("\r\n",$this->element->extraData->bottomMiddle); } ?>
<!-- EO BOTTOM MIDDLE EXTRA DATA -->
<!-- BOTTOM END EXTRA DATA -->
<?php if(!empty($this->element->extraData->bottomEnd)) { echo implode("\r\n",$this->element->extraData->bottomEnd); } ?>
<!-- EO BOTTOM END EXTRA DATA -->
</div>

<!-- HP HIKASHOP Product Page Layout Begins! -->
<div class="container hppadding0">
	<div class="row"><!-- Product Top Infos -->
		<div class="col-xl-4 col-lg-4"><!-- Product Images gallery/ Like/share/compare/add to list -->
			<!-- IMAGE -->
			<?php
				$this->row =& $this->element;
				$this->setLayout('show_block_img');
				echo $this->loadTemplate();
			?>
			<!-- EO IMAGE -->
		</div>
		<div class="col-xl-8 col-lg-8"><!-- Product Infos-Name/code/comment count-rating charactricstis and prices -->
			<div class="col-xl-12 col-lg-12"><!-- Product Name -->
				<!-- NAME -->
				<h1 class="hphikah1name">
					<span id="hikashop_product_name_main" class="hikashop_product_name_main" itemprop="name"><?php
						if(hikashop_getCID('product_id') != $this->element->product_id && isset($this->element->main->product_name))
							echo $this->element->main->product_name;
						else
							echo $this->element->product_name;
					?></span>
				</h1>
				<!-- EO NAME -->
			</div>
			<div class="col-xl-12 col-lg-12 hphikatopleft1"><!-- Product SKU/details/price box -->
				<div class="col-xl-8 col-lg-8"><!-- Product SKU/Details -->
					<h1 class="hphikacodeskuh1">
						<!-- CODE -->
						<?php if ($this->config->get('show_code')) { ?>
						<span class="hpflexrow10">
								<span id="hikashop_product_code_main" class="hikashop_product_code_main"><?php
									echo $this->element->product_code;
								?></span>
							<span class="hphikacodefrontline1"></span>
						</span>
						<?php } ?>
						<!-- EO CODE -->
								<meta itemprop="sku" content="<?php echo $this->element->product_code; ?>">
								<meta itemprop="productID" content="<?php echo $this->element->product_code; ?>">
					</h1>
					<!--Mini star for JLexreview -->
						<?php
						/** Mini star **/
						$loader = JPATH_ROOT . '/components/com_jlexreview/load.php';
						if(file_exists($loader)){
							require_once $loader;
							echo JLexReviewLoad::quick_init('hikashop', (isset($this->element->main) ? (int)$this->element->main->product_id : (int)$this->element->product_id ));
						}
						?>
					<!--EO Mini star for JLexreview -->
					<!-- SOCIAL NETWORKS -->
					<?php
						$this->setLayout('show_block_social');
						echo $this->loadTemplate();
					?>
					<!-- EO SOCIAL NETWORKS -->
					<!-- VOTE -->
							<div id="hikashop_product_vote_mini" class="hikashop_product_vote_mini"><?php
						if($this->params->get('show_vote_product')) {
							$js = '';
							$this->params->set('vote_type', 'product');
							$this->params->set('vote_ref_id', isset($this->element->main) ? (int)$this->element->main->product_id : (int)$this->element->product_id );
							echo hikashop_getLayout('vote', 'mini', $this->params, $js);
						}
							?></div>
					<!-- EO VOTE -->
					<!-- DIMENSIONS -->
					<?php
						$this->setLayout('show_block_dimensions');
						echo $this->loadTemplate();
					?>
					<!-- EO DIMENSIONS -->
							<br />
					<!-- CHARACTERISTICS -->
					<?php
						if($this->params->get('characteristic_display') != 'list') {
							$this->setLayout('show_block_characteristic');
							echo $this->loadTemplate();
					?>
							<br />
					<?php } ?>
					<!-- EO CHARACTERISTICS -->
					<!-- OPTIONS -->
					<?php
						if(hikashop_level(1) && !empty ($this->element->options)) {
					?>
							<div id="hikashop_product_options" class="hikashop_product_options"><?php
								$this->setLayout('option');
								echo $this->loadTemplate();
							?></div>
							<br />
					<?php
							$form = ',\'hikashop_product_form\'';
							if($this->config->get('redirect_url_after_add_cart', 'stay_if_cart') == 'ask_user') {
					?>
							<input type="hidden" name="popup" value="1"/>
					<?php
							}
						}
					?>
					<!-- EO OPTIONS -->
					<!-- MANUFACTURER URL -->
						<span id="hikashop_product_url_main" class="hikashop_product_url_main"><?php
							if(!empty($this->element->product_url)) {
								echo JText::sprintf('MANUFACTURER_URL', '<a href="' . $this->element->product_url . '" target="_blank">' . $this->element->product_url . '</a>');
							}
						?></span>
					<!-- EO MANUFACTURER URL -->
					<!-- Short Description -->
					<p class=""><span class="hphikashdesc"><?php echo JText::_('SHORT_DESCRIPTION_HP1');?></span></p>
					<?php echo $this->element->product_short_description; ?>
					<div class="hphikashortdescbot1">
						<hr class="">
						<a href="#hphikacustomfields" class="hphikashortdescbot1a"><span class="hphikashortdescbot1a1"><?php echo JText::_('SHOWALLCUSTOMFIELDS');?></span><span class="fa fa-chevron-left hphikaico1" aria-hidden="true"></span></a>
						<hr class="">
					</div>
					<!-- EO Short Description -->
				</div>
				<div class="col-xl-4 col-lg-4 hphikapricearea"><!-- Product price box -->
					<!-- PRICE -->
						<!-- SELLER -->
						<p class=""><span class="hphikaproductseller"><?php echo JText::_('PRODUCT_SELLER');?></span></p>
						<?php echo $this->element->product_seller; ?>
						<!-- EO SELLER -->
					<?php
						$itemprop_offer = 'itemprop="offers" itemscope itemtype="https://schema.org/Offer"';
					?>
							<span id="hikashop_product_price_main" class="hikashop_product_price_main" <?php echo $itemprop_offer; ?>>
					<?php
						$main =& $this->element;
						if(!empty($this->element->main))
							$main =& $this->element->main;
						if(!empty($main->product_condition) && !empty($this->element->prices)) {
					?>
								<meta itemprop="itemCondition" itemtype="https://schema.org/OfferItemCondition" content="https://schema.org/<?php echo $main->product_condition; ?>" />
					<?php
						}
						if($this->params->get('show_price') && (empty($this->displayVariants['prices']) || $this->params->get('characteristic_display') != 'list')) {
							$this->row =& $this->element;
							$this->setLayout('listing_price');
							echo $this->loadTemplate();

							$price = 0;
							if (!empty($this->element->prices)) {
								$price = $this->itemprop_price;
							}
						}
							?>	<meta itemprop="price" content="<?php echo $price; ?>" />
								<meta itemprop="availability" content="https://schema.org/<?php echo ($this->row->product_quantity != 0) ? 'InStock' : 'OutOfstock' ;?>" />
								<meta itemprop="priceCurrency" content="<?php echo $this->currency->currency_code; ?>" />
							</span>
					<!-- EO PRICE -->
					<!-- PRICE WITH OPTIONS -->
					<?php
						if($this->params->get('show_price')) {
					?>
							<span id="hikashop_product_price_with_options_main" class="hikashop_product_price_with_options_main">
							</span>
					<?php
						}
					?>
					<!-- EO PRICE WITH OPTIONS -->
					<!-- ADD TO CART BUTTON -->
					<?php
						if(empty($this->element->characteristics) || $this->params->get('characteristic_display') != 'list') {
					?>
							<div id="hikashop_product_quantity_main" class="hikashop_product_quantity_main"><?php
								$this->row =& $this->element;
								$this->formName = $form;
								$this->ajax = 'if(hikashopCheckChangeForm(\'item\',\'hikashop_product_form\')){ return hikashopModifyQuantity(\'' . (int)$this->element->product_id . '\',field,1' . $form . ',\'cart\'); } else { return false; }';
								$this->setLayout('quantity');
								echo $this->loadTemplate();
							?></div>
							<div id="hikashop_product_quantity_alt" class="hikashop_product_quantity_main_alt" style="display:none;">
								<?php echo JText::_('ADD_TO_CART_AVAILABLE_AFTER_CHARACTERISTIC_SELECTION'); ?>
							</div>
					<?php
						}
					?>
					<!-- EO ADD TO CART BUTTON -->
					
				</div>
			</div>
			
			<!-- HP HIKA Product Detail Page Module Position --BEGIN-- -->
			<?php 
			$hphikaproductbottom1_modules = 'hphikaproductbottom1';
			$attrs = array();
			$result = null;
			$renderer = JFactory::getDocument()->loadRenderer('modules');
			$hphikaproductbottom1 = $renderer->render($hphikaproductbottom1_modules, $attrs, $result);
			if ($hphikaproductbottom1) : ?>
			<div class="content-inline t4-module module">
				<?php echo $hphikaproductbottom1 ?>				
			</div>
			<?php endif ?>
			<!-- HP HIKA Product Detail Page Module Position --END-- -->
			
		</div>
	</div>
	<div class="row hphiksecborbotsep">
		<div class="col-xl-12 col-lg-12"><!-- Extra Statics infos -->
			
			<!-- TAGS -->
			<?php
				if(HIKASHOP_J30) {
					$this->setLayout('show_block_tags');
					echo $this->loadTemplate();
				}
			?>
			<!-- EO TAGS -->
			
		</div>
	</div>
	<div class="row">
		<div class="col-xl-12 col-lg-12"><!-- Products similar products -->
			<!-- HP HIKA Product Detail Page Module Position --BEGIN-- -->
			<?php 
			$hphikaproductbottom_modules = 'hphikaproductbottom';
			$attrs = array();
			$result = null;
			$renderer = JFactory::getDocument()->loadRenderer('modules');
			$hphikaproductbottom = $renderer->render($hphikaproductbottom_modules, $attrs, $result);
			if ($hphikaproductbottom) : ?>
			<div class="content-inline t4-module module">
				<?php echo $hphikaproductbottom ?>				
			</div>
			<?php endif ?>
			<!-- HP VM Product Detail Page Module Position --END-- -->
		</div>
	</div>
	<div class="row hphisecmdiv">
		<div class="col-xl-12 col-lg-12 hppadding0"><!-- Shortcut to product infos -->
			<ul class="hpulno hpflexrow hphisectitleul">
				<li class="active" onclick="activateHphitiborderbot(this)"><a class="hphiksectitle" href="<?php echo JRoute::_('#hikashop_product_description_main'); ?>"><?php echo JText::_('MAIN_DESCRIPTION'); ?></a><div class="hphitiborderbot hpsectitleleft1"></div></li>
				<li onclick="activateHphitiborderbot(this)"><a class="hphiksectitle" href="<?php echo JRoute::_('#hikashop_product_custom_info_main'); ?>"><?php echo JText::_('SPECIFICATIONS'); ?></a><div class="hphitiborderbot hpsectitleleft2"></div></li>
				<li onclick="activateHphitiborderbot(this)"><a class="hphiksectitle" href="<?php echo JRoute::_('#CUSTOMER_REVIEW_SEC'); ?>"><?php echo JText::_('JR_CUSTOMER_REVIEW'); ?></a><div class="hphitiborderbot hpsectitleleft3"></div></li>
			</ul>
		</div>
	</div>
	<div class="row hppadding0">
		<div class="col-xl-12 col-lg-12 hppadding0 hphikadesccesdiv1">
			<div class="col-xl-9 col-lg-9 hppadding0"><!-- Details -->
				<!-- DESCRIPTION -->
				<h2 id="hikashop_product_description_main" class=""><span class="hphikamaindesc"><?php echo JText::_('MAIN_DESCRIPTION');?></span></h2>
					<div class="hikashop_product_description_main" itemprop="description"><?php
						echo JHTML::_('content.prepare',preg_replace('#<hr *id="system-readmore" */>#i','',$this->element->product_description));
					?></div>
				<!-- EO DESCRIPTION -->
				<!-- CUSTOM PRODUCT FIELDS -->
				<?php
					if(!empty($this->fields)) {
						$this->setLayout('show_block_custom_main');
						echo $this->loadTemplate();
					}
				?>
				<!-- EO CUSTOM PRODUCT FIELDS -->
				<!-- CUSTOM ITEM FIELDS -->
				<?php
					if(!$this->params->get('catalogue') && ($this->config->get('display_add_to_cart_for_free_products') || ($this->config->get('display_add_to_wishlist_for_free_products', 1) && hikashop_level(1) && $this->params->get('add_to_wishlist') && $this->config->get('enable_wishlist', 1)) || !empty($this->element->prices))) {
						if(!empty($this->itemFields)) {
							$form = ',\'hikashop_product_form\'';
							if ($this->config->get('redirect_url_after_add_cart', 'stay_if_cart') == 'ask_user') {
				?>
						<input type="hidden" name="popup" value="1"/>
				<?php
							}
							$this->setLayout('show_block_custom_item');
							echo $this->loadTemplate();
						}
					}
				?>
				<!-- EO CUSTOM ITEM FIELDS -->
				<!-- CONTACT US BUTTON -->
							<div id="hikashop_product_contact_main" class="hikashop_product_contact_main"><?php
						$contact = (int)$this->config->get('product_contact', 0);
						if(hikashop_level(1) && ($contact == 2 || ($contact == 1 && !empty($this->element->product_contact)))) {
							$css_button = $this->config->get('css_button', 'hikabtn');
							$attributes = 'class="'.$css_button.'"';
							$fallback_url = hikashop_completeLink('product&task=contact&cid=' . (int)$this->element->product_id . $this->url_itemid);
							$content = JText::_('CONTACT_US_FOR_INFO');

							echo $this->loadHkLayout('button', array( 'attributes' => $attributes, 'content' => $content, 'fallback_url' => $fallback_url));
						}
					?>
							</div>
				<!-- EO CONTACT US BUTTON -->
				<!-- JLEX Review -->
				
				<!-- EO JLEX Review -->
			</div>
			<div class="col-xl-3 col-lg-3"><!-- Float price box -->
				<div class="hphikapricearea bottomsidstickypbox">
				<!-- PRICE -->
					<?php
						$itemprop_offer = 'itemprop="offers" itemscope itemtype="https://schema.org/Offer"';
					?>
							<span id="hikashop_product_price_main" class="hikashop_product_price_main" <?php echo $itemprop_offer; ?>>
					<?php
						$main =& $this->element;
						if(!empty($this->element->main))
							$main =& $this->element->main;
						if(!empty($main->product_condition) && !empty($this->element->prices)) {
					?>
								<meta itemprop="itemCondition" itemtype="https://schema.org/OfferItemCondition" content="https://schema.org/<?php echo $main->product_condition; ?>" />
					<?php
						}
						if($this->params->get('show_price') && (empty($this->displayVariants['prices']) || $this->params->get('characteristic_display') != 'list')) {
							$this->row =& $this->element;
							$this->setLayout('listing_price');
							echo $this->loadTemplate();

							$price = 0;
							if (!empty($this->element->prices)) {
								$price = $this->itemprop_price;
							}
						}
							?>	<meta itemprop="price" content="<?php echo $price; ?>" />
								<meta itemprop="availability" content="https://schema.org/<?php echo ($this->row->product_quantity != 0) ? 'InStock' : 'OutOfstock' ;?>" />
								<meta itemprop="priceCurrency" content="<?php echo $this->currency->currency_code; ?>" />
							</span>
					<!-- EO PRICE -->
					<!-- PRICE WITH OPTIONS -->
					<?php
						if($this->params->get('show_price')) {
					?>
							<span id="hikashop_product_price_with_options_main" class="hikashop_product_price_with_options_main">
							</span>
					<?php
						}
					?>
					<!-- EO PRICE WITH OPTIONS -->
					<!-- ADD TO CART BUTTON -->
					<?php
						if(empty($this->element->characteristics) || $this->params->get('characteristic_display') != 'list') {
					?>
							<div id="hikashop_product_quantity_main" class="hikashop_product_quantity_main"><?php
								$this->row =& $this->element;
								$this->formName = $form;
								$this->ajax = 'if(hikashopCheckChangeForm(\'item\',\'hikashop_product_form\')){ return hikashopModifyQuantity(\'' . (int)$this->element->product_id . '\',field,1' . $form . ',\'cart\'); } else { return false; }';
								$this->setLayout('quantity');
								echo $this->loadTemplate();
							?></div>
							<div id="hikashop_product_quantity_alt" class="hikashop_product_quantity_main_alt" style="display:none;">
								<?php echo JText::_('ADD_TO_CART_AVAILABLE_AFTER_CHARACTERISTIC_SELECTION'); ?>
							</div>
					<?php
						}
					?>
					<!-- EO ADD TO CART BUTTON -->
				</div>
			</div>
		</div>
	</div>
</div>
<script>
  function activateHphitiborderbot(selectedLi) {
    // Remove 'active' class from all list items
    document.querySelectorAll('li').forEach(li => {
      li.classList.remove('active');
    });
    // Add 'active' class to the clicked list item
    selectedLi.classList.add('active');
  }
</script>

Last edit: 8 months 2 weeks ago by diacotm.

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

  • Posts: 43
  • Thank you received: 3
8 months 2 weeks ago #359656

I copied the price box content to a new position for the time that the price box hide in the screen to a new position and gave it a sticky position. because of that quantity box won't work properly but the copied price box code at the bottom position worked!
Please help me with this
Thanks

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
8 months 2 weeks ago #359664

Hi,

Could you provide the URL of the page with the issue so that we can look at the result and analyze what's going on ?

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

  • Posts: 43
  • Thank you received: 3
8 months 1 week ago #359715

Hi, thanks for your reply
Sure,
here you are,

onlineshop.tesla360.ir/index.php/product/1-lamp-10-wat-mganwr

the copied price box which is the second one, located in the middle of the page works fine but the first one is not working, it is frozen at the amount of 1.

Thanks in advance

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
8 months 1 week ago #359718

Hi,

I would recommend turning off the "synchronized add to cart" setting of the HikaShop configuration and configuring the "Quantity input method" setting there to not display a quantity input field.
That way, the user will be able to use each add to cart button on the page, and use them several times if he needs to add the product several times in the cart.
Otherwise, if you really need to have a quantity input field, I would recommend not duplicating the add to cart area. Having several quantity input fields with several add to cart buttons in the same HTML form won't work properly and you'll struggle trying to do what you're trying to do at the moment. It's not impossible but quite complex to achieve with the way the product page is made in HikaShop, even for me.

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

Time to create page: 0.063 seconds
Powered by Kunena Forum