打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Magento 通过订单号获取订单所有信息
Magento 通过订单号获取订单所有信息
//第一步:通过定单号获得Email
1
2
3
4
5
6
7
8
9
10
11
12
require_once("app/Mage.php");//先引用
$app = Mage::app('default');
$incrementID='C00012577';
$orders = Mage::getModel('sales/order')->getCollection();
$orders->addAttributeToFilter('increment_id',$incrementID); //其中 $incrementID为订单号
$orders->addAttributeToSelect('*');
$orders->load();
$alldata = $orders->getData();
$sales_order = Mage::getModel('sales/order')->load($alldata[0]['entity_id']);
$billingAddress=$sales_order->getBillingAddress();
$Email=$sales_order->getData('customer_email'); //客户的邮件
var_dump($Email);
//第二步 获取项目所有的数据
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
foreach ($sales_order->getAllItems() as $item) {
$option = $item->getProductOptions();
//print_r($option );
$qty = $item->getQtyOrdered();
if(count($option)>1){
if($version == '1.2.1.1'&& isset($option['attributes_info'][0]['value'])){
echo $size = $option['attributes_info'][0]['value'];
}
else{
echo $size = $option['options'][0]['value'];
}
}
else{
$size = "";
}
}
//第三步检查订单
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
$amount = $alldata[0]['base_discount_amount'];
$fee = $alldata[0]['base_fee_amount'];
$created_at = $alldata[0]['created_at'];
$shippingamount=$alldata[0]['base_shipping_amount'];
$grand_total=$alldata[0]['grand_total'];
$dv_oid = $alldata[0]['entity_id'];
if( $dv_oid=='' ) echo '定单号不存在';
if( $dv_oid && Mage::getSingleton( 'customer/session' )->isLoggedIn() ){
$dv_url = $this->getUrl('sales/order/view/').'order_id/'.$dv_oid.'/';
//die($dv_url);
echo '您已登录,正为您跳转..<br>';
echo 'redirect to '.$dv_url;
echo '<script type="text/javascript">location.href="'.$dv_url.'";</script>';
}
$sales_order = Mage::getModel('sales/order')->load($alldata[0]['entity_id']);
$billingAddress=$sales_order->getBillingAddress();
//print_r($billingAddress);
$shipping=$sales_order->getShippingDescription();//运送方式
$order = Mage::getModel ( 'sales/order' )->loadByIncrementId ($incrementID);//支付方式
$pay=Mage::helper('payment')->getInfoBlock($order->getPayment())->toHtml();
$status = $sales_order->getStatus();//订单状态
$state = $sales_order->getState();
$Email=$sales_order->getData('customer_email'); //客户的邮件
//第四步获取客人的更多信息的方法
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
echo $name = $item->getName(); //获取订单产品名
echo $price = $item->getPrice();//获取价格
echo $address= $item->getShippingAddress();//获取地址
echo $sku= $item->getSku();//获取sku
echo $FirstName=$billingAddress->getFirstname();
echo $LastName=$billingAddress->getLastname();
echo $Email=$sales_order->getData('customer_email');
echo $Phone=$billingAddress->getTelephone();
echo $ZipCode=$billingAddress->getPostcode();
echo $company=$billingAddress->getCompany();
echo $Address=$billingAddress->getStreetFull();
echo $City=$billingAddress->getCity();
echo $State=$billingAddress->getRegion();
echo $Country=$billingAddress->getCountry();
echo $option = $item->getProductOptions(); //获取option属性
echo $qty =   $item->getQtyOrdered(); //获取订单产品数量
echo $item->getRowTotal();//获取total
转载于:http://www.weicot.com/magento-%E9%80%9A%E8%BF%87%E8%AE%A2%E5%8D%95%E5%8F%B7%E8%8E%B7%E5%8F%96%E8%AE%A2%E5%8D%95%E6%89%80%E6%9C%89%E4%BF%A1%E6%81%AF/
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
外贸函电常用范文
SAP Cloud for Customer里Sales Order和Sales Quote的建模方式
ecshop后台管理增加商品成本价和毛利润统计功能
海猫原创|如何读懂亚马逊后台的业务报告(上)
SAP中的缩写
Oracle开发之:窗口函数 rows between unbounded preceding and current row
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服