Adding to cart not working properly

  • Posts: 26
  • Thank you received: 1
8 years 6 days ago #255411

-- HikaShop version -- : 2.6.4
-- Joomla version -- : 3.6.4
-- PHP version -- : 5.6

Hi,

I thinks this is a bug however i'm not sure. The adding to cart functionality was working fine but now i have encountered a problem. When a product has multiple characteristics i can only add 1 product to my cart. If i select quantity 10, only 1 adds to the cart. When a product has one characteristic this is working fine. The products do not have any limits.

I there a setting that i have messed up? is this a bug? I'd like to know!

Thanks!

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 6 days ago #255415

Hi,

It works fine on our end. Could you provide a link to the page with the issue ?

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

  • Posts: 26
  • Thank you received: 1
8 years 4 days ago #255588

Hi,

This is the url of the demo server: www.slimbedacht.nu/bloomingnotes/index.php/webshop/diversen

When i add less than 10, one product adds to the cart. When i select more than 10. 10 products add to the cart

When you look at this page you can see it works properly: www.slimbedacht.nu/bloomingnotes/index.php/webshop/product/test


Extra bug

On this page: www.slimbedacht.nu/bloomingnotes/index.p...p/product/verjaardag i have some extra characteristics active. This creates serveral problems. sometimes the characteristics are passed wrong to the checkout. In this demo the characteristics are not passed at all to the checkout.

Also the cart can't find the name in this situations. Error:

Notice: Undefined property: stdClass::$main_product_name in /public/sites/www.slimbedacht.nu/bloomingnotes/templates/bloomingnotes/html/com_hikashop/checkout/cart.php on line 128

Characterisics error:
Notice: Undefined property: stdClass::$characteristics in /public/sites/www.slimbedacht.nu/bloomingnotes/templates/bloomingnotes/html/com_hikashop/checkout/cart.php on line 210

I dit var_dump on the characteristics and the value is NULL.

I have already deleted all the products and characteristics but nothing helps.



Thanks!

Last edit: 8 years 4 days ago by jannick.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 4 days ago #255596

Hi,

I suppose that the issue is with your template.
Rename the folder templates/YOUR_TEMPLATE/html/com_hikashop/product/ via FTP and you shouldn't have the problem.
If so, then try renaming each file in that folder until you find the one creating the problem.
Either keep it renamed if it isn't a problem for the product page display, or ask your template provider (or the designer who customized that view file on your end) to fix that view file.

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

  • Posts: 26
  • Thank you received: 1
8 years 3 days ago #255652

Thanks for the Reply!

You were right(ofcorse) the problem is in a template file. The template contains the following file wich causes the error: hikashop_characteristics.php to override the characteristics table layout on the product page. The file contains the following code:

<?php

function hikashop_characteristics_html(&$element,&$params, &$obj){
		if(empty($element->main->characteristics)) return '';
		$obj->characteristics=&$element->main->characteristics;
		foreach($obj->characteristics as $k => $characteristic){
			if(empty($obj->characteristics[$k]->characteristic_display_method)){
				$obj->characteristics[$k]->characteristic_display_method = $params->get('characteristic_display');
			}
		}
		$obj->load();


		if(empty($html)){
			switch($params->get('characteristic_display')){
				default:
				case 'radio':
				case 'dropdown':
					$main_html = '<div class="hikashop_product_characteristics_table">';
					$config =& hikashop_config();
					foreach($obj->characteristics as $characteristic){
						$main_html.='<div class="hikashop_characteristic_line_'.$characteristic->characteristic_id.'">';
						$values = array();
						$switch_done = false;
						if(!empty($characteristic->values)){
							foreach($characteristic->values as $k => $value){
								if(!$config->get('show_out_of_stock',1)){
									$hasQuantity = false;
									foreach($element->variants as $variant){
										foreach($variant->characteristics as $variantCharacteristic){
											if($variantCharacteristic->characteristic_id==$value->characteristic_id){
												if($variant->product_quantity != 0){
													$hasQuantity = true;
												}elseif( $element->product_id==$variant->product_id && !$switch_done){
													if($characteristic->characteristic_display_method == 'dropdown'){
														$id = 'hikashop_product_characteristic_'.$characteristic->characteristic_id;
														$js = "hikashopUpdateVariant(document.getElementById('".$id."'));";
													}else{
														$id = 'hikashop_product_characteristic['.$characteristic->characteristic_id.']';
														$js = "var el = document.querySelector('[name=\"".$id."\"]'); if(el) el.checked = true; hikashopUpdateVariant(el);";
													}

													$js = "
													window.hikashop.ready( function() {".$js."});";
													if (!HIKASHOP_PHP5) {
														$doc =& JFactory::getDocument();
													}else{
														$doc = JFactory::getDocument();
													}
													$doc->addScriptDeclaration("\n<!--\n".$js."\n//-->\n");
													$switch_done = true;
												}
											}
										}
									}
									if(!$hasQuantity) continue;
								}
								$values[$k]=$value->characteristic_value;
							}
						}


						$html=$obj->display(@$characteristic->characteristic_id,@$characteristic->default->characteristic_id,$values,$characteristic->characteristic_display_method);
						if($params->get('characteristic_display_text') && isset($characteristic->characteristic_value)){
							$html=$characteristic->characteristic_value.'</div><div class="col-md-9">'.$html;
						}
						$main_html.='<div class="row"><div class="col-md-3">'.$html.'</div></div>';
					}
					$main_html.='</div></div>';
					$html = $main_html;
					break;
			}
		}
		$html.='
		<noscript>
			<input type="submit" class="btn button" name="characteristic" value="'.JText::_('REFRESH_INFORMATION').'"/>
		</noscript>';
		return $html;
	}

I have followed another topic wich said: create this function, paste the core code in the function and replace $this with $obj. Could you tell the problem with this code?

Thanks in advance!

Last edit: 8 years 3 days ago by Jerome. Reason: [code] is nice !

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 3 days ago #255660

Hi,

Well, try changing the line:
return $html;
to:
return $html.'</div>';

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

  • Posts: 26
  • Thank you received: 1
8 years 1 day ago #255771

I thought the problem would something more than just a closing div tag. The problem was in the following line: $main_html.='<div class="row"><div class="col-md-3">'.$html.'</div></div></div>';

Thanks!!

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

Time to create page: 0.070 seconds
Powered by Kunena Forum