Page 1 of 2

Remove Comments

Posted: Thu Feb 08, 2024 7:18 am
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?

Re: Remove Comments

Posted: Thu Feb 08, 2024 10:09 am
by ecartz
Add a hidden form input with an empty value named 'comments' to replace the textarea.

Re: Remove Comments

Posted: Thu Feb 08, 2024 11:59 am
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

Re: Remove Comments

Posted: Thu Feb 08, 2024 5:34 pm
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="">';

Re: Remove Comments

Posted: Thu Feb 08, 2024 6:32 pm
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;
}

Re: Remove Comments

Posted: Thu Feb 08, 2024 6:57 pm
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.

Re: Remove Comments

Posted: Thu Feb 08, 2024 7:19 pm
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 ?>

Re: Remove Comments

Posted: Fri Feb 09, 2024 3:29 am
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.

Re: Remove Comments

Posted: Fri Feb 09, 2024 5:53 am
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

Re: Remove Comments

Posted: Fri Feb 09, 2024 5:56 am
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.