Problems related to shopping cart

  • Posts: 12
  • Thank you received: 0
10 years 5 months ago #160015

-- url of the page with the problem -- : still in localhost
-- HikaShop version -- : HikaShop Essential 2.3.1
-- Joomla version -- : 2.5.20
-- PHP version -- : 5.3.13
-- Browser(s) name and version -- : Any browsers
-- Error-message(debug-mod must be tuned on) -- : Error_message

Not logged-in user cannot update the item quantities in the cart.
Notice: Trying to get property of non-object in D:\wamp\www\hikashop\components\com_hikashop\controllers\cart.php on line 191

At first I thought it was caused from my mistakes during template overriding. But then I did a fresh install of Joomla and Hikashop in another folder just to test around using the default Joomla 2.5.20 theme. The same problem still exists.

Last edit: 10 years 5 months ago by ylont.

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

  • Posts: 12
  • Thank you received: 0
10 years 5 months ago #160016

Another bug.

When a logged in user populated his cart and then logs out without checking out and then try to visit the cart page as a guest, the page says "Please login first" instead of loading the cart template and showing "The cart is empty".

To test this, I have the Shopping Cart direct link menu item created. The menu item type is Cart Display.

Last edit: 10 years 5 months ago by ylont. Reason: changed title

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

  • Posts: 12
  • Thank you received: 0
10 years 5 months ago #160017

And one more odd bug.

When a user fills in products to his cart as a guest, then logs in using the Joomla standard Login menu item, and then go to visit his cart using a "cart display" menu item, the page shows "You are not authorized to see this resource" instead of the cart content that he sees as a guest.

This problem fixes itself when the user adds another item into the cart after logging in.

This problem can also happen when we remove the Cart box from the checkout workflow in the configuration. However when the Cart box is not omitted and the user logs in as part of the checkout flow, the problem doesn't occur.

It seems like the cart has to be loaded once after logging in to be properly initialized and carried over from the guest session.

Last edit: 10 years 5 months ago by ylont. Reason: changed title

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
10 years 5 months ago #160119

Hi,

1. This looks like a caching issue. Can you make sure that all the cache is disabled on your website ?

2. This is the normal behavior. The carts management interface of the frontend where you can see all your carts is only available for logged in users. Note that this is different from the checkout where you can see your current cart, even when not logged in, and which will display that "the cart is empty" error if you try to access it without a cart.

3. It would seem more like a problem with the user not been synchronized between Joomla and HikaShop. That would happen if the user synchronization plugin is turned off. Could you check on that in the Joomla plugins manager of your website ?

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

  • Posts: 12
  • Thank you received: 0
10 years 5 months ago #160133

Hi there,

1) I did not enable any kinds of Joomla caching because the website is still under development.

2) Ok understood, I was just trying to figure out the logic based on my experience using Virtuemart. I will work around this.

3) The hikashop user sync plugin was enabled.

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

  • Posts: 12
  • Thank you received: 0
10 years 5 months ago #161272

Hi,

Need some updates here. We are launching our website in approx 10 days.

Thanks

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
10 years 5 months ago #161350

Hi,

We would need an access to the backend and to the frontend of the website to be able to look at these because we cannot reproduce the problems on our end.
Could you put the website online and provide such access?

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

  • Posts: 12
  • Thank you received: 0
10 years 5 months ago #161456

Sure, how can I send these info to you?

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

  • Posts: 2639
  • Thank you received: 66
  • Hikashop Business
10 years 5 months ago #161464

ylont wrote: And one more odd bug.

When a user fills in products to his cart as a guest, then logs in using the Joomla standard Login menu item, and then go to visit his cart using a "cart display" menu item, the page shows "You are not authorized to see this resource" instead of the cart content that he sees as a guest.
.

Same problem time to time for me with J 331and hk 231

Last edit: 10 years 5 months ago by erickb.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
10 years 4 months ago #161473

Hi,

You can use our contact form:
www.hikashop.com/contact-us.html

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

  • Posts: 12
  • Thank you received: 0
10 years 4 months ago #161527

Sent!

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
10 years 4 months ago #161843

Hi,

So regarding the problem with the edition of the quantity of the products in the cart and also regarding the "You are not authorized to see this resource" error when access the cart after logging in, I found the problem.
You need to replace the files components/com_hikashop/controllers/cart.php and components/com_hikashop/views/cart/tmpl/showcart.php with the ones in the archive enclosed and that will fix the problem (note that if you had customized the showcart view file, you'll have to remove the customization and apply it to this new file).

File Attachment:

File Name: h1f8c75a.zip
File Size:8 KB


The modifications will also be included in the next version of HikaShop.

Attachments:

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

  • Posts: 12
  • Thank you received: 0
10 years 4 months ago #162487

Hi,

Thanks for the update unfortunately it didn't fix any of the issues you mentioned :(

We still can't edit the items quantity in the cart and "You are not authorized to see this resource" error when access the cart after logging in still exists.

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

  • Posts: 13201
  • Thank you received: 2322
10 years 4 months ago #162501

Hi,

We made some fixes which should solve this issue, this will be available in the next package.

Thanks to contact us via the contact form and give us your order number, this way we will send you a preview package of the next release.

hikashop.com/support/contact-us.html

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

  • Posts: 12
  • Thank you received: 0
10 years 4 months ago #163751

Hi there,

I have just downloaded v2.3.2. The "update item quantity in cart bug" still exist no matter logged in or not. Funny thing that when you're not logged in there's a Save button, but not when you're logged in so you need to press Enter instead.

d.pr/i/iq9Z

I didn't test the other bugs mentioned above but this one is really the most annoying one. I tested this on a clean joomla install.

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

  • Posts: 13201
  • Thank you received: 2322
10 years 4 months ago #163774

Hi,

Thanks to replace your "cart / showcart" view content by:

<?php
$cart_type = JRequest::getString('cart_type','cart');
$cart_id = JRequest::getInt('cart_id','');
$tmpl = JRequest::getString('tmpl','view');
$config = hikashop_config();
global $Itemid;
$url_itemid = '&Itemid='.$Itemid;
if($cart_type == 'wishlist'){
	$addText = JText::_('ADD_TO_CART');
}
else{
	$addText = JText::_('ADD_TO_WISHLIST');
}
$app = JFactory::getApplication();
$session = JFactory::getSession();
$userCurrent = hikashop_loadUser(true);
if(isset($userCurrent))
	$userCurrent = $userCurrent->id;
else
	$userCurrent = 0;
$hasAccess = $this->cartVal->user_id == $userCurrent || $this->cartVal->session_id == $session->getId();

?>
<form method="POST" id="hikashop_show_cart_form" name="hikashop_show_cart_form" action="<?php echo hikashop_completeLink('cart'.$url_itemid);?>">
<div onload="document.getElementById('task').value='savecart'" id="hikashop_cart_listing">
<?php if($tmpl != 'component'){ ?>
<fieldset>
	<div class="header hikashop_header_title"><h1><?php if($cart_type == 'cart')echo JText::_('CARTS');else echo JText::_('WISHLISTS'); ?></h1></div>
	<div class="toolbar hikashop_header_buttons" id="toolbar" style="float: right;">
		<table class="hikashop_no_border">
			<tr>
				<td>
					<?php
						if($cart_type == 'cart' && $config->get('enable_multicart')){
					?>
							<a href="<?php echo hikashop_completeLink('cart&task=showcarts&cart_type='.$cart_type.$url_itemid); ?>">
								<span class="icon-32-show_cart" title="<?php echo JText::_('DISPLAY_THE_CARTS'); ?>">
								</span>
								<?php echo JText::_('DISPLAY_THE_CARTS'); ?>
							</a>
					<?php
						}elseif($userCurrent == $this->cartVal->user_id && $cart_type == 'wishlist' && $config->get('enable_multicart')){
					?>
							<a href="<?php echo hikashop_completeLink('cart&task=showcarts&cart_type='.$cart_type.$url_itemid); ?>">
								<span class="icon-32-show_wishlist" title="<?php echo JText::_('DISPLAY_THE_WISHLISTS'); ?>">
								</span>
								<?php echo JText::_('DISPLAY_THE_WISHLISTS'); ?>
							</a>
					<?php
						}
					?>
				</td>
			<!-- Wishlist V2
				<td>
					<a title="<?php echo JText::_('HIKA_EMAIL');?>" class="modal" rel="{handler: 'iframe', size: {x: 760, y: 480}}" href="<?php echo hikashop_completeLink('product&task=sendcart',true); ?>">
						<img src="<?php echo HIKASHOP_IMAGES; ?>go.png" alt="<?php echo JText::_('HIKA_EMAIL');?>"/>
					</a>
				</td>
			-->
				<td>
					<?php echo $this->popup->display(
						'<span class="icon-32-print" title="'. JText::_('HIKA_PRINT').'"></span>'. JText::_('HIKA_PRINT'),
						'HIKA_PRINT',
						hikashop_completeLink('cart&task=showcart&cart_type='.$cart_type.'&cart_id='.$cart_id,true),
						'hikashop_print_cart',
						760, 480, '', '', 'link'
					); ?>
				</td>
				<?php 
				$session = JFactory::getSession();
				if($this->cartVal->display && ($userCurrent == $this->cartVal->user_id || $session->getId() == $this->cartVal->session_id)){ ?>
				<td>
					<a href="#" onclick="javascript:document.forms['hikashop_show_cart_form'].submit();">
						<span class="icon-32-save" title="<?php echo JText::_('HIKA_SAVE'); ?>">
						</span>
						<?php echo JText::_('HIKA_SAVE'); ?>
					</a>
				</td>
				<?php } ?>
				<td>
				<?php
				if(!$config->get('enable_multicart')){
				?>
					<a href="#" onclick="history.back()">
				<?php
				}else{
				?>
					<a href="<?php echo JRoute::_('index.php?option='.HIKASHOP_COMPONENT.'&ctrl=cart&task=showcarts&cart_type='.$cart_type.$url_itemid); ?>" >
				<?php } ?>
						<span class="icon-32-back" title="<?php echo JText::_('HIKA_BACK'); ?>">
						</span>
						<?php echo JText::_('HIKA_BACK'); ?>
					</a>
				</td>
			</tr>
		</table>
	</div>
</fieldset>
<?php
}else{
	$js = "window.hikashop.ready( function() {setTimeout(function(){window.focus();window.print();setTimeout(function(){hikashop.closeBox();}, 1000);},1000);});";
	$doc = JFactory::getDocument();
	$doc->addScriptDeclaration("\n<!--\n".$js."\n//-->\n");
}

if(($this->cartVal->display == 'registered' && $userCurrent == 0) || ($this->cartVal->display == 'link' && JRequest::getString('link',0) == 0)){
	$this->cartVal->display = 0;
}

if(($this->cartVal->display && $cart_type == 'wishlist') || ($this->cartVal->display == 'main' && $cart_type == 'cart' && $hasAccess)){

?>
<div class="iframedoc" id="iframedoc"></div>
<table class="hikashop_showcart_infos table table-striped table-hover" width="100%">
	<?php if($userCurrent == $this->cartVal->user_id || $session->getId() == $this->cartVal->session_id){ ?>
	<tr>
		<td class="key">
			<?php echo JText::_('HIKASHOP_CART_NAME'); ?>:
		</td>
		<td width="60%">
		<?php if($tmpl != 'component'){ ?>
			<input type="text" id="cart_name" name="cart_name" value="<?php echo $this->cartVal->cart_name; ?>" class="inputbox"/>
		<?php }else{ ?>
			<span id="hikashop_wishlist_name" class="hikashop_wishlist_name"><?php echo $this->cartVal->cart_name; ?></span>
		<?php } ?>
		</td>
	</tr>
	<?php } if($cart_type != 'cart' && ($userCurrent == $this->cartVal->user_id || $session->getId() == $this->cartVal->session_id)){ ?>
	<tr>
		<td class="key">
	<?php
		$baseUrl = JURI::base();
		$baseUrl .= 'index.php?option=com_hikashop&ctrl=';
		$token = "";
		if($this->cartVal->display == 'public'){
			$displayLink = JText::_('HIKASHOP_EVERYBODY');
		}elseif($this->cartVal->display == 'registered'){
			$displayLink = JText::_('HIKASHOP_REGISTERED_USERS');
		}elseif(!$this->cartVal->display || $this->cartVal->display == 'main' || $this->cartVal->display == 'nobody'){
			$this->cartVal->display = 'nobody';
			$displayLink = JText::_('HIKASHOP_NOBODY');
		}else{// email
			$displayLink = JText::_('HIKA_EMAIL');
			$token = $this->cartVal->display;
			$this->cartVal->display = 'email';
		}
		echo JText::_('SHARE'); ?>:
		</td>
		<td>
			<span id="hikashop_wishlist_share" class="hikashop_wishlist_share">
				<select style="width:145px;" id="hikashop_wishlist_share_select" name="cart_share" onChange="showLink(cart_share.value);">
					<option value="<?php echo $this->cartVal->display;?>"><?php echo $displayLink; ?></option>
				 	<?php
				 	if($this->cartVal->display != "nobody")
						echo "<option value='nobody'>".JText::_('HIKASHOP_NOBODY')."</option>";
					if($this->cartVal->display != "public")
						echo "<option value='public'>".JText::_('HIKASHOP_EVERYBODY')."</option>";
				 	if($this->cartVal->display != "registered")
						echo "<option value='registered'>".JText::_('HIKASHOP_REGISTERED_USERS')."</option>";
				 	if($this->cartVal->display != "email")
						echo "<option value='email'>".JText::_('HIKA_EMAIL')."</option>";
					?>
				</select>
			</span>
			<span class="hikashop_wishlist_share_text" id="hikashop_wishlist_share_text"></span>
		</td>
	</tr>
	<script type="text/javascript">
		window.onload=function(){
			var link = document.getElementById('hikashop_wishlist_link');
			var linkDisplay = document.getElementById('hikashop_wishlist_link_display');
			var linkDisplayText = document.getElementById('hikashop_wishlist_link_display_text');
			var linkShare = document.getElementById('hikashop_wishlist_share');
			var linkShareSelect = document.getElementById('hikashop_wishlist_share_select').value;
			var linkShareText = document.getElementById('hikashop_wishlist_share_text');
			if(linkShareSelect == 'public') linkShareText.innerHTML = 'Anybody';
			else if(linkShareSelect == 'registered') linkShareText.innerHTML = 'Registered users';
			else if(linkShareSelect == 'email') linkShareText.innerHTML = 'E-mail';
			else linkShareText.innerHTML = 'Nobody';
			if(linkShareSelect == 'email'){
				link.style.display="table-row";
				if(linkDisplay){
					linkDisplay.value = "<?php echo $baseUrl.'cart&task=showcart&cart_id='.$cart_id.'&cart_type='.$cart_type.'&Itemid='.$Itemid.'&link='.$token ?>";
					linkShareText.style.display="none";
				}
				if(linkDisplayText){
					linkDisplayText.innerHTML = "<?php echo $baseUrl.'cart&task=showcart&cart_id='.$cart_id.'&cart_type='.$cart_type.'&Itemid='.$Itemid.'&link='.$token ?>";
					linkShare.style.display="none";
				}
			}else if(linkShareSelect == 'nobody'){
				link.style.display="none";
				if(linkDisplay){
					linkShareText.style.display="none";
				}else{
					linkShare.style.display="none";
				}
			}else{
				link.style.display="table-row";
				if(linkDisplay){
					linkDisplay.value = "<?php echo $baseUrl.'cart&task=showcart&cart_id='.$cart_id.'&cart_type='.$cart_type.'&Itemid='.$Itemid ?>";
					linkShareText.style.display="none";
				}
				if(linkDisplayText){
					linkDisplayText.innerHTML = "<?php echo $baseUrl.'cart&task=showcart&cart_id='.$cart_id.'&cart_type='.$cart_type.'&Itemid='.$Itemid ?>";
					linkShare.style.display="none";
				}
			}
		}
		function showLink(share){
			var link = document.getElementById('hikashop_wishlist_link');
			var linkShareText = document.getElementById('hikashop_wishlist_share_text');
			link.style.display="none";
			var linkDisplay = document.getElementById('hikashop_wishlist_link_display');
			var linkDisplayText = document.getElementById('hikashop_wishlist_link_display_text');
			if(share == 'public') linkShareText.innerHTML = 'Anybody';
			else if(share == 'registered') linkShareText.innerHTML = 'Registered users';
			else if(share == 'email') linkShareText.innerHTML = 'E-mail';
			else linkShareText.innerHTML = 'Nobody';
			if(share == 'public' || share == 'registered'){
				if(linkDisplay)
					linkDisplay.value = "<?php echo $baseUrl.'cart&task=showcart&cart_id='.$cart_id.'&cart_type='.$cart_type.'&Itemid='.$Itemid ?>";
				if(linkDisplayText)
					linkDisplayText.innerHTML = "<?php echo $baseUrl.'cart&task=showcart&cart_id='.$cart_id.'&cart_type='.$cart_type.'&Itemid='.$Itemid ?>";
				link.style.display="table-row";
			}
			else if(share == 'email'){
				<?php
					$chaine = "abcdefghijklmnpqrstuvwxy0123456789";
					srand((double)microtime()*1000000);
					for($i=0; $i<20; $i++) {
						$token .= $chaine[rand()%strlen($chaine)];
					}
					$tokenLink = '&link='.$token;
				?>
				if(linkDisplay)
					linkDisplay.value = "<?php echo $baseUrl.'cart&task=showcart&cart_id='.$cart_id.'&cart_type='.$cart_type.'&Itemid='.$Itemid.$tokenLink ?>";
				if(linkDisplayText)
					linkDisplayText.innerHTML = "<?php echo $baseUrl.'cart&task=showcart&cart_id='.$cart_id.'&cart_type='.$cart_type.'&Itemid='.$Itemid.$tokenLink ?>";
				link.style.display="table-row";
			}
			else{
				link.style.display="none";
			}
			link.focus();
		}
	</script>
	<input type="hidden" name="hikashop_wishlist_token" value="<?php echo $token; ?>"/>
	<tr width="100%" id='hikashop_wishlist_link' style="display:none;">
		<td  class="key">
			<span class="hikashop_wishlist_link_text"><?php echo JText::_('HIKASHOP_WISHLIST_LINK'); ?>:</span>
		</td>
		<?php if($tmpl != 'component'){ ?>
		<td width="60%">
			<input onClick="javascript:this.focus();this.select();" style="width:100%;" readonly="readonly" type="text" id="hikashop_wishlist_link_display" name="hikashop_wishlist_link_display" value=""/>
		</td>
	</tr>
		<?php }else{ ?>
	<tr><td colspan="2"><span class="hikashop_wishlist_link_display_text" id="hikashop_wishlist_link_display_text"></span></td></tr>
		<?php
		}
		?>
	<?php } ?>
</table>
	<table id="hikashop_cart_product_listing" class="hikashop_cart_products adminlist table table-striped table-hover" cellpadding="1">
		<thead>
			<tr>
				<th class="hikashop_cart_num_title title titlenum" align="center">
					<?php echo JText::_( 'HIKA_NUM' );?>
				</th>
				<th class="hikashop_cart_image_title title" align="center">
					<?php echo JText::_( 'HIKA_IMAGE' );?>
				</th>
				<th class="hikashop_cart_name_title title" align="center">
					<?php echo JText::_('CART_PRODUCT_NAME'); ?>
				</th>
				<th class="hikashop_cart_quantity_title title" align="center">
					<?php echo JText::_('PRODUCT_QUANTITY'); ?>
				</th>
				<th class="hikashop_cart_price_title title" align="center">
					<?php echo JText::_('PRODUCT_PRICE'); ?>
				</th>
				<th class="hikashop_cart_status_title title" align="center">
					<?php echo JText::_('HIKASHOP_CHECKOUT_STATUS'); ?>
				</th>
				<?php if($tmpl != 'component' && hikashop_level(1) && (($this->config->get('enable_wishlist') && $cart_type == 'cart')||$cart_type == 'wishlist')){ ?>
				<th class="hikashop_cart_action_title title" align="center">
					<a  style="cursor: pointer;" onClick="checkAll();"><?php echo JText::_('HIKASHOP_ADD_TO'); ?></a>
				</th>
				<th class="hikashop_cart_delete_title title" align="center">
					<?php echo JText::_('HIKA_DELETE'); ?>
				</th>
				<?php } ?>
			</tr>
		</thead>
		<tbody>
			<?php
			$app = JFactory::getApplication();
			$config =& hikashop_config();
			$i = 1;
			$k = 1;
			$total_quantity = 0;
			if(!empty($this->rows)){
				$productClass = hikashop_get('class.product');
				$group = $this->config->get('group_options',0);
				foreach($this->rows as $cart){
					if($group && $cart->cart_product_option_parent_id) continue;
					if(!@$cart->hide){
						$total_quantity += $cart->cart_product_quantity;
						$productClass->addAlias($cart);
						$quantityLeft = $cart->product_quantity - $cart->cart_product_quantity;
						$inStock = 1;
						if(($cart->product_quantity - $cart->cart_product_quantity) >= 0 || $cart->product_quantity == -1){
							if($cart->product_quantity == -1)
								$stockText = "<span class='hikashop_green_color'>".JText::sprintf('X_ITEMS_IN_STOCK',JText::_('HIKA_UNLIMITED'))."</span>";
							else
								$stockText = "<span class='hikashop_green_color'>".JText::sprintf('X_ITEMS_IN_STOCK',$cart->product_quantity)."</span>";
						}else{
							if($cart->product_code != @$cart->cart_product_code){
								$stockText = "<span class='hikashop_red_color'>".JText::_('HIKA_NOT_SALE_ANYMORE'). "</span>";
							}else{
								$stockText = "<span class='hikashop_red_color'>".JText::_('NOT_ENOUGH_STOCK')."</span>";
							}
							$inStock = 0;
						}
						if($k ==1)$k = 0;else $k =1;
						?>
						<tr class="hikashop_show_cart row<?php echo $k; if((int)$cart->cart_product_quantity == 0) echo " hika_wishlist_green";?>">
							<td data-title="<?php echo JText::_('HIKA_NUM'); ?>" align="center"><?php echo $i; ?></td>
							<td data-title="<?php echo JText::_('HIKA_IMAGE'); ?>" align="center">
							<?php
								$width = (int)$this->config->get('thumbnail_x');
								$height = (int)$this->config->get('thumbnail_y');
								if(isset($cart->images[0])){
									$image_options = array('default' => true,'forcesize'=>$this->config->get('image_force_size',true),'scale'=>$this->config->get('image_scale_mode','inside'));
									$img = $this->image->getThumbnail(@$cart->images[0]->file_path, array('width' => $width, 'height' => $height), $image_options);
									if($img->success) {
										echo '<img class="hikashop_product_cart_image" title="'.$this->escape(@$cart->images[0]->file_description).'" alt="'.$this->escape(@$cart->images[0]->file_name).'" src="'.$img->url.'"/>';
									}
								}
									//echo '<img src="' . $this->image->uploadFolder_url.'thumbnail_'.$width.'x'.$height.'/'.$cart->images[0]->file_path . '" alt="' . $cart->images[0]->file_name . '" id="hikashop_main_image" style="margin-top:10px;margin-bottom:10px;display:inline-block;vertical-align:middle" />';
							?>
							</td>
							<td data-title="<?php echo JText::_('CART_PRODUCT_NAME'); ?>" align="center">
								<a class="hikashop_no_print" href="<?php echo hikashop_contentLink('product&task=show&cid='.$cart->product_id.'&name='.$cart->alias.'&Itemid='.$Itemid,$cart); ?>">
								<?php
									if(!isset($cart->bought) || !$cart->bought){
										echo $cart->product_name;
									}else{
										echo JHTML::tooltip(implode('<br />',$cart->bought), JText::_('HIKA_BOUGHT_BY'), '',$cart->product_name);
									}
									if($this->params->get('show_code')){
										echo ' ('.$cart->product_code.')';
									}
								?>
								</a>
								<?php
								$input='';
								if($group){
									foreach($this->rows as $j => $optionElement){
										if($optionElement->cart_product_option_parent_id != $cart->cart_product_id) continue;
										 ?>
											<p class="hikashop_cart_option_name">
												<?php
													echo $optionElement->product_name;
												?>
											</p>
									<?php
									$input .='document.getElementById(\'cart_product_option_'.$optionElement->cart_product_id.'\').value=qty_field.value;';
									echo '<input type="hidden" id="cart_product_option_'.$optionElement->cart_product_id.'" name="item['.$optionElement->cart_product_id.'][cart_product_quantity]" value="'.$cart->cart_product_quantity.'"/>';
									}

									foreach($this->rows as $j => $optionElement){
										if($optionElement->cart_product_option_parent_id != $cart->cart_product_id) continue;
										if(!empty($optionElement->prices[0])){
											if(!isset($cart->prices[0])){
												$cart->prices[0]->price_value=0;
												$cart->prices[0]->price_value_with_tax=0;
												$cart->prices[0]->price_currency_id = hikashop_getCurrency();
											}
											foreach(get_object_vars($cart->prices[0]) as $key => $value){
												if(is_object($value)){
													foreach(get_object_vars($value) as $key2 => $var2){
														if(strpos($key2,'price_value')!==false) $cart->prices[0]->$key->$key2 +=@$optionElement->prices[0]->$key->$key2;
													}
												}else{
													if(strpos($key,'price_value')!==false) $cart->prices[0]->$key+=@$optionElement->prices[0]->$key;
												}
											}
										}
									}
								}
								?>
							</td>
							<td data-title="<?php echo JText::_('PRODUCT_QUANTITY'); ?>" align="center">
								<?php
								if($cart->product_quantity_layout == 'show_select' || (empty($cart->product_quantity_layout) && $this->config->get('product_quantity_display', '') == 'show_select')){
									$min_quantity = $cart->product_min_per_order;
									$max_quantity = $cart->product_max_per_order;
									if($min_quantity == 0)
										$min_quantity = 1;
									if($max_quantity == 0)
										$max_quantity = (int)$min_quantity * 15;
									?>
									<select id="hikashop_showcart_quantity_select_<?php echo $cart->cart_product_id;?>" class="tochosen" onchange="var qty_field = document.getElementById('hikashop_product_quantity_field_<?php echo $cart->product_id;?>'); qty_field.value = this.value; if (qty_field){<?php echo $input; ?> } return false;">
										<?php
										for($j = $min_quantity; $j <= $max_quantity; $j += $min_quantity){
											$selected = '';
											if($j == $cart->cart_product_quantity)
												$selected = 'selected="selected"';
											echo '<option value="'.$j.'" '.$selected.'>'.$j.'</option>';
										}
										?>
									</select>
									<input id="hikashop_product_quantity_field_<?php echo $cart->product_id;?>" type="hidden" name="item[<?php echo $cart->cart_product_id;?>]" class="hikashop_show_cart_quantity"  value="<?php echo $cart->cart_product_quantity; ?>" />
								<?php
								}else{
								?>
									<input id="hikashop_product_quantity_field_<?php echo $cart->product_id;?>" type="text" name="item[<?php echo $cart->cart_product_id;?>]" class="hikashop_show_cart_quantity"  value="<?php echo $cart->cart_product_quantity; ?>" />
								<?php
								}
								?>
							</td>
							<td data-title="<?php echo JText::_('PRODUCT_PRICE'); ?>" align="center">
							<?php
								if(!isset($cart->prices[0])){
									$cart->prices[0] = new stdClass();
									$cart->prices[0]->price_value=0;
									$cart->prices[0]->price_value_with_tax=0;
									$cart->prices[0]->price_currency_id = hikashop_getCurrency();
								}

								if($this->params->get('show_cart_price','-1')=='-1'){
									$this->params->set('show_cart_price',$config->get('show_cart_price'));
								}
								if ($this->params->get('show_cart_price',1)) {
									if(empty($cart->prices[0]->price_value)){
										echo JText::_('FREE_PRICE');
									}else{
										if($config->get('price_with_tax')){
											echo $this->currencyHelper->format($cart->prices[0]->price_value_with_tax,$cart->prices[0]->price_currency_id);
										}
										if($config->get('price_with_tax')==2){
											echo JText::_('PRICE_BEFORE_TAX');
										}
										if($config->get('price_with_tax')==2||!$config->get('price_with_tax')){
											echo $this->currencyHelper->format($cart->prices[0]->price_value,$cart->prices[0]->price_currency_id);
										}
										if($config->get('price_with_tax')==2){
											echo JText::_('PRICE_AFTER_TAX');
										}
									}
								}
							?>
							</td>
							<td data-title="<?php echo JText::_('HIKASHOP_CHECKOUT_STATUS'); ?>" align="center"><?php echo $stockText;?></td>
							<?php if($tmpl != 'component'){
									if(hikashop_level(1) && (($this->config->get('enable_wishlist') && $cart_type == 'cart')||$cart_type == 'wishlist')){
								?>
							<td data-title="<?php echo JText::_('HIKASHOP_ADD_TO'); ?>"  align="center" class="hikashop_show_cart_add">
								<?php
//									$cartAjax =	'if(hikashopCheckChangeForm(\'item\',\'hikashop_show_cart_form\')){ return hikashopModifyQuantity(\'' . $cart->product_id . '\',document.getElementById(\'hikashop_product_quantity_field_'.$cart->product_id.'\'),1,\'hikashop_show_cart_form\',\'wishlist\'); } else { return false; }';
//									$wishlistAjax =	'if(hikashopCheckChangeForm(\'item\',\'hikashop_show_cart_form\')){ return hikashopModifyQuantity(\'' . $cart->product_id . '\',document.getElementById(\'hikashop_product_quantity_field_'.$cart->product_id.'\'),1,\'hikashop_show_cart_form\',\'cart\'); } else { return false; }';
//									if($inStock ==1){
//										$url = '';
//										$this->params->set('show_quantity_field',2);
//										if($cart_type == 'wishlist'){
//											$this->ajax = $wishlistAjax;
//											echo $this->cart->displayButton(JText::_('ADD_TO_CART'),'add',$this->params,$url,$this->ajax,'',$cart->product_max_per_order,$cart->product_min_per_order);
//										}else{
//											$this->ajax = $cartAjax;
//											echo $this->cart->displayButton(JText::_('ADD_TO_WISHLIST'),'add',$this->params,$url,$this->ajax,'',$cart->product_max_per_order,$cart->product_min_per_order);
//										}
//									}
								?>
								<input type="checkbox" name="data[products][<?php echo $cart->product_id;?>][checked]" value="1"/>
							</td>
							<?php }
								if($userCurrent == $this->cartVal->user_id || $session->getId() == $this->cartVal->session_id){ ?>
							<td data-title="<?php echo JText::_('HIKA_DELETE'); ?>" align="center" class="hikashop_show_cart_delete">
								<a class="hikashop_no_print" href="<?php echo hikashop_completeLink('product&task=updatecart&stay=1&delete=1&quantity=0&cart_type='.$cart_type.'&cart_id='.$cart->cart_id.'&cart_product_id='.$cart->cart_product_id.'&Itemid='.$Itemid); ?>"  title="<?php echo JText::_('HIKA_DELETE'); ?>">
									<img src="<?php echo HIKASHOP_IMAGES . 'delete2.png';?>" border="0" alt="<?php echo JText::_('HIKA_DELETE'); ?>" />
								</a>
							</td>
						<?php
							}
						}
						?>
						</tr>
						<?php
						$i++;
					}
				}
				if($cart_type == 'wishlist') echo '<input type="hidden" name="add_to" value="cart"/>';
				else echo '<input type="hidden" name="add_to" value="wishlist"/>';
			}
			?>
		</tbody>
		<tfoot>
			<tr class="hika_show_cart_total">
				<td class="hika_show_cart_total_text">
					<?php echo JText::_('HIKASHOP_TOTAL'); ?>
				</td>
				<td></td>
				<td align="center" class="hika_show_cart_total_quantity">
					<?php echo $total_quantity; ?>
				</td>
				<td align="center" class="hika_show_cart_total_price">
					<?php
						if(empty($this->total->prices)) {
							$this->total->prices[0] = new stdClass();
							$this->total->prices[0]->price_value = 0;
							$this->total->prices[0]->price_value_with_tax = 0;
							$this->total->prices[0]->price_currency_id = hikashop_getCurrency();
						}
						if($config->get('price_with_tax')){
							echo $this->currencyHelper->format($this->total->prices[0]->price_value_with_tax,$this->total->prices[0]->price_currency_id);
						}
						if($config->get('price_with_tax')==2){
							echo JText::_('PRICE_BEFORE_TAX');
						}
						if($config->get('price_with_tax')==2||!$config->get('price_with_tax')){
							echo $this->currencyHelper->format($this->total->prices[0]->price_value,$this->total->prices[0]->price_currency_id);
						}
						if($config->get('price_with_tax')==2){
							echo JText::_('PRICE_AFTER_TAX');
						}
					?>
				</td>
				<?php if($tmpl != 'component'){ ?>
				<td></td>
				<?php if(hikashop_level(1) && (($this->config->get('enable_wishlist') && $cart_type == 'cart')||$cart_type == 'wishlist')){ ?>
				<td align="center">
					<?php
						echo $this->cart->displayButton($addText,'wishlist',$this->params,hikashop_completeLink('cart&task=convert&cart_type=cart&cart_id='.$cart_id.'&Itemid='.$Itemid),'document.getElementById(\'task\').value = \'addtocart\'; document.forms[\'hikashop_show_cart_form\'].submit(); return false;');
						if($cart_type == 'wishlist' && $config->get('show_compare',0) != 0 && $config->get('wishlist_to_compare',0) != 0)
							echo $this->cart->displayButton(JText::_('HIKASHOP_COMPARE_LIST'),'wishlist',$this->params,'','document.getElementById(\'task\').value = \'addtocart\'; document.getElementById(\'action\').value = \'compare\'; document.forms[\'hikashop_show_cart_form\'].submit(); return false;');
					?>
				</td>
				<?php } ?>
				<td></td>
				<?php } ?>
			</tr>
		</tfoot>
	</table>
<?php
		if($cart_type == 'cart' && $total_quantity > 0 && hikashop_level(1) && $this->config->get('enable_wishlist')&&$tmpl != 'component'){
			//$baseUrl = JURI::base();
			//echo '<a class="hikashop_cart_button" href="'.$baseUrl.'/index.php?option=com_hikashop&ctrl=cart&task=convert&cart_type=cart&Itemid=64">Convert cart in wishlist</a>';
			$this->params->set('cart_type','wishlist');
			echo $this->cart->displayButton(JText::_('CART_TO_WISHLIST'),'wishlist',$this->params,hikashop_completeLink('cart&task=convert&cart_type=cart&cart_id='.$cart_id.'&Itemid='.$Itemid),'window.location.href = \''.hikashop_completeLink('cart&task=convert&cart_type=cart&cart_id='.$cart_id.'&Itemid='.$Itemid).'\';return false;');
		}
	}else{
		echo "<div class='hikashop_not_authorized'>".JText::_('HIKASHOP_NOT_AUTHORIZED')."</div>";
	}
?>
	</div>
	<div class="clear_both"></div>
	<input type="hidden" id="task" name="task" value="savecart"/>
	<input type="hidden" name="cid" value=""/>
	<input type="hidden" name="cart_id" value="<?php echo $cart_id; ?>"/>
	<input type="hidden" name="from_id" value="<?php echo $cart_id; ?>"/>
	<input type="hidden" name="cart_type" value="<?php echo $cart_type; ?>"/>
	<input type="hidden" id="action" name="action" value=""/>
</form>

Replace:
if($cartInfo != null && $currUser->user_cms_id == $cartInfo->user_id){
By:
if($cartInfo != null && ((isset($currUser->user_cms_id) && $currUser->user_cms_id == $cartInfo->user_id) || $session->getId() == $cartInfo->session_id)){
In "components/com_hikashop/controllers/cart" function "savecart()".

That should solve your issues.

The following user(s) said Thank You: ylont

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

  • Posts: 12
  • Thank you received: 0
10 years 4 months ago #163898

Thank you very much. This fix works.

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

  • Posts: 2639
  • Thank you received: 66
  • Hikashop Business
10 years 4 months ago #163908

another bug

when adding a product in the cart I get the message the cart is empty, after a few try it works

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

Time to create page: 0.088 seconds
Powered by Kunena Forum