mecachisenros / cf-civicrm

Caldera Forms CiviCRM Integration
GNU Affero General Public License v3.0
30 stars 26 forks source link

Unable to add new line items to CiviCRM Order processor - javascript errors #183

Open Brusella opened 3 years ago

Brusella commented 3 years ago

Hi,

I'm unable to add additional line items to the CiviCRM Order processor. In the form, I have one membership processors with two line item processors setup. However, I can only input the first line item in the Order processor. Receiving javascript errors via console- see gif screenshot.

Any advice to get this functioning would be appreciated.

CFCIVIBUG

Windows 10 Google Chrome Wordpress 5.4.2 Caldera 1.9.2 Caldera Forms CiviCRM 1.0.5

Brusella commented 3 years ago

So I see this is related to an issue resolved in #146 However, I'm having trouble working out where to apply the jquery fix in the relevant php file;

@am2605 -"So a fix seems to be to edit processors/order/orderconfig.php and add var $j = jQuery.noConflict(); at about line 293, and then use references to $j instead of $"

Can anyone help? jquery and php is new to me. Thanks in advance

clement8888 commented 3 years ago

Thanks for flagging this bug, i was able to successful patch this to resolve the bug. the steps to do so are as follows:

  1. change directory to this folder /var/www/html/wp-content/plugins/cf-civicrm-master/processors/order

  2. edit the order_config.php file, i use nano nano order_config.php

  3. go to row 293 and add the $j = jQuery.noConflict(); line and replace $ to $j, so the code section will end up like the following, only 3 edits were required, one for the new line for JQuery and 2 $ to be changed to $j:

    function cfc_add_line_item( obj ) { $j = jQuery.noConflict(); var id = obj.trigger.data( 'id' ), config = JSON.parse( $j('#' + id + ' .processor_config_string' ).val() ), item_id = 'lineitem' + ( $j( '#' + id + ' .line-item' ).length + 1 ), _name = 'config[processors][' + id + '][config]';

            if ( config.line_items ) {
                    config.line_items[item_id] = '';
            } else {
                    config['line_items'] = {}
                    config.line_items['line_item_1'] = '';
            }
    
            var processor = { id: id, config: config };
    
            var line_item = { item_id: item_id, _name: _name };
            return line_item;
    }
  4. Then go back to the Order Processor to add the New Line!

Brusella commented 3 years ago

Great. Thanks for this