//第一步:通过定单号获得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 |