第一步:require_once(“/var/www/dressesonlinesalecouk/app/Mage.php”);先引用
$app =Mage::app(‘default’);
$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’);//客户的邮件
foreach($sales_order->getAllItems() as $item) {
$option =$item->getProductOptions();
$qty=
if(count($option)>1){
if($version ==’1.2.1.1′&&isset($option['attributes_info'][0]['value'])){
$size =$option['attributes_info'][0]['value'];
}
else{
$size =$option['options'][0]['value'];
}
}else{
$size = “”;
}
循环输出产品信息,,用print_r($option)来打印所有的option属性
$item->getName()//获取订单产品名
$option =$item->getProductOptions(); //获取option属性
$qty=
$item->getPrice();//获取订单金额
$item->getRowTotal();//获取total
$item->getSku()获得sku
下面是客户的各种信息
$FirstName=$billingAddress->getFirstname();
$LastName=$billingAddress->getLastname();
$Email=$sales_order->getData(‘customer_email’);
$Phone=$billingAddress->getTelephone();
$ZipCode=$billingAddress->getPostcode();
$company=$billingAddress->getCompany();
$Address=$billingAddress->getStreetFull();
$City=$billingAddress->getCity();
$State=$billingAddress->getRegion();
$Country=$billingAddress->getCountry();
$adress_info .=$Email.”~”.$FirstName.”~”.$LastName.”~”.$company.”~”.$Address.”~”.$City.”~”.$State.”~”.$ZipCode.”~”.$Country.”~”.$Phone.”~”;
echo $adress_info;