Author Topic: VirtueMart 3.2.14: "class 'CouponHelper' not found"  (Read 824 times)

aka.deton

  • Beginner
  • *
  • Posts: 9
VirtueMart 3.2.14: "class 'CouponHelper' not found"
« on: April 13, 2018, 10:40:27 am »
Joomla! 3.8.6
VirtueMart 3.2.14

Code: [Select]
[message] => Class 'CouponHelper' not found
[file] => components/com_virtuemart/helpers/cart.php
[line] => 1300
Do not forget to add:
Code: [Select]
if (!class_exists('CouponHelper')) {
require(VMPATH_SITE . DS . 'helpers' . DS . 'coupon.php');
}
in function emptyCartValues?

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9720
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: VirtueMart 3.2.14: "class 'CouponHelper' not found"
« Reply #1 on: April 13, 2018, 15:47:08 pm »
Hmmm, I wonder why it is not already loaded in your case, whatever. I added it.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Gingerweb

  • Beginner
  • *
  • Posts: 33
  • A beginner
Re: VirtueMart 3.2.14: "class 'CouponHelper' not found"
« Reply #2 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

Code: [Select]
}

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

$this->prepareCartData();

How can i stop this from happening please?

hazael

  • Beginner
  • *
  • Posts: 33
    • Biżuteria etniczna i orientalna
  • VirtueMart Version: 3.2.14
Re: VirtueMart 3.2.14: "class 'CouponHelper' not found"
« Reply #3 on: August 22, 2018, 20:21:34 pm »
I have same problem

Jörgen

  • Global Moderator
  • Full Member
  • *
  • Posts: 1750
    • Kreativ Fotografi
  • VirtueMart Version: 3.2.12
Re: VirtueMart 3.2.14: "class 'CouponHelper' not found"
« Reply #4 on: August 23, 2018, 00:13:24 am »
No VM version, no Joomla version etc

Jörgen @ Kreativ Fotografi
Joomla 3.8.3
Virtuemart 3.2.12
Olympiantheme Hera (customized)

dslove

  • Jr. Member
  • **
  • Posts: 67
Re: VirtueMart 3.2.14: "class 'CouponHelper' not found"
« Reply #5 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

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 8413
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 2.6.22 & 3.2.14
Re: VirtueMart 3.2.14: "class 'CouponHelper' not found"
« Reply #6 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

GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

dslove

  • Jr. Member
  • **
  • Posts: 67
Re: VirtueMart 3.2.14: "class 'CouponHelper' not found"
« Reply #7 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?

dslove

  • Jr. Member
  • **
  • Posts: 67
Re: VirtueMart 3.2.14: "class 'CouponHelper' not found"
« Reply #8 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.

Jörgen

  • Global Moderator
  • Full Member
  • *
  • Posts: 1750
    • Kreativ Fotografi
  • VirtueMart Version: 3.2.12
Re: VirtueMart 3.2.14: "class 'CouponHelper' not found"
« Reply #9 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
Joomla 3.8.3
Virtuemart 3.2.12
Olympiantheme Hera (customized)

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 8413
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 2.6.22 & 3.2.14
Re: VirtueMart 3.2.14: "class 'CouponHelper' not found"
« Reply #10 on: October 23, 2018, 15:09:36 pm »
had the wrong glasses on!

yes J,  it should be at the start

something like

Code: [Select]
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?
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

dslove

  • Jr. Member
  • **
  • Posts: 67
Re: VirtueMart 3.2.14: "class 'CouponHelper' not found"
« Reply #11 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 :)

dslove

  • Jr. Member
  • **
  • Posts: 67
Re: VirtueMart 3.2.14: "class 'CouponHelper' not found"
« Reply #12 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.

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 8413
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 2.6.22 & 3.2.14
Re: VirtueMart 3.2.14: "class 'CouponHelper' not found"
« Reply #13 on: October 26, 2018, 12:10:51 pm »
Thanks for the info
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation