how to send codeigniter cart data on email - codeigniter

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

Related

Ajax function not returing anything in response but post is working fine: Wordpress

I have this ajax script that action on a function in function.php to send an email after submitting the form. Data is posting but the function is not triggering and so the email is not sending , also script is not showing anything in response.
==================Jquery====================
jQuery('#quote-forms').submit(function(e) {
e.preventDefault();
var ocity = jQuery(".ocity").val();
var ostate = jQuery(".ostate").val();
var ozip = jQuery(".ozip").val();
var dataString = 'custom ocity='+ ocity + '&custom ostate=' + ostate + '&custom ozip=' + ozip;
jQuery.ajax({
type: "POST",
url: "/wp-admin/admin-ajax.php",
action : 'quote_ajax_submission',
data: dataString,
success: function() {
alert("sent");
}
});
});
And here is my function in function.php file can you please check and let me know what is the issue so no response in return and email is not sending.
add_action('wp_ajax_quote_ajax_submission', 'quote_ajax_handler');
add_action('wp_ajax_nopriv_quote_ajax_submission','quote_ajax_handler');
function quote_ajax_handler(){
echo "helol";
$oCity = $_POST["custom ocity"];
$iZip = $_POST["custom ozip"];
$oState = $_POST["custom ostate"];
$dState = $_POST["dstate"];
$dZip = $_POST["dzip"];
$dCity = $_POST["dcity"];
$rNumbers = $_POST["room-numbers"];
$mDate = $_POST["mdate"];
$fName = $_POST["fname"];
$lName = $_POST["lname"];
$pEmail = $_POST["pemail"];
$pPhone = $_POST["pphone"];
$addtion_C = $_POST["additionC"];
$to = 'shoaibswl123#gmail.com';
$subject = 'Quote Request From '. $fName ;
$message = '<html><body>';
$message = '<div style="background:#CEE4ED; padding:10px;>';
$message = '<div style="margin-left:30px;">';
$message .= "<br>";
$message .= "<br>";
$message .= "<b>Hi Admin,</b>";
$message .= "<br>";
$message .= "<br>";
$message .= 'You have received a new quote from the site with the following information';
$message .= "<br>";
$message .= "<br>";
$message .= '<b>Address Information:</b>';
$message .= "<br>";
$message .= "<br>";
$message .= "<b>Origin City: </b>" .$oCity;
$message .= "<br />";
$message .= "<b>Origin Zip: </b>" . $iZip;
$message .= "<br />";
$message .= "<b>Origin State: </b>" . $oState;
$message .= "<br />";
$message .= "<b>Destination City: </b>" .$dCity;
$message .= "<br />";
$message .= "<b>Destination Zip: </b>" .$dZip;
$message .= "<br />";
$message .= "<b>Destination State: </b>" .$dState;
$message .= "<hr>";
$message .= "<br>";
$message .= "<br>";
$message .= '<b>Client Information:</b>';
$message .= "<br />";
$message .= "<br />";
$message .= "<b>First Name: </b>" .$fName;
$message .= "<br />";
$message .= "<b>Last Name: </b>" .$lName;
$message .= "<br />";
$message .= "<b>Primary Emai: </b>" .$pEmail;
$message .= "<br />";
$message .= "<b>Primary Phone: </b>" .$pPhone;
$message .= "<hr>";
$message .= "<br>";
$message .= "<br>";
$message .= '<b>Moving Information:</b>';
$message .= "<br>";
$message .= "<br />";
$message .= "<b>Moving Date: </b>" .$mDate;
$message .= "<br />";
$message .= "<b>Number of Rooms: </b>" .$rNumbers;
$message .= "<hr>";
$message .= "<br>";
$message .= "<br>";
$message .= '<b>Addition Comments :</b>';
$message .= "<br />";
$message .= '<p>'.$addtion_C.'</p>' ;
$message .= "<br>";
$message .= "<br>";
$message .= "<br>";
$message .= "<p>Thank you.</p>";
$message .= "</div></div>";
$message .= "</body></html>";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: '.$pEmail.'' . "\r\n";
if(wp_mail($to, $subject, $message, $headers)){
echo "<div class='success-message'>Message Has Been Sent Successfully..!</div>";
}else{
echo "<div class='success-message'>There is an error while sending message..!</div>";
}
die();
}
There was issue with action element in ajax call.
so we have updated the code like this and added the action element in the data array and its work as follows:
jQuery.ajax({
type: "POST",
url: "/wp-admin/admin-ajax.php",
data: 'action=quote_ajax_submission&'+dataString,
success: function(data) {
alert("sent");
},
error: function(request, status, error){
alert(request.responseText);
}
});
});
So before the updated code the action element was like this:
action : 'quote_ajax_submission',
After update the code action like this...
data: 'action=quote_ajax_submission&'+dataString,

how to escape HTML entity when used character_limiter in codeignite3?

I've using character_limiter in codeigniter to limit text which I selected from data and that text were input by TinyMCE editor so my text will contain with html character and another css that why my result is wrong because Character_limiter will count all the character both text and html code.
So I want to know how to escape all HTML or any code from my text and limited below function
Here is my Model
public function content() {
$this->load->helper('text');
$this->promot = $this->my_model->all_selct('*', 'content', array('status' => 1, 'lang' => $this->langs, 'home'=>1), FALSE);
if ($this->promot) {
$out = '';
foreach ($this->promot as $item) {
$text = html_entity_decode($item['text']);
$out .= '<div class="col-lg-12 col-md-6 col-xs-6" style="padding:0px; !important">'; // animated bounceIn
$out .= '<div style=" " class="thumbnail mgrid">'; // animated bounceIn
$out .= '<a href ="' . base_url($this->cleanstr($item['slug']). '/'.$item['cid']).'" >';
// $out .= '<img src ="' . base_url('assets/img/content/' . $item['img']) . '"class="img-responsive">';
$out .= '<div class ="hom_img">';
$out .= '<h3 class="text-left">' . $item['name'] . '</h3></a>';
$out .= '<p class="himg">'.character_limiter($text, 50) . ' </p>';
$out .='</div>';
$out .='</div>';
$out .='</div>';
}
} else {
return false;
}
return $out;
}

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.

how to get onchange value after select navigation menu in 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"

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