Forums / Managing Customers and Orders / Order Comments Status/Update Boilerplate

Order Comments Status/Update Boilerplate

Views: 71,333

Results 61 to 80 of 83
18 May 2021, 1:03 PM
#61
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Order Comments Status/Update Boilerplate

simon1066:

Thank you for updating this mod @swguy.

Fresh install of this mod on an existing ZC v1.57c store. HTML tags don't seem to be carried over to the comments field on the order details page.

I can for instance wrap some boilerplate comment text in <b></b>, this shows as bold in the order_comment_boilerplate page. Not so if I add the Predefined Comments to the order details page.

(I can successfully add HTML tagged text to the order details comments field, manually)

Edit: I am not using CKEditor

This seems to be caused by the introduction of this new code in Admin/orders.php

$(document).ready(function() {
      $('#predefined_comments').change(function(){
        val = $(":selected", this).index();
        <?php if ($editor_handler !== '') { ?>
        $('textarea[name="comments"]').val(commentsArray[val].comment); 
        <?php } else { ?>
        var html_comment = $.parseHTML(commentsArray[val].comment);
        var text = $(html_comment).text(); 
        $('textarea[name="comments"]').html(text); 
        <?php } ?>
      });
    });
    </script>
<?php /* EOF Zen4All Order Comment 2 of 3 */ ?>

as opposed to the previous code, which worked, of

$(document).ready(function() {
      $('#predefined_comments').change(function(){
        val = $(":selected", this).index();											  
        $('textarea[name="comments"]').val(commentsArray[val].comment);	
      });
    });
    </script>
<?php /* EOF Zen4All Order Comment 2 of 3 */ ?>

Simon

18 May 2021, 1:24 PM
#62
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Order Comments Status/Update Boilerplate

swguy:

Simon: if you want to use HTML in your predefined comments, use CKEditor on the order details page. (You may need to make the change below.)

@n8pbm: Please replace the ready() function in orders.php (around line 481) with the following:

$(document).ready(function() {
  $('#predefined_comments').change(function(){
    val = $(":selected", this).index();
    <?php if ($editor_handler !== '') { ?>
    CKEDITOR.instances['comments'].setData(commentsArray[val].comment); 
    <?php } else { ?>
    var html_comment = $.parseHTML(commentsArray[val].comment);
    var text = $(html_comment).text(); 
    $('#comments').val(text); 
    <?php } ?>
  });
});

Thank you, styling the comments with CKEDITOR has worked - once I enabled it. I've never liked using the editor, I might have to configure the way it wraps everything in <p> tags and how it handles new lines/carriage returns.

Simon

18 May 2021, 1:29 PM
#63
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,729
Plugin Contributions:
56

Re: Order Comments Status/Update Boilerplate

If you really want to type HTML into the non-CKEditor textarea block, you can do that if you tweak the else branch of the ready() function. Right now, it strips out any HTML. This was a guess as to correct behavior on my part - please feel free to customize to your own taste.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

18 May 2021, 1:32 PM
#64
n8pbm avatar

n8pbm

Zen Follower

Join Date:
Mar 2005
Posts:
146
Plugin Contributions:
0

Re: Order Comments Status/Update Boilerplate

I did not type anything in the comments section before selecting from the dropdown. I just opened the order and then select from the dropdown and nothing happens.

I will give the code you provided as soon as I can.

Thank you

18 May 2021, 2:38 PM
#65
n8pbm avatar

n8pbm

Zen Follower

Join Date:
Mar 2005
Posts:
146
Plugin Contributions:
0

Re: Order Comments Status/Update Boilerplate

I updated the file with the new code and everything appears to be working.

Thank you for taking the time to work on this. I really appreciate it.

18 May 2021, 2:47 PM
#66
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,729
Plugin Contributions:
56

Re: Order Comments Status/Update Boilerplate

I'm going to update the mod to use this new code for CKEditor but the old code for plain text - I think this is the best compromise. I have my updated code for plain text in there and commented out in case someone prefers that behavior.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

25 May 2021, 4:37 PM
#67
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Order Comments Status/Update Boilerplate

As designed, adding a second boilerplate entry to the order comments box replaces the first. I have occasion to add more than one boilerplate comment at a time. With a bit of help from Stackoverflow I made a stab at it:

Note: this only works if, like me, you don't use ckeditor and are adding HTML code manually to the boilerplate comments.

The new line is in red and replaces the line above it,

admin/orders.php

$(document).ready(function() {
      $('#predefined_comments').change(function(){
        val = $(":selected", this).index();
        <?php if ($editor_handler !== '') { ?>
        CKEDITOR.instances['comments'].setData(commentsArray[val].comment); 
        <?php } else { ?>
           /*  Use this instead if you want to strip out HTML
        var html_comment = $.parseHTML(commentsArray[val].comment);
        var text = $(html_comment).text(); 
        $('#comments').val(text); 
            */
       // $('textarea[name="comments"]').val(commentsArray[val].comment);
	  $('textarea[name="comments"]').val($('textarea[name="comments"]').val() +(commentsArray[val].comment) + "\n");
        <?php } ?>
      });
    });

Simon

31 Mar 2024, 5:31 PM
#68
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Order Comments Status/Update Boilerplate

ZC v 2.0.0 rc2
PHP 8.1

Not specific to ZC 2.0.0 but, the coupon_admin page displays 'no coupons' when coupons are empty
Attachment 20548

I would like to do the same for this plugin, while I'm beautifying it (and getting it ready for ZC 2.0.0).

I have achieved this, but want to remove the grey portion below the black 'no comments' block.
Attachment 20549

I added the 'no comments' with this code in red

default:
              if (isset($ocInfo) && is_object($ocInfo)) {
                $heading[] = array('text' => '<h4>[' . $ocInfo->comment_id . ']  ' . $ocInfo->comment_title . '</h4>');

                $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_ORDER_COMMENT_BOILERPLATE, (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . '&ocid=' . $ocInfo->comment_id . '&action=new') . '" class="btn btn-primary">' . IMAGE_EDIT . '</a> <a href="' . zen_href_link(FILENAME_ORDER_COMMENT_BOILERPLATE, 'ocid=' . $ocInfo->comment_id . (isset($_GET['page']) ? '&page=' . (int)$_GET['page'] : '') . '&action=del') . '" class="btn btn-warning" role="button">' . IMAGE_DELETE . '</a>');
                $commentContent = $db->Execute("SELECT comment_content
                                                FROM " . TABLE_ORDER_COMMENTS_CONTENT . "
                                                WHERE comment_id = " . (int)$ocInfo->comment_id . "
                                                AND language_id = " . (int)$_SESSION['languages_id']);

                $contents[] = array('text' => COMMENT_CONTENT . ':  ' . $commentContent->fields['comment_content']);
                $contents[] = array('text' => DATE_CREATED . ':  ' . zen_date_short($ocInfo->date_added));
                $contents[] = array('text' => DATE_MODIFIED . ':  ' . zen_date_short($ocInfo->last_modified));
              }[B] else {				
                $heading[] = array('text' => '<h4>' . ERROR_NO_COMMENTS . '</h4>');
                $contents[] = [];
              }[/B]
              break;

It is obviously this line that is causing the greyed area

[B]$contents[] = [];[/B]

but if I remove it then the entire 'no comments' box disappears so it seems that the $heading has to be paired with a $contents. As you can see, this is a bit above my head so any pointers are welcome.

Simon

31 Mar 2024, 6:08 PM
#69
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,729
Plugin Contributions:
56

Re: Order Comments Status/Update Boilerplate

I will update this for PHP8 soon.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

2 Apr 2024, 8:36 AM
#70
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Order Comments Status/Update Boilerplate

swguy:

I will update this for PHP8 soon.

I'm happy to work through this, unless you have a burning desire to do so. Both you and @lat9 (possibly others) have added a decent amount of info to the Docs regarding upgrading plugins to work with newer PHP versions - that should help.

Simon

4 Apr 2024, 12:06 PM
#71
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Order Comments Status/Update Boilerplate

simon1066:

ZC v 2.0.0 rc2
PHP 8.1

Not specific to ZC 2.0.0 but, the coupon_admin page displays 'no coupons' when coupons are empty
Attachment 20548

I would like to do the same for this plugin, while I'm beautifying it (and getting it ready for ZC 2.0.0).

I have achieved this, but want to remove the grey portion below the black 'no comments' block....

I have resolved the above issue.

When inserting a comment there exists some custom text adjacent to the input boxes,
Attachment 20553

I aim to have different text depending on whether the content input box is Plain Text or CKEditor entry. I can write some code except that I'm unsure how to identify the type of input box in use.

e.g.
if input box is Plain Text then
display this text
else (if it is CKeditor)
display that text

Simon

4 Apr 2024, 2:22 PM
#72
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,973
Plugin Contributions:
8

Re: Order Comments Status/Update Boilerplate

simon1066:

..
e.g.
if input box is Plain Text then
display this text
else (if it is CKeditor)
display that text

look at this session var:

$_SESSION['html_editor_preference_status']

that should tell you which editor (or none) is in use.

you can look over here to see how it gets set:

https://github.com/zencart/zencart/blob/master/admin/includes/init_includes/init_html_editor.php

best.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

29 May 2024, 8:10 PM
#74
apollowilcox avatar

apollowilcox

Zen Follower

Join Date:
Sep 2014
Location:
Indiana
Posts:
123
Plugin Contributions:
0

Re: Order Comments Status/Update Boilerplate

[Deleted comment]

6 Sep 2024, 6:24 PM
#75
apollowilcox avatar

apollowilcox

Zen Follower

Join Date:
Sep 2014
Location:
Indiana
Posts:
123
Plugin Contributions:
0

Re: Order Comments Status/Update Boilerplate

Just updated the CKEditor and now this Boilerplate comments will not copy into the comments box. The editor seems to work fine, and i've re-installed the OC Boilerplate plug-in just cause. No change. Feels like something simple but I can't find it. No error logfile being created.

Can someone send me a hint? Thanks,

7 Sep 2024, 7:36 AM
#76
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Order Comments Status/Update Boilerplate

apollowilcox:

Just updated the CKEditor and now this Boilerplate comments will not copy into the comments box. The editor seems to work fine, and i've re-installed the OC Boilerplate plug-in just cause. No change. Feels like something simple but I can't find it. No error logfile being created.

Can someone send me a hint? Thanks,

I've tested this by upgrading to ckeditor5 on ZC v1.5.8a. The appropriate lines of code on my install of this plugin is as folllows, with the line that gives an error in browser dev console highlighted in red.

    $(document).ready(function() {
      $('#predefined_comments').change(function(){
        val = $(":selected", this).index();
        <?php if ($editor_handler !== '') { ?>
        [B]CKEDITOR.instances['comments'].insertHtml((commentsArray[val].comment) + '<br>'); [/B]
        <?php } else { ?>
        /* Using Plain Text Editor */
        $('textarea[name="comments"]').val($('textarea[name="comments"]').val() +(commentsArray[val].comment) + '\n');
        /*  Use this instead of above line if you want to strip out HTML 
        var html_comment = $.parseHTML(commentsArray[val].comment);
        var text = $(html_comment).text(); 
        $('#comments').val($('#comments').val() +(text) + '\n'); 
        */
        <?php } ?>
      });
    });

I haven't much time at the moment to debug this or compare it with the latest plugin code - so your code might be different.

Simon

7 Sep 2024, 7:53 AM
#77
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Order Comments Status/Update Boilerplate

simon1066:

I've tested this by upgrading to ckeditor5 on ZC v1.5.8a. The appropriate lines of code on my install of this plugin is as folllows, with the line that gives an error in browser dev console highlighted in red.

$(document).ready(function() {
  $('#predefined_comments').change(function(){
    val = $(":selected", this).index();
    <?php if ($editor_handler !== '') { ?>
    [B]CKEDITOR.instances['comments'].insertHtml((commentsArray[val].comment) + '<br>'); [/B]
    <?php } else { ?>
    /* Using Plain Text Editor */
    $('textarea[name="comments"]').val($('textarea[name="comments"]').val() +(commentsArray[val].comment) + '\n');
    /*  Use this instead of above line if you want to strip out HTML 
    var html_comment = $.parseHTML(commentsArray[val].comment);
    var text = $(html_comment).text(); 
    $('#comments').val($('#comments').val() +(text) + '\n'); 
    */
    <?php } ?>
  });
});
> 
> I haven't much time at the moment to debug this or compare it with the latest plugin code - so your code might be different.

Edit: relevant file is admin/orders.php

Simon

7 Sep 2024, 9:46 AM
#78
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,729
Plugin Contributions:
56

Re: Order Comments Status/Update Boilerplate

Referencing CKEditor no longer works in CKEditor 5.
Here are some details on how to fix this:

https://stackoverflow.com/questions/46816098/how-to-get-data-from-ckeditor-5-instance

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

9 Sep 2024, 2:23 PM
#79
apollowilcox avatar

apollowilcox

Zen Follower

Join Date:
Sep 2014
Location:
Indiana
Posts:
123
Plugin Contributions:
0

Re: Order Comments Status/Update Boilerplate

Lol... Thanks, but well over my head. :shocking:

My code does look like what Simon offered. Guess I'll wait for the update to the order-comments-boilerplate plug-in.

27 Sep 2024, 1:15 PM
#80
apollowilcox avatar

apollowilcox

Zen Follower

Join Date:
Sep 2014
Location:
Indiana
Posts:
123
Plugin Contributions:
0

Re: Order Comments Status/Update Boilerplate

Using the developer tools in the browser, I get this comment when attempting to insert a comment from the Order-comments-boilerplate at the customer order screen:

*index.php?cmd=orders&oID=335750&action=edit:753

Uncaught ReferenceError: CKEDITOR is not defined
at HTMLSelectElement.<anonymous> (index.php?cmd=orders&oID=335750&action=edit:753:3)
at HTMLSelectElement.dispatch (jquery-3.6.1.min.js:2:43064)
at y.handle (jquery-3.6.1.min.js:2:41048)*

Does that lead anyone to any specific suggestions?

Thank you!

ZC 1.5.8a; PHP 8.2.23