CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • CiviDiscount Module Extension
Pages: 1 [2] 3 4 ... 8

Author Topic: CiviDiscount Module Extension  (Read 24793 times)

ChrisChinchilla

  • I post occasionally
  • **
  • Posts: 104
  • Karma: 3
  • CiviCRM version: 4.1.2
  • CMS version: Drupal 6 & 7
Re: CiviDiscount Module Extension
July 16, 2012, 10:49:43 pm
I didn't even see them!

Will try again :)
Melbourne CiviCRM meetup group - http://www.meetup.com/MelbourneCiviCRM/

joshathedone

  • I post occasionally
  • **
  • Posts: 50
  • Karma: 0
  • CiviCRM version: Civicrm4
  • CMS version: Drupal 7
  • MySQL version: 5.1.41
  • PHP version: 5
Re: CiviDiscount Module Extension
July 20, 2012, 01:28:32 pm
All right.

After upgrading the site to 4.2 beta, uninstalling the module, and reistalling it from the master branch I can confirm the following error still exists:

Code: [Select]
Fatal error: Cannot make static method CRM_Core_DAO::fields() non static in class CDM_DAO_Item in /home/eros/public_html/hedone.us/public/sites/all/civicrm_extensions/dlobo-org.civicrm.module.cividiscount-5f105ae/CDM/DAO/Item.php on line 367
I am sure the soloution to this is fairly simple, but I do not have enough knowledge of php to correct the issue.  Is there anyone who can help with this, or advise me how I could help debug the problem?

joshathedone

  • I post occasionally
  • **
  • Posts: 50
  • Karma: 0
  • CiviCRM version: Civicrm4
  • CMS version: Drupal 7
  • MySQL version: 5.1.41
  • PHP version: 5
Re: CiviDiscount Module Extension
July 20, 2012, 02:34:41 pm
All right.  I may have a soloution.  I don't know how to submit a patch.

I was able to get the master branch working by changing:

Code: [Select]
function &fields()to
Code: [Select]
static function &fields()
and

Code: [Select]
function getTableName()to
Code: [Select]
static function getTableName()
Waiting to see what (if any) adverse effects pop up.

joshathedone

  • I post occasionally
  • **
  • Posts: 50
  • Karma: 0
  • CiviCRM version: Civicrm4
  • CMS version: Drupal 7
  • MySQL version: 5.1.41
  • PHP version: 5
Re: CiviDiscount Module Extension
July 20, 2012, 06:41:34 pm
So while the above fix shows the discount setting screens without error and everything seems like it is working, any discounts fail silently

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: CiviDiscount Module Extension
July 20, 2012, 09:41:58 pm

can you debug the code and figure out whats happening and why?

thanx

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

joshathedone

  • I post occasionally
  • **
  • Posts: 50
  • Karma: 0
  • CiviCRM version: Civicrm4
  • CMS version: Drupal 7
  • MySQL version: 5.1.41
  • PHP version: 5
Re: CiviDiscount Module Extension
July 21, 2012, 09:46:10 pm
Trying.  What I have figurd out so far is that the above functions are declared static in Civi's core, so an error is being thrown unless they are declared static in the extension.

Changing the function throughout the extension stops giving errors and appears to allow things to work properly, however the discounts are never applied.  Upon clicking to edit a discount code the following error appears:

Code: [Select]
Fatal error: Class 'CDM_BAO_Item' not found in /home/eros/public_html/hedone.us/public/sites/all/modules/civicrm/CRM/Admin/Form.php(67) : eval()'d code on line 1
I am not sure if this is a symptom of a problem that is occurring because of the changes to static functions. or an unrelated issue.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: CiviDiscount Module Extension
July 21, 2012, 10:15:05 pm

try applying this patch to the code base:

Code: [Select]

Index: CRM/Admin/Form.php
===================================================================
--- CRM/Admin/Form.php  (revision 41658)
+++ CRM/Admin/Form.php  (working copy)
@@ -58,12 +58,16 @@
    *
    * @var string
    */
-  protected $_BAOName; function preProcess() {
+  protected $_BAOName;
+
+  function preProcess() {
     $this->_id      = $this->get('id');
     $this->_BAOName = $this->get('BAOName');
     $this->_values  = array();
     if (isset($this->_id)) {
       $params = array('id' => $this->_id);
+      // this is needed if the form is outside the CRM name space
+      require_once (str_replace('_', DIRECTORY_SEPARATOR, $this->_BAOName) . ".php");
       eval($this->_BAOName . '::retrieve( $params, $this->_values );');
     }
   }
@@ -80,6 +84,7 @@
     if (isset($this->_id) && empty($this->_values)) {
       $this->_values = array();
       $params = array('id' => $this->_id);
+      require_once (str_replace('_', DIRECTORY_SEPARATOR, $this->_BAOName) . ".php");
       eval($this->_BAOName . '::retrieve( $params, $this->_values );');
     }
     $defaults = $this->_values;

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

joshathedone

  • I post occasionally
  • **
  • Posts: 50
  • Karma: 0
  • CiviCRM version: Civicrm4
  • CMS version: Drupal 7
  • MySQL version: 5.1.41
  • PHP version: 5
Re: CiviDiscount Module Extension
July 22, 2012, 08:40:48 am
All right.  I can confirm the above patch fixes the edit problem.  However, the codes are still not applying.  Here is what I see happening:

When I change the function "&fields" to static in the extension's Item.php, everything seems to work until trying to apply a code when I get the following error:

Code: [Select]
Fatal error: Cannot make static method CRM_Core_DAO::fields() non static in class CDM_DAO_Track in /home/eros/public_html/hedone.us/public/sites/all/civicrm_extensions/dlobo-org.civicrm.module.cividiscount-5f105ae/CDM/DAO/Track.php on line 296
Changing the &fields function in Track.php to static silences the error but also (I'm assuming) breaks the extension as codes are not applied.

Changing the base function in CRM/Core/DAO.php starts throwing errors in core.

I am guessing that either the function somehow needs to be migrated from a static one in the extension or core needs to be patched.  Does that make sense?


Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: CiviDiscount Module Extension
July 22, 2012, 03:21:19 pm

Pretty sure it is not due to changing the &fields function to static. That is the right thing to do :)

You'll need to continue debugging and figure out why the discount hooks are not called when an event reg form is submitted.

Thanx for being persistent and pushing on this

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

joshathedone

  • I post occasionally
  • **
  • Posts: 50
  • Karma: 0
  • CiviCRM version: Civicrm4
  • CMS version: Drupal 7
  • MySQL version: 5.1.41
  • PHP version: 5
Re: CiviDiscount Module Extension
July 24, 2012, 03:28:30 pm
Here is what I can say after trying to get this extension to work for the past several days:

  • After making the changes described previously, I can access the extension's admin pages without errors.
  • In fact, though the module is not working, I am no longer getting any errors in my logs even with php error reporting set to maximum.
  • The admin functions of creating, editing, and deleting price sets work, as do install and uninstall.
  • The discount code field appears above the offline registration form.
  • The extension recognizes when an incorrect code is entered for a priceset.
  • When a correct code is entered for a priceset, the discount fails silently.  The discount is not applied, the usage count is not incremented, it does not show as applied either under the codes screen in the cividiscount section or the discount tab under the contact.
  • The code field does not show up in any step of the online (profile) registration process.

I will continue to do what I can, but I have a limited knowledge of php and am somewhat lost in what other steps to take in the absence of error messages.  If anyone has any suggestions I would be happy to hear them.  In addition, if there is anybody else with more development knowledge who could take a look at this extremely useful module it would be greatly appreciated.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: CiviDiscount Module Extension
July 24, 2012, 07:47:58 pm
i did a quick check on this and fixed the static issue.

However for 4.2, there is a bigger issue. The underlying data structure of the amounts field has changed to a price set which breaks the model that cividisount had.

But, you can still get it to work in a slightly twisted way :) Since all the amounts are now a priceset, for the discounts do:

1. Choose the event
2. Choose all the price set fields

lobo
« Last Edit: July 24, 2012, 08:02:52 pm by Donald Lobo »
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

joshathedone

  • I post occasionally
  • **
  • Posts: 50
  • Karma: 0
  • CiviCRM version: Civicrm4
  • CMS version: Drupal 7
  • MySQL version: 5.1.41
  • PHP version: 5
Re: CiviDiscount Module Extension
July 26, 2012, 10:31:50 am
Selecting all pricesets makes discounts work!!!  I also tried just selecting "contribution" and the current priceset with no success.

Offline tracking does not work which is a known error, but online tracking is also not working.  I think tracking would make this a functional (albeit still buggy) module.  Online tracking was supposedly working in 4.1, but I reverted to 4.1.5 and fixed the static issue, and tracking didn't work for me there either.  Has anyone else had problems with tracking in either 4.1 or 4.2?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: CiviDiscount Module Extension
July 26, 2012, 11:20:26 am

are there any entries in your cividiscount_track table? When i did a simple test there was an entry.

Can u elaborate (and also investigate) on what you mean by tracking is not working

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

joshathedone

  • I post occasionally
  • **
  • Posts: 50
  • Karma: 0
  • CiviCRM version: Civicrm4
  • CMS version: Drupal 7
  • MySQL version: 5.1.41
  • PHP version: 5
Re: CiviDiscount Module Extension
July 26, 2012, 12:49:00 pm
I meant all tracking including theincrement counters  cividiscount_track table.  I uninstalled and reinstalled the extension which fixed the problem, I must have broken something working on the static issue. 

A couple of other things I have noticed while testing:

  • When doing an online event registration I see two text boxes for the code:  one at the top of the page and one at the bottom.  Only the bottom one works.
  • Though the event ID shows up in the cividiscount_track table the event name does not show up either in the cividiscount/report?id=1&reset=1 page or the redeemed codes tab
  • Is there supposed to be a spot to choose the applicable events when creating a code?  You mentioned something about choosing the event in one of your previous posts and I see the entry in the cividiscount_item table, but do not see the option when creating or editing a code.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: CiviDiscount Module Extension
July 26, 2012, 01:53:02 pm

I dont know the code well enough to see if the code matches events and pricesets. I suspect it might not and hence it does not show up in the reports

If you investigate the code and figure / patch things, please update this topic so we could potentially patch the extension

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: 1 [2] 3 4 ... 8
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • CiviDiscount Module Extension

This forum was archived on 2017-11-26.