Coupon restriction on product not working

  • Posts: 39
  • Thank you received: 0
13 years 4 months ago #2024

I'm trying to build a fixed amount coupon for a specific product, when comes time to select the product, I have a pup-up displayiong the products, I then choose the desired item and click "OK", once done, I have a blank page with only one line top left "1 Registre de coaching" appearing (this is the selected product) and nothing else, no button nothing. If I go back, then I get back to the main coupon creation page and there is not attached products.

Got the same problem when trying to affect a zone when comes time to select the zone, I have a pup-up displayiong the zones, I then choose Canada and click "OK", once done, I have a blank page with only one line top left "38 Canada" appearing (this is the selected product) and nothing else, no button nothing. If I go back, then I get back to the main coupon creation page and there is not attached zones.

I also just tried to build a simple coupon with a %, I can create the coupon but it is impossible to use on the front-end, I always have a message saying "Le code du coupon que vous avez entré n'est pas valide"

This look's like if some debugging code where still in the component code

Joomla 1.5.22
Hikashop 1.3.6
IE 8

Last edit: 13 years 4 months ago by goldriver.

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

  • Posts: 81361
  • Thank you received: 13035
  • MODERATOR
13 years 4 months ago #2025

Hi,

This looks like a limitation of internet explorer.

In the file administrator/components/com_hikashop/views/product/view.html.php near line 685, could you try to replace the code

window.top.document.getElementById('product_id').innerHTML = document.getElementById('result').innerHTML;
by the code
obj = window.top.document.getElementById('product_id');
						while(obj.firstChild) obj.removeChild(obj.firstChild);
						obj.appendChild(document.getElementById('result'));
and try again ?

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

  • Posts: 81361
  • Thank you received: 13035
  • MODERATOR
13 years 4 months ago #2026

For the zone, try to replace the code

window.top.document.getElementById('zone_id').innerHTML = document.getElementById('result').innerHTML;
by the code
obj = window.top.document.getElementById('zone_id');
					while(obj.firstChild) obj.removeChild(obj.firstChild);
					obj.appendChild(document.getElementById('result'));
near line 240 of the file administrator/components/com_hikashop/views/zone/view.html.php and try again.

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

  • Posts: 39
  • Thank you received: 0
13 years 4 months ago #2027

same proble, nothing changes. I also tried with Firefox, same problem.

If you still have credentials for halonacoachong.com/joomlatest, you can go and try. (I've sent then by mail earlier last week)

Last edit: 13 years 4 months ago by goldriver.

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

  • Posts: 81361
  • Thank you received: 13035
  • MODERATOR
13 years 4 months ago #2028

For the "coupon is not valid" error will happen when:
The type of the discount is "discount" and not "coupon" (coupons are to be entered by the user while discounts are applied automatically)
or the coupon is not published
or the code entered doesn't match any coupon code.

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

  • Posts: 81361
  • Thank you received: 13035
  • MODERATOR
13 years 4 months ago #2029

The login you sent me earlier this week do not seem to work as I couldn't login.

Do you have the same problem on our demo website ?

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

  • Posts: 39
  • Thank you received: 0
13 years 4 months ago #2030

I've fixed the credentials, they now should work.

I have not tested on your demo site yet.

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

  • Posts: 81361
  • Thank you received: 13035
  • MODERATOR
13 years 4 months ago #2031

That was something else.

It's a bug we found already at the beginning of the week. On some website the modal javascript library wasn't loaded on that page for some reason. So we added the code below in the view in order to force it:
JHTML::_('behavior.modal');

It's now working on your website.

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

  • Posts: 39
  • Thank you received: 0
13 years 4 months ago #2032

In wich document have you made the change ? I'll need to port that change to the live environment.

Thanks

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

  • Posts: 81361
  • Thank you received: 13035
  • MODERATOR
13 years 4 months ago #2034

you can add it to the file administrator/components/com_hikashop/views/discount/view.html.php just after
$discount_id = hikashop::getCID('discount_id',false);
near line 185

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

  • Posts: 39
  • Thank you received: 0
13 years 4 months ago #2046

It looks like another problem appear, if I select the coupon, I still have a message saying that this coupon is not usable in my zone.

I've check the coupon, it is set to zone 38 and the customer adress is also set to 38, the coupon type is coupon. I've noticed that if I open the coupon, I see the product number and the zone number but right beside I have a message "product not found" and "zone not found"

Last edit: 13 years 4 months ago by goldriver.

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

  • Posts: 81361
  • Thank you received: 13035
  • MODERATOR
13 years 4 months ago #2086

For the display of the "not found" message on the backend it's just a bug in the display. We fixed it on our end.

We were able to reproduce the problem of the coupon not accepted although you're in the good zone on your website.

We tried to edit the files directly via FTP but we got the error "552 Disk full - please upload later" while trying to edit the files.
We will try to reproduce the problem on our end.

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

  • Posts: 39
  • Thank you received: 0
13 years 4 months ago #2087

My provider is having a disk issue, it should be fixed whitin the next hour, if you want, you can test it later (I guess it will be tommorow for you), thanks again for your support

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

  • Posts: 81361
  • Thank you received: 13035
  • MODERATOR
13 years 4 months ago #2089

We were able to reproduce the problem on our end and fixed it. You need to replace the code

			if($coupon->discount_quota && $coupon->discount_quota<=$coupon->discount_used_times){
				$error_message = JText::_('QUOTA_REACHED_FOR_COUPON');
			}elseif($coupon->discount_zone_id && !in_array($coupon->discount_zone_id,$zones)){
				$error_message = JText::_('COUPON_NOT_AVAILABLE_IN_YOUR_ZONE');
			}elseif(bccomp($coupon->discount_minimum_order,0,5)){
				$currency->convertCoupon($coupon,$total->prices[0]->price_currency_id);
				
				if($coupon->discount_minimum_order>$total->prices[0]->price_value){
					$error_message = JText::sprintf('ORDER_NOT_EXPENSIVE_ENOUGH_FOR_COUPON',$currency->format($coupon->discount_minimum_order,$coupon->discount_currency_id));
				}
			}
by the code
			if($coupon->discount_quota && $coupon->discount_quota<=$coupon->discount_used_times){
				$error_message = JText::_('QUOTA_REACHED_FOR_COUPON');
			}else{
				if($coupon->discount_zone_id){
					$class = hikashop::get('class.zone');
					$zone = $class->get($coupon->discount_zone_id);
					if(!in_array($zone->zone_namekey,$zones)){
						$error_message = JText::_('COUPON_NOT_AVAILABLE_IN_YOUR_ZONE');
					}
				}
				if(empty($error_message) && bccomp($coupon->discount_minimum_order,0,5)){
					$currency->convertCoupon($coupon,$total->prices[0]->price_currency_id);
					
					if($coupon->discount_minimum_order>$total->prices[0]->price_value){
						$error_message = JText::sprintf('ORDER_NOT_EXPENSIVE_ENOUGH_FOR_COUPON',$currency->format($coupon->discount_minimum_order,$coupon->discount_currency_id));
					}
				}
			}
in the file administrator/components/com_hikashop/classes/discount.php near line 75. That will fix the check of the zone restriction. For the display problem of the zone name in the edit you can replace the code
if(!empty($element->price_product_id)){
			$query = 'SELECT * FROM '.hikashop::table('product').' WHERE product_id = '.(int)$element->price_product_id;
			$database->setQuery($query);
			$product = $database->loadObject();
			if(!empty($product)){
				foreach(get_object_vars($product) as $key => $val){
					$element->$key = $val;
				}
			}
		}
		if(empty($element->product_name)){
			$element->product_name = JText::_('PRODUCT_NOT_FOUND');
		}
		//get category info
		if(!empty($element->price_category_id)){
			$query = 'SELECT * FROM '.hikashop::table('category').' WHERE category_id = '.(int)$element->price_category_id;
			$database->setQuery($query);
			$category = $database->loadObject();
			if(!empty($category)){
				foreach(get_object_vars($category) as $key => $val){
					$element->$key = $val;
				}
			}
		}
		if(empty($element->category_name)){
			$element->category_name = JText::_('CATEGORY_NOT_FOUND');
		}
		//get zone info
		if(!empty($element->price_zone_id)){
			$query = 'SELECT * FROM '.hikashop::table('zone').' WHERE zone_id = '.(int)$element->price_zone_id;
			$database->setQuery($query);
			$zone = $database->loadObject();
			if(!empty($zone)){
				foreach(get_object_vars($zone) as $key => $val){
					$element->$key = $val;
				}
			}
		}
by the code
if(!empty($element->discount_product_id)){
			$query = 'SELECT * FROM '.hikashop::table('product').' WHERE product_id = '.(int)$element->discount_product_id;
			$database->setQuery($query);
			$product = $database->loadObject();
			if(!empty($product)){
				foreach(get_object_vars($product) as $key => $val){
					$element->$key = $val;
				}
			}
		}
		if(empty($element->product_name)){
			$element->product_name = JText::_('PRODUCT_NOT_FOUND');
		}
		//get category info
		if(!empty($element->discount_category_id)){
			$query = 'SELECT * FROM '.hikashop::table('category').' WHERE category_id = '.(int)$element->discount_category_id;
			$database->setQuery($query);
			$category = $database->loadObject();
			if(!empty($category)){
				foreach(get_object_vars($category) as $key => $val){
					$element->$key = $val;
				}
			}
		}
		if(empty($element->category_name)){
			$element->category_name = JText::_('CATEGORY_NOT_FOUND');
		}
		//get zone info
		if(!empty($element->discount_zone_id)){
			$query = 'SELECT * FROM '.hikashop::table('zone').' WHERE zone_id = '.(int)$element->discount_zone_id;
			$database->setQuery($query);
			$zone = $database->loadObject();
			if(!empty($zone)){
				foreach(get_object_vars($zone) as $key => $val){
					$element->$key = $val;
				}
			}
		}
in the file amdinistrator/components/com_hikashop/views/discount/view.html.php near line 210.

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

  • Posts: 39
  • Thank you received: 0
13 years 4 months ago #2121

Hi Nicolas,

I'm unable to do the second modification, teher is no amdinistrator/components/com_hikashop/views/discount/view.html.php file in my system !

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

  • Posts: 81361
  • Thank you received: 13035
  • MODERATOR
13 years 4 months ago #2126

Hi,

Yes, when I tried to edit it via FTP and that I got the disk space error, I deleted it hoping that it would free some space and that I would be able to upload the new version of the file. Unfortunately, I still had the error afterwards and it wouldn't let me put it back.

You should get that file from your hikashop install package in the folder back/views/discount and upload it manually in order to restore it and apply the fix.

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

  • Posts: 39
  • Thank you received: 0
13 years 4 months ago #2160

Nicolas,

I took the views.html.php file from the installation package and dropped it in the right directory and did the changes mentionned above and here is the message I Have when I try to open a coupon to modify it:

Fatal error: Call to a member function setQuery() on a non-object in /home/brisebo/public_html/halonacoaching.com/joomlatest/administrator/components/com_hikashop/views/discount/view.html.php on line 187

But now the coupon works, I'm just unable to modify the discount once created.

Last edit: 13 years 4 months ago by goldriver.

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

  • Posts: 81361
  • Thank you received: 13035
  • MODERATOR
13 years 4 months ago #2168

Hi,

We just released the new version of HikaShop. You can download it and update your version. That will fix both problems. Alternatively, you can just get the back/views/discount/view.html.php file of the new package and put it over the administrator/components/com_hikashop/views/discount/view.html.php file.

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

  • Posts: 39
  • Thank you received: 0
13 years 4 months ago #2270

Just upgraded to 1.3.7 and still have the same issue:

Fatal error: Call to a member function setQuery() on a non-object in /home/brisebo/public_html/halonacoaching.com/joomlatest/administrator/components/com_hikashop/views/discount/view.html.php on line 187 when trying to open/modify a coupon

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

  • Posts: 81361
  • Thank you received: 13035
  • MODERATOR
13 years 4 months ago #2272

Please edit that file and add just after the code

function form(){
the code
$database =& JFactory::getDBO();
near line 165.

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

Time to create page: 0.089 seconds
Powered by Kunena Forum