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; ?>
Related
I'm newbie and I would like to know the way to put search bar beside page selector.
Here's a screenshot now :
https://imgur.com/a/S9X3sIc
My desire layout :
https://imgur.com/a/0zx3rfl
How can I make it? I need your help. Thanks in advance. I love you guys. :D
<div class="wpf-navi <?php echo esc_attr($class) ?>">
<div class="wpf-navi-wrap">
<div id="wpf-widget-search" class="wpforo-widget-wrap"><form action="<?php echo wpforo_home_url() ?>" method="get">
<?php wpforo_make_hidden_fields_from_url( wpforo_home_url() ) ?>
<input type="text" placeholder="<?php wpforo_phrase('Search...') ?>" name="wpfs" class="wpfw-70" value="<?php echo isset($_GET['wpfs']) ? esc_attr(sanitize_text_field($_GET['wpfs'])) : '' ?>" ><input type="submit" class="wpfw-20" value="ยป">
</form></div>
<span class="wpf-page-info">
<?php wpforo_phrase('Page') ?> <?php echo intval($paged) ?> / <?php echo intval($pages_count) ?>
</span>
<?php if( $paged - 1 > 0 ): $prev_url = ( ($paged - 1) == 1 ? $sanitized_current_url : sprintf($url, $paged - 1) ); ?>
<a href="<?php echo esc_url( WPF()->user_trailingslashit($prev_url) ) ?>" class="wpf-prev-button" rel="prev">
<i class="fas fa-chevron-left fa-sx"></i> <?php wpforo_phrase('prev') ?>
</a>
<?php endif ?>
<select class="wpf-navi-dropdown" onchange="if (this.value) window.location.assign(this.value)" title="<?php esc_attr( wpforo_phrase('Select Page') ) ?>">
<option value="<?php echo esc_url( WPF()->user_trailingslashit($sanitized_current_url) ) ?>" <?php wpfo_check($paged, 1, 'selected') ?>>1</option>
<?php for($i = 2; $i <= $pages_count; $i++) : ?>
<option value="<?php echo esc_url( WPF()->user_trailingslashit( sprintf($url, $i) ) ) ?>" <?php wpfo_check($paged, $i, 'selected') ?>>
<?php echo $i ?>
</option>
<?php endfor; ?>
</select>
<?php if( $paged + 1 <= $pages_count ): ?>
<a href="<?php echo esc_url( WPF()->user_trailingslashit(sprintf($url, $paged + 1) ) ) ?>" class="wpf-next-button" rel="next">
<?php wpforo_phrase('next') ?> <i class="fas fa-chevron-right fa-sx"></i>
</a>
<?php endif ?>
</div>
</div>
I am trying to add shipping cost for each country.whenever i am trying to save those all values it added multiple row in table.
But How can i show all these selected values in my edit form in yii2?
Controller:
$countrywiseshipping = new ProductCountrywiseshipping();
$countryArr = [];
foreach ($countrylist as $country) {
$countryArr[$country->idCountry->id_country]['code'] = $country->idCountry->iso_code;
$countryArr[$country->idCountry->id_country]['call_prefix'] = $country->idCountry->call_prefix;
$countryArr[$country->idCountry->id_country]['name'] = $country->name;
}
View:
<div class="col-sm-7 col-md-8 col-xs-6" id="cntryDiv">
<div class="row repeat-addcountry-part" id="subcntry1">
<div class="col-sm-3" id="shipcountry">
<label>Country</label>
<div class="categry-select">
<div class="styled-select">
<select class="countries2 form-control" data-country="US">
<?php foreach ($countryArr as $country_id => $country) { ?>
<option id="country_<?php echo $country_id ?>" value="<?php echo $country_id ?>" data-code="<?php echo strtolower($country['code']) ?>" data-prefix="<?php echo $country['call_prefix'] ?>" data-image="images/blank.gif" data-imagecss="flag <?php echo strtolower($country['code']) ?>" data-title="<?php echo $country['name'] ?>"><?php echo $country['name'] ?></option>
<?php } ?>
</select>
</div>
</div>
</div>
<div class="col-sm-3" id="costs">
<label>Cost</label>
<div class="input-cost">
<?php echo $form->field($countrywiseshipping, 'price[]')->textInput(['onblur'=>'assocC(this)'])->label(false) ?>
</div>
</div>
<div class="col-sm-3">
Del Country
</div>
<label>(To offer free shipping to your customers just enter $0.00.)</label>
</div>
</div>
Edit:
$countrywiseshipping = ProductCountrywiseshipping::find()->where(['id_product' => $id_product])->all();
If i print the variable $countrywiseshipping it return all selected values.
But i want all selected country alongwith price in edit form. How is it possible?
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.
I can't update my database.. I wonder why it's not working while it worked on my other pages. I'm receiving this error:
You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version
for the right syntax to use near 'WHERE id =1' at line 4
This is the code:
<?php require_once("include/connect.php"); ?>
<?php require("include/bp_function.php"); ?>
<?php url(); ?>
<?php
$title = mysql_prep($_POST['title']);
$content = mysql_prep($_POST['content']);
$id = mysql_prep($_GET['aboutusid']);
$query = "UPDATE aboutus SET
title='{$title}',
content='{$content}',
WHERE id ={$id}";
mysql_query($query);
if(mysql_affected_rows() == 1) {
echo "Succesfully Updated {$title}
<br/>Go back to Backpanel";
} else {
echo "failed {$id}<br />".mysql_error()."<p> </p>";
}
?>
<?php require_once("include/footer.php"); ?>`
This is the form:
<?php require("include/connect.php"); ?>
<?php require("include/bp_function.php"); ?>
<?php url(); ?>
<?php include("include/bp_header.php"); ?>
<div id="bgcontainer">
<!-- NEWS CONTAINER -->
<div id="bodycont">
<div id="left_page">
<h2>About Us Menu</h2>
<?php list_of_aboutus(); ?>
<br />+ Add Menu
<hr />
</div>
<div id="right_page">
<h2>Edit: <?php echo $s_aboutus['title']; ?> </h2>
<br /><br />
<form action="query_editaboutus.php?aboutusid=<?php echo urlencode($s_aboutus['id']); ?>" method="post" enctype="multipart/form-data">
<table>
<tr valign="top"><td width="100px">Title:</td> <td><input name="title" type="name" size="45" value="<?php echo $s_aboutus['title']; ?>" /></td></tr>
<tr valign="top"><td width="100px">Content:</td> <td>
<textarea name="content" cols="45" rows="20" value="" > <?php echo $s_aboutus['content']; ?> </textarea>
<tr valign="top"><td width="100px">Update:</td><td><input type="submit" id="submit" value="Update" /></td></tr>
</table>
</form>
</div>
<!-- MEDIA CONTAINER -->
<?php include("include/footer.php"); ?>
Remove the comma after setting the content field.
$query = "UPDATE aboutus SET title='{$title}', content='{$content}' WHERE id ={$id}";
Original for comparison
$query = "UPDATE aboutus SET title='{$title}', content='{$content}', WHERE id ={$id}";
Check your update statement
$query = "UPDATE aboutus SET
title='{$title}',
content='{$content}'
WHERE id ={$id}";
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.