VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: aka.deton on April 13, 2018, 10:40:27 AM

Title: VirtueMart 3.2.14: "class 'CouponHelper' not found"
Post by: aka.deton on April 13, 2018, 10:40:27 AM
Joomla! 3.8.6
VirtueMart 3.2.14


[message] => Class 'CouponHelper' not found
[file] => components/com_virtuemart/helpers/cart.php
[line] => 1300

Do not forget to add:

if (!class_exists('CouponHelper')) {
require(VMPATH_SITE . DS . 'helpers' . DS . 'coupon.php');
}

in function emptyCartValues?
Title: Re: VirtueMart 3.2.14: "class 'CouponHelper' not found"
Post by: Milbo on April 13, 2018, 15:47:08 PM
Hmmm, I wonder why it is not already loaded in your case, whatever. I added it.
Title: Re: VirtueMart 3.2.14: "class 'CouponHelper' not found"
Post by: Gingerweb on August 06, 2018, 17:51:16 PM
I have this error on a new store when using the coupon in the cart.
the above code is present in the file but like this

}

if (!class_exists('CouponHelper')) {
require(VMPATH_SITE . DS . 'helpers' . DS . 'coupon.php');
}

$this->prepareCartData();


How can i stop this from happening please?
Title: Re: VirtueMart 3.2.14: "class 'CouponHelper' not found"
Post by: hazael on August 22, 2018, 20:21:34 PM
I have same problem
Title: Re: VirtueMart 3.2.14: "class 'CouponHelper' not found"
Post by: Jörgen on August 23, 2018, 00:13:24 AM
No VM version, no Joomla version etc

Jörgen @ Kreativ Fotografi
Title: Re: VirtueMart 3.2.14: "class 'CouponHelper' not found"
Post by: dslove on October 23, 2018, 12:04:33 PM
Hi!

I'm having the same issue here, using Joomla 3.8.10, VM 3.2.14 and PHP 7.1.
Code in mentioned file/line looks as in the attachment

Should I apply the fix described above?

Thanks,
Alex
Title: Re: VirtueMart 3.2.14: "class 'CouponHelper' not found"
Post by: GJC Web Design on October 23, 2018, 12:56:29 PM
yes-- try

      if (!class_exists('CouponHelper')) {
         require(VMPATH_SITE. '/helpers/coupon.php');
      }

if your error is  Class 'CouponHelper' not found

Title: Re: VirtueMart 3.2.14: "class 'CouponHelper' not found"
Post by: dslove on October 23, 2018, 13:23:06 PM
Exact error message is "0 - Class 'CouponHelper' not found",
code now (after fix) looks as attachment below,
problem has not been solved though.

Any ideas?
Title: Re: VirtueMart 3.2.14: "class 'CouponHelper' not found"
Post by: dslove on October 23, 2018, 13:25:21 PM
Oh, important note: This only happens when I use credit card payment. When I tried coupon checkout with Bank Deposit, no error appeared.
Title: Re: VirtueMart 3.2.14: "class 'CouponHelper' not found"
Post by: Jörgen on October 23, 2018, 13:28:47 PM
If I am not mistaken You have to load the helper before You use the helper. It does not do any good to load it on the next line.

Jörgen @ Kreativ Fotografi
Title: Re: VirtueMart 3.2.14: "class 'CouponHelper' not found"
Post by: GJC Web Design on October 23, 2018, 15:09:36 PM
had the wrong glasses on!

yes J,  it should be at the start

something like

static public function emptyCartValues(&$cart, $session = true){

//if we used a coupon, we must set it in final use now
$couponCode = '';
if(!empty($cart->couponCode)){
$couponCode = $cart->couponCode;
} else if(!empty($cart->cartData['couponCode'])){
$couponCode = $cart->cartData['couponCode'];
}
if(!empty($cart->couponCode)){
  if (!class_exists('CouponHelper')) {
require(VMPATH_SITE. '/helpers/coupon.php');
  }
CouponHelper::setInUseCoupon($couponCode, true, 1);
}


as Max says -- why doesn't everyone have this problem?
Title: Re: VirtueMart 3.2.14: "class 'CouponHelper' not found"
Post by: dslove on October 24, 2018, 10:45:01 AM
Thank you all, code was rearranged as per GJC's suggestion and issue was resolved.

I have two more VM installations that are identical in setup, they even use the same front end framework and scripts. I can run some tests there too, and let you know if I have the same problem and if any minor differences exist between the websites. Just give me a couple of days, and I'll get back at you on this issue.

Have a great day :)
Title: Re: VirtueMart 3.2.14: "class 'CouponHelper' not found"
Post by: dslove on October 26, 2018, 10:28:31 AM
Hi all, the problem existed on one of my other vm sites too.

Same Joomla version (3.8.10), same Virtuemart version (3.2.14), same PHP version (7.1), same MySQL version (5.7), hosted on the same server.

As expected, the issue was resolved using the same fix.

The two websites were developed independently (website #2 was built ~10 months before website #1) but are being maintained in the same manner.
Title: Re: VirtueMart 3.2.14: "class 'CouponHelper' not found"
Post by: GJC Web Design on October 26, 2018, 12:10:51 PM
Thanks for the info