Advertisement
sanjaynakate

code

Sep 16th, 2015
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.23 KB | None | 0 0
  1. <?php $order = Mage::getModel('sales/order')->loadByIncrementId($order);
  2.    
  3. $items = $order->getAllItems();
  4. //$items = $order->getItemsCollection();
  5. $itemcount=count($items);
  6. $name=array();
  7. $unitPrice=array();
  8. $sku=array();
  9. $ids=array();
  10. $qty=array();
  11.  
  12.  
  13. /*if (Mage::getSingleton('customer/session')->isLoggedIn()) {
  14. $customerData = Mage::getSingleton('customer/session')->getCustomer();
  15. $mydatas['email'] = $customerData->getEmail();
  16. $mydatas['vatid'] = $customerData->getTaxvat();
  17.  
  18. $customerAddressId = Mage::getSingleton('customer/session')->getCustomer()->getDefaultBilling(); //oder getDefaultShipping
  19. if ($customerAddressId) {
  20.      $address = Mage::getModel('customer/address')->load($customerAddressId);
  21.     echo $mydatas['name'] = $address->getFirstname();
  22.        echo $mydatas['lastname']=$address->getLastname();
  23.    echo $mydatas['company'] = $address->getCompany();
  24.      echo $mydatas['email'] = $address->getEmail();
  25.     echo $mydatas['zip'] = $address->getPostcode();
  26.     echo $mydatas['city'] = $address->getCity();
  27.     echo $street = $address->getStreet();
  28.     echo $mydatas['street'] = $street[0];
  29.     echo $mydatas['telephone'] = $address->getTelephone();
  30.      $mydatas['fax'] = $address->getFax();
  31.  
  32.     echo $mydatas['country'] = $address->getCountry();
  33. }
  34.  
  35. } */
  36.  
  37. if (Mage::getSingleton('customer/session')->isLoggedIn()) {
  38. $customerData = Mage::getSingleton('customer/session')->getCustomer();
  39. $customerAddressId = Mage::getSingleton('customer/session')->getCustomer()->getDefaultBilling(); //oder getDefaultShipping
  40. if ($customerAddressId) {
  41.      $address_billing = Mage::getModel('customer/address')->load($customerAddressId);  
  42. }
  43. $customerAddressId_shipping = Mage::getSingleton('customer/session')->getCustomer()->getDefaultShipping();
  44. if ($customerAddressId_shipping) {
  45.      $address_shipping = Mage::getModel('customer/address')->load($customerAddressId_shipping);
  46. }
  47. }
  48. $output="";
  49. foreach ($items as $itemId => $item)
  50.  
  51. //foreach ($items as $item)
  52. {   //start billing address variable
  53.     echo "Order Date".$order_date=$item->getCreatedAt();
  54.      echo "<br>";  
  55.     echo "first name".$bfirst_name=$order->getBillingAddress()->getFirstname();
  56.     echo "<br>";    
  57.     echo "last name".$blast_name=$order->getBillingAddress()->getLastname();
  58.          echo "<br>";  
  59.     //company
  60.     $billingAddress = $order->getBillingAddress();
  61.     echo "company".$bcompany_name=$billingAddress->getCompany();
  62.          echo "<br>";  
  63.     echo "email".$bemail_name=$order->getBillingAddress()->getEmail();
  64.          echo "<br>";  
  65.     $billingAddress = $order->getBillingAddress();
  66.     echo "BillingAddr1".$baddress1_name=$billingAddress->getStreet(1);
  67.          echo "<br>";  
  68.     echo "BillingAddr2".$baddress2_name=$billingAddress->getStreet(2);
  69.      echo "<br>";  
  70.    
  71.    
  72.     echo "telephone".$btelephone_name=$order->getBillingAddress()->getTelephone();
  73.          echo "<br>";  
  74.     //fax
  75.    
  76.     echo "fax".$bfax_name=$billingAddress->getFax();
  77.          echo "<br>";  
  78.     echo "city".$bcity_name=$order->getBillingAddress()->getCity();
  79.          echo "<br>";  
  80.     $billingAddress = $order->getBillingAddress();
  81.     echo "state".$bstate_name=$billingAddress->getRegion();
  82.    
  83.          echo "<br>";  
  84.    
  85.       $countryId =$address_billing->getCountry();
  86.     echo "Country".$bcountry_name=Mage::app()->getLocale()->getCountryTranslation($countryId);
  87.          echo "<br>";  
  88.        
  89.          
  90.     echo "zip".$bzip_name=$order->getBillingAddress()->getPostcode();
  91.          echo "<br>";  
  92.     echo "confirmzip".$bconfirmzip_name=$order->getBillingAddress()->getPostcode();
  93.          echo "<br>";  
  94.    
  95.     //end billing address variable
  96.    
  97.    
  98.    
  99.     //start shipping address variable
  100.    
  101.     echo "Order Date".$sorder_date=$item->getCreatedAt();
  102.          echo "<br>";  
  103.     echo "first name".$sfirst_name=$order->getShippingAddress()->getFirstname();
  104.          echo "<br>";  
  105.     echo "last name".$slast_name=$order->getShippingAddress()->getLastname();
  106.          echo "<br>";  
  107.         $ShippingAddress = $order->getShippingAddress();
  108.     echo "company".$scompany_name=$ShippingAddress->getCompany();
  109.          echo "<br>";  
  110.    
  111.     echo "email".$semail_name=$order->getBillingAddress()->getEmail();
  112.          echo "<br>";  
  113.     //
  114.     $ShippingAddress = $order->getShippingAddress();
  115.     echo "ShippingAddress".$saddress1_name=$ShippingAddress->getStreet(1);
  116.          echo "<br>";  
  117.     echo "ShippingAddress".$saddress2_name=$billingAddress->getStreet(2);
  118.          echo "<br>";  
  119.    
  120.     echo "telephone".$stelephone_name=$order->getShippingAddress()->getTelephone();
  121.          echo "<br>";  
  122.     //fax
  123.     echo "fax".$sfax_name=$ShippingAddress->getFax();
  124.          echo "<br>";  
  125.     echo "city".$scity_name=$order->getShippingAddress()->getCity();
  126.          echo "<br>";  
  127.     $billingAddress = $order->getShippingAddress();
  128.     echo "state".$sstate_name=$billingAddress->getRegion();
  129.          echo "<br>";  
  130.    
  131. // $address_shipping=$address_shipping->getCountry();
  132.   $address_shipping =$address_billing->getCountry();
  133.         echo "country".$scountry_name=Mage::app()->getLocale()->getCountryTranslation($address_shipping);
  134.              echo "<br>";  
  135.     echo "zip".$szip_name=$order->getShippingAddress()->getPostcode();
  136.          echo "<br>";  
  137.     echo "confirmzip".$sconzip_name=$order->getBillingAddress()->getPostcode();
  138.          echo "<br>";  
  139.    
  140.     echo "payment method" .$spayment = $order->getPayment()->getMethodInstance()->getTitle();
  141.          echo "<br>";  
  142.    
  143.     echo "shiping method".$shipping = $order->getShippingDescription();
  144.          echo "<br>";  
  145.  
  146.     //echo "product name".$itemname = $item->getName();
  147.    
  148.     $item_name[]=$item->getName();
  149.     //$output.=explode(', ',$output);
  150.     //$output.=$item->getName().PHP_EOL;
  151.     //$output.=implode(PHP_EOL,$output);
  152.    
  153.          echo "<br>";  
  154.      
  155.     //echo "sku".$sku=$item->getSku();
  156.    
  157.     $skucode[]=$item->getSku();
  158.          echo "<br>";  
  159.    
  160.      $product=Mage::getModel('catalog/product')->load($item->getProductId());
  161.     //echo "quantity".$qtyw+= $item->getQtyOrdered();
  162.     //echo "quantity".$qty= $item->getQtyOrdered();
  163.     $item_qty[]= $item->getQtyOrdered();
  164.     //echo $qty=$qtyw;
  165.     //echo "quantity".$itemcount;
  166.     //$qty=$itemcount;
  167.          echo "<br>";  
  168.      //echo "sale price".$product_orignalprices=$product->getPrice() * $qty;
  169.      $sale_price[]=$product->getPrice();
  170.     //end shipping address variable
  171.      echo "<br>";  
  172.     // draw MRP
  173.           //$product=Mage::getModel('catalog/product')->load($item->getProductId());
  174.          $mrp=$product->getData('mrp_price');
  175.          if(!empty($mrp))
  176.          {
  177.         //echo "Mrp".$mrp;
  178.         $mrps[]=$mrp;
  179.          }
  180.          else{
  181.              
  182.         //echo "Mrp"."0";
  183.         $mrps[]=0;
  184.              
  185.          }
  186.              echo "<br>";
  187.          //discount
  188.          
  189.         $taxall=$item->getTaxAmount();
  190.         $qty= $item->getQtyOrdered();
  191.           $discountedprice = $item->getPriceInclTax() * $qty;
  192.        
  193.          
  194.                             $product_orignalprices=$product->getPrice() * $qty;
  195.                            
  196.                            $finaltot= $product_orignalprices - $discountedprice;
  197.                             $todatlsaving= round( $finaltot, 0, PHP_ROUND_HALF_UP);
  198.                             //echo "discount".$finaltot=money_format("%i",$todatlsaving);
  199.                             $finaltot_saving[]=money_format("%i",$todatlsaving);
  200.                                  echo "<br>";
  201.  
  202.                                  
  203.     //excluding vat
  204.     echo "excluding vat".$excludingvat[]=$item->getPrice();
  205.          echo "<br>";  
  206.     //VatAmt
  207.     echo "VatAmt".$VatAmt[]=$order->formatPriceTxt($item->getTaxAmount());
  208.          echo "<br>";  
  209.    
  210.     // Vat %
  211.     $store = Mage::app()->getStore('default');
  212. $taxCalculation = Mage::getModel('tax/calculation');
  213. $request = $taxCalculation->getRateRequest(null, null, null, $store);
  214. $taxClassId = $product->getTaxClassId();
  215. echo "vat %".$vatpercent[] = $taxCalculation->getRate($request->setProductClassId($taxClassId));
  216.          echo "<br>";  
  217.          
  218.          echo "gross pay".$gross_pay[]=$item->getRowTotalInclTax();
  219.          echo "<br>";
  220.          echo "subtotal".$subtotaleach[]=$item->getPrice() * $qty;
  221.          echo "<br>";
  222.          echo "taxes".$taxes[]=$order->formatPriceTxt($item->getTaxAmount());
  223.     /**/
  224.    
  225.    
  226.     /* 
  227.     echo "sub total".$subtotal=$item->getPrice() * $qty  ;
  228.      echo "<br>";  
  229.     echo "tax".$taxall=$item->getTaxAmount();
  230.      echo "<br>";  
  231.     $shiping_amount=$order->getShippingAmount();
  232.     $sub_total=$item->getPrice() * $qty;
  233.     $net_pay=$shiping_amount + $sub_total + $taxall;
  234.     echo "Net payble".round( $net_pay, 0, PHP_ROUND_HALF_UP);
  235.            
  236.     */
  237. echo "shiping amount".$shipingamount=$order->getShippingAmount();
  238.  
  239. }
  240.  
  241.  //echo $output;
  242. // $output= str_replace(' ', ',', $output);
  243. //$arr = array();
  244. //$arr=$output;
  245.  echo $item_name=implode(',', $item_name);
  246.  echo "<br>";
  247.  echo $skucode=implode(',', $skucode);
  248.   echo "<br>";  
  249.   echo $sale_price=implode(',', $sale_price);
  250.     echo "<br>";
  251.      echo $item_qty=implode(',', $item_qty);
  252.      echo "<br>";
  253.      echo $mrps=implode(',', $mrps);
  254.      echo "<br>";
  255.      echo "saving discount".$finaltot_saving=implode(',',$finaltot_saving);
  256.     echo "<br>";
  257.      echo "excludingvat".$excludingvat=implode(',',$excludingvat);
  258.     echo "<br>";
  259.     echo "vatamount".$VatAmt=implode(',',$VatAmt);
  260.    
  261.     echo"<br>";
  262.     echo "vatpercent".$vatpercent=implode(',',$vatpercent);
  263.    
  264.      echo "<br>";
  265. echo "gross pay".$gross_pay=implode(',',$gross_pay);
  266.  
  267. echo "<br>";
  268.  
  269. echo "subtotal each".$subtotaleach= implode(',',$subtotaleach);
  270.  
  271. echo "<br>";
  272. echo "taxes".$taxes=implode(',',$taxes);
  273.  
  274.  
  275.      
  276. //echo "shiping amount".$shipingamount=$product->getShippingAmount();
  277.         /*
  278.          echo "<br>";  
  279.          echo "Incl. applicable Taxes:".$order->getBaseTaxAmount();
  280.          echo "<br>";
  281.           echo "sub total".$order->getSubtotal();
  282.          echo "<br>";  
  283.          echo "Net payble".$order->getBaseGrandTotal();
  284. */
  285.  
  286.  
  287.  
  288.     ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement