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?
Hmmm, I wonder why it is not already loaded in your case, whatever. I added it.
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?
I have same problem
No VM version, no Joomla version etc
Jörgen @ Kreativ Fotografi
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
yes-- try
if (!class_exists('CouponHelper')) {
require(VMPATH_SITE. '/helpers/coupon.php');
}
if your error is Class 'CouponHelper' not found
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?
Oh, important note: This only happens when I use credit card payment. When I tried coupon checkout with Bank Deposit, no error appeared.
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
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?
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 :)
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.
Thanks for the info