devst3r
devst3r

Reputation: 562

Opencart - Undefined variable in new shipping module

I'm making a new shipping module for opencart. Which simply takes the name and cost from the admin. But, shows an error inside the textbox. Undefined Variable

I'm stuck in here, Really want solution. My view (.tpl) file is given below.

  <div class="box">
    <div class="heading">
      <h1><img src="view/image/shipping.png" alt="" /> <?php echo $heading_title; ?></h1>
      <div class="buttons"><a onclick="$('#form').submit();" class="button"><?php echo $button_save; ?></a><a href="<?php echo $cancel; ?>" class="button"><?php echo $button_cancel; ?></a></div>
    </div>


    <div class="content">
      <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
        <table class="form">

          <tr>
            <td><?php echo $entry_name; ?></td>
            <td><input type="text" name="ndz_name" value="<?php echo $ndz_name; ?>" /></td>
          </tr>
          <tr>
            <td><?php echo $entry_amount; ?></td>
            <td><input type="text" name="ndz_amount" value="<?php echo $ndz_amount; ?>" /></td>
          </tr>
          <tr>
            <td><?php echo $entry_status; ?></td>
            <td><select name="ndz_status">
                <?php if ($ndz_status) { ?>
                <option value="1" selected="selected"><?php echo $text_enabled; ?></option>
                <option value="0"><?php echo $text_disabled; ?></option>
                <?php } else { ?>
                <option value="1"><?php echo $text_enabled; ?></option>
                <option value="0" selected="selected"><?php echo $text_disabled; ?></option>
                <?php } ?>
              </select></td>
          </tr>
          <tr>
            <td><?php echo $entry_sort_order; ?></td>
            <td><input type="text" name="ndz_sort_order" value="<?php echo $ndz_sort_order; ?>" size="1" /></td>
          </tr>
        </table>
      </form>
    </div>
  </div>

Opencart version : 1.5

Upvotes: 0

Views: 432

Answers (1)

vaso123
vaso123

Reputation: 12391

Because you need to initialize your $ndz_name and $ndz_amount before you echos it.

$ndz_name = '';
$ndz_amount = '';
if (!empty($_POST["ndz_name"])) {
    $ndz_name = $_POST["ndz_name"];
}
if (!empty($_POST["ndz_amount"])) {
    $ndz_amount = $_POST["ndz_amount"];
}

Upvotes: 1

Related Questions