how to get onchange value after select navigation menu in magento? - magento

hi all how to get onchange value after select navigation menu in magento?
i trying to following code in topmenu.phtmlbut it's not working proper showing page is not found
But it's not working properly. What do i do?

you can try something like this
<select id="nav" class="nav" onchange="if (this.value) window.location.href=this.value">

Update Topmenu.php code with below code.
Remove this:
$html .= '<option ' . $this->_getRenderedMenuItemAttributes($child) . '>';
$html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '><span>' . $this->escapeHtml($child->getName()) . '</span></a>';
if ($child->hasChildren()) {
if (!empty($childrenWrapClass)) {
$html .= '<div class="' . $childrenWrapClass . '">';
}
$html .= '<ul class="level' . $childLevel . '">';
$html .= $this->_getHtml($child, $childrenWrapClass);
$html .= '</ul>';
if (!empty($childrenWrapClass)) {
$html .= '</div>';
}
}
$html .= '</option>';
Add below code:
$html .= '<option value="' . $child->getUrl() . '" '>'. $this->escapeHtml($child->getName()) . '</option>';
if ($child->hasChildren()) {
$html .= $this->_getHtml($child, $childrenWrapClass);
}
And update select onchange code with below code:
onchange="if (this.value) window.location.href=this.value"

Related

laravel livewire mount dynamic fields

I would like to have dynamic input fields with values ​​for all that are already entered in the db.
the following code works!
here the values ​​of the input extras.4 fields are displayed on the website
public function mount() {
$this->advettisment_extras = DB::table('advertisment_extras')
->where('advertisment_number', '=', $this->advertisment['advertisment_number'])
->where('user_id', '=', Auth::user()->id)->get()->toArray();
foreach ($this->advettisment_extras as $advettisment_extra) {
$this->extras = [
'4' => '12346548'
];
}
}
but when I try to dynamically search for and fill in the fields from db, the values ​​are not displayed.
foreach ($this->advettisment_extras as $advettisment_extra) {
$this->extras = [
$advettisment_extra->extra_id => $advettisment_extra->extra_value
];
}
can anyone help ?
<div class="row" wire:init="loadExtras">
#if(isset($categorie_extras))
#foreach($categorie_extras as $categorie_extra)
<div class="col-4 form-group">{!! getExtraField($categorie_extra->extra_id, $advertisment->advertisment_number) !!}</div>
#endforeach
#endif
</div>
and my getExtraField Function in helper.php
//Helper für Anzeige der Extra Felder
function getExtraField($extra_id, $advertisment_number) {
$field = '';
$option = '';
// Extra aus DB holen
$extra = \Illuminate\Support\Facades\DB::table('extras')->where('id', '=', $extra_id)->first();
$advertisment_extras = \Illuminate\Support\Facades\DB::table('advertisment_extras')
->where('advertisment_number', '=', $advertisment_number)
->where('user_id', '=', \Illuminate\Support\Facades\Auth::user()->id)->get();
switch ($extra->extra_form_item) {
case 'input':
foreach($advertisment_extras as $advertisment_extra) {
if ($advertisment_extra->extra_id == $extra->id ) {
$field = '<label for="' . $extra->id . '">' . $extra->extra_field_label . '</label><input type="' . $extra->extra_input_field_type . '" wire:model.lazy="extras.' . $extra->id . '" name="' . $extra->id . '" class="form-control" id="' . $extra->id . '">';
break;
} else {
$field = '<label for="' . $extra->id . '">' . $extra->extra_field_label . '</label><input type="' . $extra->extra_input_field_type . '" wire:model.lazy="extras.' . $extra->id . '" name="' . $extra->id . '" class="form-control" id="' . $extra->id . '">';
}
}
break;
case 'select':
$values = explode(',', $extra->extra_enum_select_values);
// Option des Select Feldes suchen
$field_1 = '<label for="' . $extra->id . '">' . $extra->extra_field_label . '</label><select name="' . $extra->id . '" wire:model="extras.'. $extra->id . '" class="form-control" id="' . $extra->id . '">';
foreach ($values as $value) {
$option = $option .'<option value="'. $value . '">' . $value . '</option>';
}
$field_3 = '</select>';
$field = $field_1 . $option . $field_3;
break;
case 'checkbox' :
$field = '<label for="' . $extra->id . '">' . $extra->extra_field_label . '</label><br><input type="checkbox" name="' . $extra->id . '" wire:model="extras.'. $extra->id . '" class="" value="1" id="' . $extra->id . '">';
break;
}
return $field;
}
and my complete component:
//Helper für Anzeige der Extra Felder
function getExtraField($extra_id, $advertisment_number) {
$field = '';
$option = '';
// Extra aus DB holen
$extra = \Illuminate\Support\Facades\DB::table('extras')->where('id', '=', $extra_id)->first();
$advertisment_extras = \Illuminate\Support\Facades\DB::table('advertisment_extras')
->where('advertisment_number', '=', $advertisment_number)
->where('user_id', '=', \Illuminate\Support\Facades\Auth::user()->id)->get();
switch ($extra->extra_form_item) {
case 'input':
foreach($advertisment_extras as $advertisment_extra) {
if ($advertisment_extra->extra_id == $extra->id ) {
$field = '<label for="' . $extra->id . '">' . $extra->extra_field_label . '</label><input type="' . $extra->extra_input_field_type . '" wire:model.lazy="extras.' . $extra->id . '" name="' . $extra->id . '" class="form-control" id="' . $extra->id . '">';
break;
} else {
$field = '<label for="' . $extra->id . '">' . $extra->extra_field_label . '</label><input type="' . $extra->extra_input_field_type . '" wire:model.lazy="extras.' . $extra->id . '" name="' . $extra->id . '" class="form-control" id="' . $extra->id . '">';
}
}
break;
case 'select':
$values = explode(',', $extra->extra_enum_select_values);
// Option des Select Feldes suchen
$field_1 = '<label for="' . $extra->id . '">' . $extra->extra_field_label . '</label><select name="' . $extra->id . '" wire:model="extras.'. $extra->id . '" class="form-control" id="' . $extra->id . '">';
foreach ($values as $value) {
$option = $option .'<option value="'. $value . '">' . $value . '</option>';
}
$field_3 = '</select>';
$field = $field_1 . $option . $field_3;
break;
case 'checkbox' :
$field = '<label for="' . $extra->id . '">' . $extra->extra_field_label . '</label><br><input type="checkbox" name="' . $extra->id . '" wire:model="extras.'. $extra->id . '" class="" value="1" id="' . $extra->id . '">';
break;
}
return $field;
}
my problem is that the value is not displayed in the fontend. That means the mount function does not work dynamically, but if I put it in directly as described above it works:
foreach ($xs as $x) {
$this->extras = [
'4' => '12345678'
];
}
but I would like to load the fields dynamically with values ​​like here:
foreach ($xs as $x) {
$this->extras = [
$x->extra_id => $x->extra_value,
];
}
Thanks for help :)

how to send codeigniter cart data on email

hello guys I tried to much to send codeigniter cart data on mail, it woking but I need to send it on html table.plz help me
if($cart = $this->cart->contents()){
foreach ($cart as $item){
$htmlContent=array(
'orderid'=>$user_id,
"product name": ".$item['name'],
);
$dataset[] = implode(', ', $htmlContent);
}
}
$content = implode("\n<br>", $dataset);
$headers = 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n";
$headers .= 'From:attaulahk782#gmail.com'."\n";
mail('attaullahk782#gmail.com', $subject, $content , $headers);
Please follow bellow code:
<?php
$content = '<table cellpadding="6" cellspacing="1" style="width:100%" border="0">';
$content .= '<tr>';
$content .= '<th>QTY</th>';
$content .= '<th>Item Description</th>';
$content .= '<th style="text-align:right">Item Price</th>';
$content .= '<th style="text-align:right">Sub-Total</th>';
$content .= '</tr>';
$i = 1;
foreach ($this->cart->contents() as $items):
$content .= '<tr>';
$content .= '<td>'.$items['qty'].'</td>';
$content .= '<td>'.$items['name'];
if ($this->cart->has_options($items['rowid']) == TRUE):
$content .= '<p>';
foreach ($this->cart->product_options($items['rowid']) as $option_name => $option_value):
$content .= '<strong>'.$option_name.':</strong>'.$option_value.'<br />';
endforeach;
$content .= '</p>';
endif;
$content .= '</td>';
$content .= '<td style="text-align:right">'.$this->cart->format_number($items['price']).'</td>';
$content .= '<td style="text-align:right">$'.$this->cart->format_number($items['subtotal']).'</td>';
$content .= '</tr>';
$i++;
endforeach;
$content .= '<tr>';
$content .= '<td colspan="2"> </td>';
$content .= '<td class="right"><strong>Total</strong></td>';
$content .= '<td class="right">$'.$this->cart->format_number($this->cart->total()).'</td>';
$content .= '</tr>';
$content .= '</table>';
$headers = 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n";
$headers .= 'From:attaulahk782#gmail.com'."\n";
mail('attaullahk782#gmail.com', $subject, $content , $headers);
?>

Magento 1.9 Duplicate View all title in sub-category

When I define a subcategory (i.e. sub1) in a category (i.e. main1), the resulting top menu displays:
1.The title of the category (main1)
2.The submenu with 2 option
View all main1
sub1
I don't understand why the name of the category is duplicated in the subcategory with 'View all' in front of the name.
Do you know how to disable it?
You can disable this by going to the file app/design/frontend/???/your-template/template/page/html/topmenu/renderer.phtml
Then comment out line 64 to 68 which should be:
$html .= '<li class="level'. $nextChildLevel .'">';
$html .= '<a class="level'. $nextChildLevel .'" href="'. $child->getUrl() .'">';
$html .= $this->__('View All ') . $this->escapeHtml($this->__($child->getName()));
$html .= '</a>';
$html .= '</li>';
this way you comment out the "View all", if you comment out the whole block, you will not get a submenu.
I think you need to get rid of the first "View All SubcategoryName" link. If you need that, just change the code like this:
$html .= '<li class="level'. $nextChildLevel .'">';
$html .= '<a class="level'. $nextChildLevel .'" href="'. $child->getUrl() .'">';
if($childLevel > 1) {
$html .= $this->escapeHtml($this->__($child->getName()));
}
$html .= '</a>';
$html .= '</li>';
Good luck.

magento how to make a parent menu link which has subcategories not clickable

Can someone help me with this please? I'm using Magento CE 1.8.0.0
magento how to make a parent menu link which has subcategories not clickable
I've tried the below codes, they don't work for me either.
app/code/core/Mage/Catalog/Block or Topmenu.php
if($category->getLevel()== 2 && $hasActiveChildren) {
$html[] = '<a href="'.$this->getCategoryUrl($category).'"'.$linkClass.' onclick="return false;">';
$html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
$html[] = '</a>';
} else {
$html[] = '<a href="'.$this->getCategoryUrl($category).'"'.$linkClass.'>';
$html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
$html[] = '</a>';
}
if ($category->getID()==[category ID]) {
$linkClass = 'class="no-click"';
$html[] = '<a href="javascript:void(0)"'.$linkClass.'>';
}
else{
$html[] = '<a href="'.$this->getCategoryUrl($category).'"'.$linkClass.'>;';
}
To make it works on top level only:
app/code/local/Mage/Page/Block/Html/Topmenu.php, line 126 replace this code
$html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '><span>'
. $this->escapeHtml($child->getName()) . '</span></a>';
With :
if ($child->hasChildren() && $childLevel == 0 ) {
$html.= '<a href="#" ' . $outermostClassCode . ' onclick="return false;"><span>'
. $this->escapeHtml($child->getName()) . '</span></a>'."\n";
}
else {
$html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '><span>'
. $this->escapeHtml($child->getName()) . '</span></a>';
}
Titonja has the answer here:
app/code/local/Mage/Page/Block/Html/Topmenu.php
Around line 126. Find this code:
$html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '><span>'
. $this->escapeHtml($child->getName()) . '</span></a>';
Replace with:
if ($child->hasChildren()) {
$html.= '<a href="#" ' . $outermostClassCode . ' onclick="return false;"><span>'
. $this->escapeHtml($child->getName()) . '</span></a>'."\n";
}
else {
$html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '><span>'
. $this->escapeHtml($child->getName()) . '</span></a>';
}
Clear cache. It works for me on Magento 1.8.0.0
For people with version 1.6.2, try this:
Look for the file: /app/code/core/Mage/Catalog/Block/Navigation.php
Replace line 268:
$html[] = '<a href="'.$this->getCategoryUrl($category).'"'.$linkClass.'>';
By this conditional:
$myParentIds = array(3,6,10);
if (in_array($category->getID(), $myParentIds)){
$linkClass = ' class="no-click"';
$html[] = '<a href="javascript:void(0)"'.$linkClass.'>';
}
else{
$html[] = '<a href="'.$this->getCategoryUrl($category).'"'.$linkClass.'>';
}
I hope this helps.
app/code/local/Mage/Page/Block/Html/Topmenu.php
Around line 126. Find this code:
$html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '><span>'. $this->escapeHtml($child->getName()) . '</span></a>';
Replace with:
if ($child->hasChildren() && $childLevel == 0) {
$html.= '<span>'. $this->escapeHtml($child->getName()) . '</span>'."\n";
} else {
$html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '><span>'. $this->escapeHtml($child->getName()) . '</span></a>';
}

Checkbox ajax form posts the word array to email

I am trying to make a booking form with checkboxes using an existing contact form.js script and mailhandler.php from template monster. All of the text and textarea inputs work fine but the checkboxes only return the word array.
Here's parts of the code:
html
<form action="bin/MailHandler.php" method="post" id="booking-form" >
<fieldset>
<div class="grid_12">
<div class="bookingformwrapper">
<div class="headerbar">WAXING</div>
intrested in:<br/>
<input type="checkbox" name="waxing[]" value="kidum_esek" id="wax1"/>aaa<br />
<input type="checkbox" name="waxing[]" value="mitug_esek" id="wax2"/>bbb<br />
<input type="checkbox" name="waxing[]" value="laikim" id="wax3"/>CCC<br />
<input type="checkbox" name="waxing[]" value="aher" id="wax4"/>DDD<br />
ajax jquery
,submitFu:function(){
var data = { 'waxing[]' : []};
$(":checked").each(function() {
data['waxing[]'].push($(this).val());
});
_.validateFu(_.labels)
if(!_.form.has('.'+_.invalidCl).length)
$.ajax({
type: "POST",
url:_.mailHandlerURL,
data:{
choice:'waxing[]',
name:_.getValFromLabel($('.name',_.form)),
email:_.getValFromLabel($('.email',_.form)),
phone:_.getValFromLabel($('.phone',_.form)),
fax:_.getValFromLabel($('.fax',_.form)),
state:_.getValFromLabel($('.state',_.form)),
message:_.getValFromLabel($('.message',_.form)),
message2:_.getValFromLabel($('.message2',_.form)),
datepicker:_.getValFromLabel($('#datepicker',_.form)),
owner_email:_.ownerEmail,
stripHTML:_.stripHTML
},
success: function(){
_.showFu()
}
})
},
php
<?php
$owner_email = $_POST["owner_email"];
$headers = 'From:' . $_POST["email"];
$subject = 'A message from your site visitor ' . $_POST["name"];
$messageBody = "";
if($POST['waxing[]'] !='nope'){
$messageBody .= '<p>Choice: ' . explode(",", $_POST['waxing[]']);
$messageBody .= '<br>' . "\n";
}
if($_POST['name']!='nope'){
$messageBody .= '<p>Visitor: ' . $_POST["name"] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
if($_POST['email']!='nope'){
$messageBody .= '<p>Email Address: ' . $_POST['email'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}else{
$headers = '';
}
if($_POST['state']!='nope'){
$messageBody .= '<p>State: ' . $_POST['state'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
if($_POST['phone']!='nope'){
$messageBody .= '<p>Phone Number: ' . $_POST['phone'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
if($_POST['fax']!='nope'){
$messageBody .= '<p>Fax Number: ' . $_POST['fax'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
if($_POST['datepicker']!='nope'){
$messageBody .= '<p>Date: ' . $_POST['datepicker'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
if($_POST['message']!='nope'){
$messageBody .= '<p>Address: ' . $_POST['message'] . '</p>' . "\n";
}
if($_POST['message2']!='nope'){
$messageBody .= '<p>Notes: ' . $_POST['message2'] . '</p>' . "\n";
}
if($_POST["stripHTML"] == 'true'){
$messageBody = strip_tags($messageBody);
}
try{
if(!mail($owner_email, $subject, $messageBody, $headers)){
throw new Exception('mail failed');
}else{
echo 'mail sent';
}
}catch(Exception $e){
echo $e->getMessage() ."\n";
}
?>
This is what gets returned on the email:
Choice: Array
Visitor: Father Christmas
Email Address: father#christmas.com
Phone Number: 01234 567890
Date: 25th December
Address: North Pole
Notes: Mince Pies
Where it says Choice: Array, I need it to give me the values of the selected/checked checkboxes.

Resources