Customer not marked as notified programatically Magento - email

add a one new batch action in magento , in this i am changing the
status of the order pragmatically
.Its all working fine
but the problem is after changing the status and send email to
customer also it is not showing customer notified in comment history
. Below is the code
$order->setIsCustomerNotified(false);
$order->setStatus("ready_for_pickup");
$order->addStatusHistoryComment($comment, false);
$order->save();
$order->sendOrderUpdateEmail($notify = true, $comment);
Can you please suggest me how can i fix this.
thanks

OK i have got the solution and by below piece of code it is working fine now.
$order->setIsCustomerNotified(false);
$order->setStatus("your_order_status");
$historyItem = $order->addStatusHistoryComment($comment, "your_order_status");
$historyItem->setIsCustomerNotified(1)->save();
$order->save();
$order->sendOrderUpdateEmail($notify = true, $comment);

We can also send order update email just using sendOrderUpdateEmail. After order save.
$order->save();
$order->sendOrderUpdateEmail($notify = true, 'Replace your comment');

Related

woocommerce REST API Get customer by email

Get customer by email
https://localhost/biobays/wp-json/wc/v2/customers/2 getting customer by id is working. But
https://localhost/biobays/wp-json/wc/v2/customers/email/test#t.com or https://localhost/biobays/wp-json/wc/v2/customers?email=test#t.com are not working
I expect the user info do be retrieved.
I'm having an empty response.
PS: this work great on old v3 https://localhost/biobays/wc-api/v3/customers/email/test#t.com
Joe,
I make a little test and this is the call you need to do to the API:
$params = array("email" => "test#t.com");
$getContact = $wcApi->get('customers',$params);
echo "<pre>";
print("<pre>".print_r($getContact , true)."</pre>");
echo"</pre>";
If you will test the url make the call like this:
https://localhost/biobays/wp-json/wc/v2/customers?email=test%40t.com&consumer_key=YOUR_CONSUMER_KEY&consumer_secret=YOUR_CONSUMER_SECRET
If no e-mail exists one empty array is returned.
For new version api tested on 5.8.x , this seems to working fine
https://yourdomain.com/wp-json/wc/v3/customers?email=xxxxxxx#gmail.com

Facebook External doesn't get email value in Nopcommerce 3.60

Currently I use NopCommerce 3.60 and use FB External Login.
Problem:
After I login in Nop by FB External Button and it returns to URL mydomain.com/login#_=__ with red message (Email is required) and it does not login user in.
Screenshot: http://postimg.org/image/wvgu6wvud/
What I was try:
Reinstall Nop from scratch and has below setting
In advance setting and option I has:
Externalauthenticationsettings.requireemailvalidation False
Auto register enabled: Checked.
Registration method: Email Validation
I try to debug source code in file name FacebookProviderAuthorizer.cs in Nop.Plugin.ExternalAuth.Facebook folder and also does not get email value too.http://postimg.org/image/qwmphn9tn/
Have anyone suggest me what to do next for this problem please.
Fixed. You can see changeset 5bb6815e30ee
I am not familiar with Nop, but it is possible to register at Facebook without an email. This is why most libraries for fb-oauth checking against eMail and if there is no email, they create an user-id#facebook.com eMail address.
Maybe your Nop library of fb-oauth is out dated?
So please check if there is such a function - if not, you might got your problem.
Somehow FB doesn't include email in oauth. You can use this method to get email and supply that email to register.
//as part of the uri for the webrequest, include all the fields you want to use
var request = WebRequest.Create("https://graph.facebook.com/me?fields=email,name&access_token=" + Uri.EscapeDataString(authorization.AccessToken));
using (var response = request.GetResponse())
{
using (var responseStream = response.GetResponseStream())
{
System.IO.StreamReader streamReader = new System.IO.StreamReader(responseStream, true);
string MyStr = streamReader.ReadToEnd();
JObject userInfo = JObject.Parse(MyStr);
//now you can access elements via:
// (string)userInfo["name"], userInfo["email"], userInfo["id"], etc.
}
}

How to send email notification after creating lead in sugarcrm through webservice(nusoap)

I have successfully created a lead in sugarcrm 6.5 using nusoap. But now problem is, How to send email notification to assigned user?
Please help me!!
Based on your situation, what I would do is use a after_save logic hook to send your email. Logic Hooks allow you to plug into the SugarCRM logic. The code below allows you to do something after a Lead is saved.
Create a logic_hooks.php or add the following if it already exists in custom/modules/Leads/logic_hooks.php
<?php
$hook_version = 1;
$hook_array = Array();
$hook_array['after_save'] = Array();
$hook_array['after_save'][] = Array(1, 'Send Notification', 'custom/modules/Leads/Leads_custom.php','Leads_custom', 'send_notification');
After any Lead is saved, it'll run the following code in custom/modules/Leads/Leads_custom.php
<?php
class Leads_custom
{
function send_notification($bean, $event, $arguments)
{
// write your code here to send the notification to the head(Manager)
}
}
This will fire anytime Leads are created or edited. If you need to only send notifications on new Leads, you can use this technique: http://developers.sugarcrm.com/wordpress/2013/08/21/doing-beforeafter-field-comparisons-in-after_save-logic-hooks/
If you have the process manager available in your Sugar Version (entrprise+) then you just have to create a process definition that triggers an email when a new lead is created. If not then it's a logic hook.

How to add senders name while sending a mail using WebMail

My current code is:
WebMail.SmtpServer = "relay-hosting.secureserver.net";
WebMail.From = "support#shayonainfo.com";
While I send a mail using above code the senders name at the receivers side is shown as "support" instead of that I want to show "Shayona".. I tried doing something like I did in C#.net but not
WebMail.From = new MailAddress("support#shayonainfo.com", "Shayona Infocom");
Try:
WebMail.From = "Shayona Infocom support#shayonainfo.com";
From the answer by #Tom Studee
I tried it and found that on the receiver's side the senders name is shown as <Shayona Infocom>.. I tried editing the answer by him but unfortunately it didn't worked..
So finally this worked for me:
WebMail.From = "Shayona Infocom support#shayonainfo.com";

cannot get full shopping cart detail using GetExpressCheckoutDetails

I am currently testing an online store using a custom cart within paypal sandbox.
I am able to go trough all transcation steps properly
setExpressCheckout-> pay -> DoExpressCheckout.
During the DoExpressCheckout step I think it would be the good time to update my database with the order. For that I use the GetExpressCheckoutDetails function to retrieve the content of the transaction.
Sadly this function return everything paypal has to offer but miss the content of my cart. All i can get is the detail of one item. If the transaction involve multiple items i would only get the details of the first one.
Here is my code (mostly taken from paypal samples) :
$token =urlencode( $_REQUEST['token']);
$payerId=urlencode( $_REQUEST['PayerID']);
$getExpressCheckoutDetailsRequest = new GetExpressCheckoutDetailsRequestType($token);
$getExpressCheckoutReq = new GetExpressCheckoutDetailsReq();
$getExpressCheckoutReq->GetExpressCheckoutDetailsRequest = $getExpressCheckoutDetailsRequest;
$paypalService = new PayPalAPIInterfaceServiceService();
$getECResponse = $paypalService->GetExpressCheckoutDetails($getExpressCheckoutReq);
$details = $getECResponse->GetExpressCheckoutDetailsResponseDetails;
// $details->PaymentDetails->PaymentDetailsItem this array should hold all items details
// sadly it always have 1 element instead of the full content of my cart :(
$orderTotal = $details->PaymentDetails->OrderTotal;
$PaymentDetails= new PaymentDetailsType();
$PaymentDetails->OrderTotal = $orderTotal;
//
Some stuff with payment details
//
$DoECRequestDetails = new DoExpressCheckoutPaymentRequestDetailsType();
$DoECRequest = new DoExpressCheckoutPaymentRequestType();
$DoECRequest->DoExpressCheckoutPaymentRequestDetails = $DoECRequestDetails;
$DoECReq = new DoExpressCheckoutPaymentReq();
$DoECReq->DoExpressCheckoutPaymentRequest = $DoECRequest;
$DoECResponse = $paypalService->DoExpressCheckoutPayment($DoECReq);
Do i miss a step or call a bad function. Because i tried to print_r every variable i came across and the full content of my cart was nowhere to be found. I find this strange since the 'orderTotal' of the transaction match with my original cart. I could store my original order during the SetExpressCheckout step but since paypal already have those values i find it redundant.
As a last resort I did found the content of my cart using $paypalService->getLastRequest() but seriously this is the raw XML returned by paypal and the api should be parsing it properly :(.
Thanks for reading
I had this exact same issue - while the XML returned by PayPal is fine, their PHP SDK doesn't parse it properly, so you can only ever see the last item in GetExpressCheckout.
I've posted a fix for this problem in an issue on PayPal's GitHub, please check it out:
https://github.com/paypal/SDKs/issues/37