From dropdown to table in Magento - html

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.

Related

how to keep selected value in select box after submit or page reload were values and option are different which retrieved from db?

I want to keep selected particular value which was selected before the form submission. But after reloading or submisssion i did not get the previous selected value.help me!
<select name="select" class="dropbtn" onchange="this.form.submit()">
<?php
include 'connect.php';
$query="SELECT * FROM `user` WHERE id =1";
$result=mysqli_query($link_id,$query);
while($data = mysqli_fetch_assoc($result))
{ ?>
<option value="<?php echo $data['user_id']; ?>"> <?php echo
$data['address']; ?> </option>
<?php } ?>
</select>
<?php
$id = null;
if(isset($_POST['select']))
{
$id = $_POST['select'];
echo $id;
}
?>

HTML5 validation on quantity in woocommerce, change error message

I am creating my first online shop.
Problem: I want to show, error message for quantity validation.
Stock quantity is not showing in product detail page but it is showing in cart page. I have share both pages screenshot below.
Product Detail: http://prntscr.com/93ajnj
Cart: http://prntscr.com/93ajuk
I have use below code in woocommerce > single-product > add-to-cart > variable.php
<div class="quantity"><strong>Quantity </strong>
<input type="number" step="<?php echo esc_attr( $step ); ?>" <?php if ( is_numeric( $min_value ) ) : ?>min="<?php echo esc_attr( $min_value ); ?>"<?php endif; ?> <?php if ( is_numeric( $max_value ) ) : ?>max="<?php echo esc_attr( $max_value ); ?>"<?php endif; ?> name="<?php echo esc_attr( $input_name ); ?>" value="<?php echo esc_attr( $input_value ); ?>" class="input-text qty text" size="4" oninvalid="setCustomValidity('Sorry! we have only <?php echo esc_attr( $max_value ); ?> shirts in your selected size.')"
onchange="try{setCustomValidity('')}catch(e){}" />
</div>
Any help in this regards will be highly appreciated. Thanks in advance.
P.S. link of website.

Undefined variable (opencart)

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)) { ?>

Magento changing the language selector

In my project I have to display the webshop in two languages.
By default you can choose languages with the following code in:
app/design/frontend/base/default/template/page/switch/language.phtml
<?php if(count($this->getStores())>1): ?>
<div class="form-language">
<label for="select-language"><?php echo $this->__('Your Language:') ?></label>
<select id="select-language" title="<?php echo $this->__('Your Language') ?>" onchange="window.location.href=this.value">
<?php foreach ($this->getStores() as $_lang): ?>
<?php $_selected = ($_lang->getId() == $this->getCurrentStoreId()) ? ' selected="selected"' : '' ?>
<option value="<?php echo $_lang->getCurrentUrl() ?>"<?php echo $_selected ?>><?php echo $this->htmlEscape($_lang->getName()) ?></option>
<?php endforeach; ?>
</select>
</div>
<?php endif; ?>
This of course displaya a select box with the options being all the languages.
I however want to change this so that it become seperate links.
I just don't really know how to do this.
This is what I have now.
<?php if(count($this->getStores())>1): ?>
<div class="form-language">
<?php foreach ($this->getStores() as $_lang):?>
<?php echo $this->htmlEscape($_lang->getName()) ?>
<?php endforeach;?>
</div>
<?php endif; ?>
PS: I did not change this in the default magento code. I am working in app/design/frontend/default/projectname/template/page/switch/language.phtml.
So I managed to get this working by myself with this code:
<?php if(count($this->getStores())>1): ?>
<div class="form-language">
<?php foreach ($this->getStores() as $_lang):?>
<?php echo $this->htmlEscape($_lang->getName()) ?>
<?php endforeach;?>
</div>
<?php endif; ?>
But now when I switch language. It redirects to the home page.
I found I should use:
$_lang->getCurrentUrl()
But I have no idea where to place this in my code.
You're very close, you just need to include the URL!
<?php if(count($this->getStores())>1): ?>
<div class="form-language">
<?php foreach ($this->getStores() as $_lang):?>
<?php echo $this->htmlEscape($_lang->getName()) ?>
<?php endforeach;?>
</div>
<?php endif; ?>
This seems to be different in Enterprise compared to Community. This is what the code is like in Magento Enterprise v1.12. Maybe it is of use, or maybe it works as well.
<?php if(count($this->getStores())>1): ?>
<div class="switch switcher-language">
<label><?php echo $this->__('Language') ?>:</label>
<div class="switch-wrapper" id="languageSelect">
<strong class="current language-<?php echo $this->htmlEscape(Mage::app()->getStore()->getCode()) ?>">
<?php echo $this->htmlEscape(Mage::app()->getStore()->getName()) ?>
</strong>
<span class="switcher-holder">(<span onclick="popUpMenu(this);" class="switcher"><?php echo $this->__('Change')?></span>)</span>
<ul style="display:none" id="popId-languageSelect">
<li class="current language-<?php echo $this->htmlEscape(Mage::app()->getStore()->getCode()) ?>">
<span><?php echo $this->htmlEscape(Mage::app()->getStore()->getName()) ?></span>
</li>
<?php foreach ($this->getStores() as $_lang): ?>
<?php if($_lang->getId()!=$this->getCurrentStoreId()): ?>
<li class="language-<?php echo $this->htmlEscape($_lang->getCode()); ?>">
<?php echo $this->htmlEscape($_lang->getName()) ?>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
</div>
<?php endif; ?>
Try this code. I tested in EE 1.12.
<?php if(count($this->getStores())>1): ?>
<ul>
<?php foreach ($this->getStores() as $_lang): ?>
<?php if($_lang->getId()!=$this->getCurrentStoreId()): ?>
<li class="language-<?php echo $this->htmlEscape($_lang->getCode()); ?>">
<?php echo $this->htmlEscape($_lang->getName()) ?>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<?php endif; ?>

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.