Remove Comments

Open to all! Ask other shopowners for help.
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Remove Comments

Post by heatherbell »

We do not require "Comments" section on checkout_shipping and checkout_payment.
In files (in override template), using 1.0.8.21 PHP8, we have removed Lines 118-127 from checkout_shipping

Code: Select all

  $comments_textarea = new Textarea('comments', [
    'cols' => '60',
    'rows' => '5',
    'id' => 'inputComments',
    'placeholder' => ENTRY_COMMENTS_PLACEHOLDER,
  ]);

  if (isset($_SESSION['comments'])) {
    $comments_textarea->set_text($_SESSION['comments']);
  }
and removed Lines 118-121 from checkout_payment

Code: Select all

  <div class="form-group row">
    <label for="inputComments" class="col-form-label col-sm-4 text-sm-right"><?= ENTRY_COMMENTS ?></label>
    <div class="col-sm-8"><?= $comments_textarea ?></div>
  </div>
This works but gives:

PHP Warning: Undefined array key "comments" in //includes/system/versioned/1.0.7.4/shipping.php on line 145
Stack trace:
1. {main}() //checkout_shipping.php:0
2. shipping->process_selection() //checkout_shipping.php:28

We can live with the warning but is there a better way to achieve this without the warning?


Join The Code Co-op to get access to your library in the Code Co-op Forum
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Remove Comments

Post by ecartz »

Add a hidden form input with an empty value named 'comments' to replace the textarea.
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Re: Remove Comments

Post by heatherbell »

If understood correctly.
Changed

Code: Select all

  $comments_textarea = new Textarea('comments', [
    'cols' => '60',
    'rows' => '5',
    'id' => 'inputComments',
    'placeholder' => ENTRY_COMMENTS_PLACEHOLDER,
  ]);
to

Code: Select all

  $comments_input = '<input type="hidden" name="comments" id="inputComments" value="">';
but warning remains so guess haven't understood correctly
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Has thanked: 70 times
Been thanked: 152 times

Re: Remove Comments

Post by raiwa »

I didn't have a look into the page, but $comments_textarea should be echoed somewhere and $comments_input will not be echoed without an additional change.
Maybe:

Code: Select all

  $comments_textarea = '<input type="hidden" name="comments" id="inputComments" value="">';
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
Omar_one
Senior Contributor
Posts: 679
Joined: Fri Oct 25, 2019 5:06 pm
Phoenix Version: v1.0.8.16
Has thanked: 100 times
Been thanked: 56 times

Re: Remove Comments

Post by Omar_one »

@raiwa if I remember right you created an module called Modular Checkout or something like that for CE ,but I don't think it will not work on Phoenix with updating the module.

@heatherbell I managed to hide the inputComments not the whole "Comments" section by adding this to css :lol: :) maybe a start :idea:

Code: Select all

#inputComments{
visibility: hidden;
}
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Has thanked: 70 times
Been thanked: 152 times

Re: Remove Comments

Post by raiwa »

Omar_one wrote: Thu Feb 08, 2024 6:32 pm @raiwa if I remember right you created an module called Modular Checkout or something like that for CE ,but I don't think it will not work on Phoenix with updating the module.
Modular checkout is discontinued. It is not useful/necessary for Phoenix because it has other possibilities via hooks or overriding page templates.
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
User avatar
burt
Core Team
Posts: 4552
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Remove Comments

Post by burt »

Add hidden;

Code: Select all

  $comments_textarea = new Textarea('comments', [
    'cols' => '60',
    'rows' => '5',
    'id' => 'inputComments',
    'placeholder' => ENTRY_COMMENTS_PLACEHOLDER,
    'hidden' => 'hidden',
  ]);

  if (isset($_SESSION['comments'])) {
    $comments_textarea->set_text($_SESSION['comments']);
  }
And change this:

Code: Select all

  <div class="form-group row">
    <label for="inputComments" class="col-form-label col-sm-4 text-sm-right"><?= ENTRY_COMMENTS ?></label>
    <div class="col-sm-8"><?= $comments_textarea ?></div>
  </div>
to:

Code: Select all

  <?= $comments_textarea ?>
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Remove Comments

Post by ecartz »

Delete the first block entirely. For the second block:

Code: Select all

  <div class="form-group row">
    <label for="inputComments" class="col-form-label col-sm-4 text-sm-right"><?= ENTRY_COMMENTS ?></label>
    <div class="col-sm-8"><?= $comments_textarea ?></div>
  </div>
replace with

Code: Select all

<input type="hidden" name="comments" value="">
Or use the class, something like

Code: Select all

<?= new Input('comments', ['value' => ''], 'hidden') ?>
You don't need the textarea, the variable, nor the id.

In the longer term, we could look at moving the comment processing into a code segment run by hook so that you could disable it.
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Re: Remove Comments

Post by heatherbell »

burt wrote: Thu Feb 08, 2024 7:19 pm Add hidden;
And change this:
This changed the warning to:
PHP Warning: Undefined variable $comments_textarea in //templates/override/includes/pages/checkout_payment.php on line 105
Stack trace:
1. {main}() //checkout_payment.php:0
2. require() //checkout_payment.php:25
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Re: Remove Comments

Post by heatherbell »

ecartz wrote: Fri Feb 09, 2024 3:29 am Delete the first block entirely. For the second block: replace with the class, something like

Code: Select all

<?= new Input('comments', ['value' => ''], 'hidden') ?>
The warning stays the same.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply