Undefined variable (opencart) - undefined

on the line where the error apparently is the code looks like this:
<?php if ($filter_name) { ?>
I know this is probably a vague questions but if anyone can help that would be great!

This is very Vague question. most probably you would be getting this error in header.tpl because you are using theme made for 1.5.4.x ( or earlier) with 1.5.5.x
in your catalog/view/theme/your_theme/template/common/header.tpl
Find
<?php if ($filter_name) { ?>
<input type="text" name="filter_name" value="<?php echo $filter_name; ?>" />
<?php } else { ?>
<input type="text" name="filter_name" value="<?php echo $text_search; ?>" onclick="this.value = '';" onkeydown="this.style.color = '#000000';" />
<?php } ?>
replace with
<input type="text" name="search" placeholder="<?php echo $text_search; ?>" value="<?php echo $search; ?>" />
If you would have searched before asking you would have found this http://forum.opencart.com/viewtopic.php?f=20&t=97790

go to path : catalog/view/theme/your_theme/template/common/header.tpl
open the file header.tpl
search <?php if($filter_name) { ?>
replace above by <?php if(isset($filter_name)) { ?>

yes , it is a version defect , its common when u use a 1.5.4 theme for 1.5.5 version , but u can solve it easily (if one or two errors) using the above stated method. only this file needs to be changed : catalog/view/theme/your-theme/template/common/header.tpl , and dont crack up the core files for safety .

https://github.com/justinmarsan/opencart-blank-theme/issues/7
This link really helped me,
Just replace
This:
<?php if ($filter_name) { ?>
With This:
<?php if (isset($filter_name)) { ?>

Related

Wordpress custom widget that allows html codes

I just need a widget with a textarea where I can paste an embed code. Right now, whenever I save the widget, it auto removes the html codes.
<label for="<?php echo $this->get_field_id( 'embed' ); ?>"><?php _e( 'Embed:' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'embed' ); ?>" name="<?php echo $this->get_field_name( 'embed' ); ?>" type="text" value="<?php echo esc_attr( $embed ); ?>" />
It should work like the default text-widget where it runs HTML. Any way I can put a certain code to retain and run the HTML in my custom widget?
Please use the default textwidget, it will serve your purposes.

How to Display a custom value like customer number in order Email

I am working on a solution for the task to display a customer number in the order confirmation email.
There is already a custom attribute customer_number which is displayed in the register form and the customers back-end.
It seems to get displayed by calling a helper.
This is how it is displayed in the register form:
<input type="number"
name="<?php echo Company_Helper_Data :: CUSTOMER_NUMBER_FIELD ?>"
id="<?php echo Company_Helper_Data :: CUSTOMER_NUMBER_FIELD . "id" ?>"
value="<?php echo $this->escapeHtml($this->getFormData()->getData( Company_Helper_Data :: CUSTOMER_NUMBER_FIELD ) ) ?>"
title="<?php echo $this->__('Customer Number') ?>" class="input-text" />
This is how it gets called in the customer back-end
<input type="text"
name="customer_number"
id="customer_number"
value="<?php echo $this->getCustomer()->getCustomerNumber() ?>"
title="<?php echo $this->__(' Customer Number') ?>"
class="input-text" />
So I simply tried to put this code into the order/default.phmtl:
<?php echo $this->getCustomer()->getCustomerNumber()?>
Which does not work. The Order cannot be set.
I am rookie to programming. Does anyone has an idea how to call the customer-data in the order email-template and display it in the order confirmation?
For this in Magento, you'll have to go in magento backend admin panel,
next go to
system=>Transactional Emails
Here you'll find your email template.
After this open the email template and then place this where you would like
{{ var customer_number }}

From dropdown to table in Magento

I am using Magento Community in order to develop a webshop. I am creating products with a dropdown custom option. I have been trying to change the display (HTML) of this information. Basically, I would like to display a table instead of the dropdown menu that appears currently, but I do not know how to do it. The file I have tried to edit is located in app/design/frontend/base/default/template/bundle/catalog/product/view/type/bundle/option. What I understood is that the information is inserted using the following code:
<?php endif; ?>
<input type="hidden" name="bundle_option[<?php echo $_option->getId() ?>]" value="<?php echo $_selections[0]->getSelectionId() ?>"/>
<?php else:?>
<select onchange="bundle.changeSelection(this)" id="bundle-option-<?php echo $_option->getId() ?>" name="bundle_option[<?php echo $_option->getId() ?>]" class="bundle-option-<?php echo $_option->getId() ?><?php if ($_option->getRequired()) echo ' required-entry' ?> bundle-option-select change-container-classname">
<option value=""><?php echo $this->__('Choose a selection...') ?></option>
<?php foreach ($_selections as $_selection): ?>
<?php if ($_selection->getSelectionCanChangeQty() && $this->_isSelected($_selection)): ?>
<?php $tierPriceHtml = $this->getTierPriceHtml($_selection); ?>
<?php endif; ?>
<option value="<?php echo $_selection->getSelectionId() ?>"<?php if ($this->_isSelected($_selection)) echo ' selected="selected"' ?><?php if (!$_selection->isSaleable()) echo ' disabled="disabled"' ?>><?php echo $this->getSelectionTitlePrice($_selection, false) ?></option>
<?php endforeach; ?>
</select>
What I tried to do is to get the information while building a table, so I added some lines at the end of the tag in order to see a table under the dropdown, with all the information, something as basic as the following lines:
<table class="probapifa">
<?php foreach ($_selections as $_selection1): ?>
<tr id="rowpifa" value="<?php echo $_selection1->getSelectionId() ?>"><?php echo $this->getSelectionTitlePrice($_selection1, false) ?></tr>
<?php endforeach; ?>
</table>
The result is unappreciated, as I can see nothing even if I select a new option from the dropdown. Also, I can see that in the code above, it says Choose a product for the initial selected option, when in the product site the text that appears is Please select. (I read it should be edited in the CSV file, right?). So my guess is that I am not editing the right file, what should I do? I really need your help.

Passing data from DB to update form using CI CRUD

I'm trying to write a compact update controller for CRUD activity. Here is the basic code:
Controller:
function update($id)
{
$this->form_validation->set_rules('name','Name','required');
$this->form_validation->set_rules('age','Age','required|is_numeric');
$this->form_validation->set_rules('country','Country','');
$this->form_validation->set_error_delimiters('<br /><span class="error">', '</span>');
if ($this->form_validation->run() == FALSE) {
//Failed validation or first run
$data = $this->my_model->get_record($id);
$this->load->view('myform_view', $data);
} else {
//Validation success, update DB
}
}
View:
<?php
$attributes = array('class' => '', 'id' => '');
echo form_open('my_form', $attributes); ?>
<p>
<label for="name">Name</label>
<?php echo form_error('name'); ?>
<br /><input id="name" type="text" name="name" value="<?php echo set_value('name'); ?>" />
</p>
<p>
<label for="age">Age</label>
<?php echo form_error('age'); ?>
<br /><input id="age" type="text" name="age" value="<?php echo set_value('age'); ?>" />
</p>
<p>
<label for="country">Country</label>
<?php echo form_error('country'); ?>
<br /><input id="country" type="text" name="country" value="<?php echo set_value('country'); ?>" />
</p>
<p>
<?php echo form_submit( 'submit', 'Submit'); ?>
</p>
<?php echo form_close(); ?>
This is the basic structure, however the first time the form is run there is no validated data. Therefore I have to grab this from the DB. Whats the best way to pass this to the view on the first run? And then once the form has been submitted, if validation fails then I want the failed data to show not to reload from the DB again. Whats the best way to do this?
You should have another method for the viewing aspect. Then submit your form against the "update" method. In there, you define the the form_validation as you have now.
I asked a similar question. See this link
grab the data in update controller first for edit such as
$query = $this->db->where('id',$id)->get('table_name');
$data['edit'] = $query->result_array();
and then check it in view file
value="<?php if(isset($edit[0]['age'])){echo $edit[0]['age'];}else{echo set_value('age');}?>"

form text-input unwanted redirection on click

Please help, I can't understand why the code below keeps bringing me to viewcart.php when I click on the textbox that is used to input qty to buy, I made sure to close all the anchor tags in the page. I even removed all the links to viewcart.php but no luck:
<form name="cx" method="get" action="viewcart.php?action=add&id=<?php $pid; ?>">
<?php
while($row=mysql_fetch_assoc($result)){
$pid=$row['PID'];
?>
<tr>
<td><?php echo $row['PID']; ?></td>
<td> <?php echo $row['PRODUCT']; ?></td>
<td><?php echo $row['CATEGORY']; ?></td>
<td><?php echo $row['P_DESC']; ?></td>
<td><?php echo $row['QTYHAND']; ?></td>
<td><?php echo $row['S_PRICE']; ?></td>
<input type="hidden" value="<?php echo $row['QTYHAND']; ?>" name="qoh[]"/>
<input type="hidden" value="<?php echo $row['S_PRICE']; ?>" name="sprice[]"/>
<?php echo "<td><img src=\"../img/system/add-icon.png\"></td>"; ?>
<td><input type="checkbox" name="sc[]" id="<?php echo $row['PID'];?>" value="<?php echo $row['PID']; ?>"></input></td>
<td><input type="text" name="qbuys[]" value="" id="qb"></input></td> <!--when I click on this, it seems like I'm clicking on a link to viewcart.php -->
</table>
<input type="submit" value="submit"></input>
</form>
I removed some of the code which I don't think is useful in solving this problem. Please help. Thanks.
Your code has two issues. YOu're not echoing the $pid and you have a scoping error.
<form name="cx" method="get" action="viewcart.php?action=add&id=<?php $pid; ?>">
You need to add an echo:
<form name="cx" method="get" action="viewcart.php?action=add&id=<?php echo $pid; ?>">
Also, $pid doesn't exists until you're inside the while loop so you'll always be echoing '':
// $pid == null;
<form name="cx" method="get" action="viewcart.php?action=add&id=<?php $pid; ?>">
<?php
while($row=mysql_fetch_assoc($result)){
$pid=$row['PID']; // NOW $pid has a value
?>
If you view the source of this page you should see:
<form name="cx" method="get" action="viewcart.php?action=add&id=">
Notice the empty id. This would keep sending you back to viewcart.php
You are not echoing your $pid into the form action.
This means that when you submit your form it is not going where you expect.
action="viewcart.php?action=add&id=<?php echo $pid; ?>"
or
action="viewcart.php?action=add&id=<?=$pid?>"
This second examle will only work if your server has short tags enabled.
Rather than looking at the PHP code that generates the page, i would suggest loading the page in your browser, and then clicking "view source". That way you can see exactly what code is being generated, then work back from there to identify which statement is going wrong.
However, I would suggest looking at the following line:
<td> <?php echo $row['PRODUCT']; ?></td>
There is no echo on the 'Product' property.