Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Brusella opened this issue Oct 13, 2020 · 3 comments

Comments

@Brusella
Copy link

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
Copy link
Author

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/order_config.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
Copy link

clement8888 commented Oct 23, 2020

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 = 'line_item_' + ( $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
Copy link
Author

Great. Thanks for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants