Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php $order = Mage::getModel('sales/order')->loadByIncrementId($order);
- $items = $order->getAllItems();
- //$items = $order->getItemsCollection();
- $itemcount=count($items);
- $name=array();
- $unitPrice=array();
- $sku=array();
- $ids=array();
- $qty=array();
- /*if (Mage::getSingleton('customer/session')->isLoggedIn()) {
- $customerData = Mage::getSingleton('customer/session')->getCustomer();
- $mydatas['email'] = $customerData->getEmail();
- $mydatas['vatid'] = $customerData->getTaxvat();
- $customerAddressId = Mage::getSingleton('customer/session')->getCustomer()->getDefaultBilling(); //oder getDefaultShipping
- if ($customerAddressId) {
- $address = Mage::getModel('customer/address')->load($customerAddressId);
- echo $mydatas['name'] = $address->getFirstname();
- echo $mydatas['lastname']=$address->getLastname();
- echo $mydatas['company'] = $address->getCompany();
- echo $mydatas['email'] = $address->getEmail();
- echo $mydatas['zip'] = $address->getPostcode();
- echo $mydatas['city'] = $address->getCity();
- echo $street = $address->getStreet();
- echo $mydatas['street'] = $street[0];
- echo $mydatas['telephone'] = $address->getTelephone();
- $mydatas['fax'] = $address->getFax();
- echo $mydatas['country'] = $address->getCountry();
- }
- } */
- if (Mage::getSingleton('customer/session')->isLoggedIn()) {
- $customerData = Mage::getSingleton('customer/session')->getCustomer();
- $customerAddressId = Mage::getSingleton('customer/session')->getCustomer()->getDefaultBilling(); //oder getDefaultShipping
- if ($customerAddressId) {
- $address_billing = Mage::getModel('customer/address')->load($customerAddressId);
- }
- $customerAddressId_shipping = Mage::getSingleton('customer/session')->getCustomer()->getDefaultShipping();
- if ($customerAddressId_shipping) {
- $address_shipping = Mage::getModel('customer/address')->load($customerAddressId_shipping);
- }
- }
- $output="";
- foreach ($items as $itemId => $item)
- //foreach ($items as $item)
- { //start billing address variable
- echo "Order Date".$order_date=$item->getCreatedAt();
- echo "<br>";
- echo "first name".$bfirst_name=$order->getBillingAddress()->getFirstname();
- echo "<br>";
- echo "last name".$blast_name=$order->getBillingAddress()->getLastname();
- echo "<br>";
- //company
- $billingAddress = $order->getBillingAddress();
- echo "company".$bcompany_name=$billingAddress->getCompany();
- echo "<br>";
- echo "email".$bemail_name=$order->getBillingAddress()->getEmail();
- echo "<br>";
- $billingAddress = $order->getBillingAddress();
- echo "BillingAddr1".$baddress1_name=$billingAddress->getStreet(1);
- echo "<br>";
- echo "BillingAddr2".$baddress2_name=$billingAddress->getStreet(2);
- echo "<br>";
- echo "telephone".$btelephone_name=$order->getBillingAddress()->getTelephone();
- echo "<br>";
- //fax
- echo "fax".$bfax_name=$billingAddress->getFax();
- echo "<br>";
- echo "city".$bcity_name=$order->getBillingAddress()->getCity();
- echo "<br>";
- $billingAddress = $order->getBillingAddress();
- echo "state".$bstate_name=$billingAddress->getRegion();
- echo "<br>";
- $countryId =$address_billing->getCountry();
- echo "Country".$bcountry_name=Mage::app()->getLocale()->getCountryTranslation($countryId);
- echo "<br>";
- echo "zip".$bzip_name=$order->getBillingAddress()->getPostcode();
- echo "<br>";
- echo "confirmzip".$bconfirmzip_name=$order->getBillingAddress()->getPostcode();
- echo "<br>";
- //end billing address variable
- //start shipping address variable
- echo "Order Date".$sorder_date=$item->getCreatedAt();
- echo "<br>";
- echo "first name".$sfirst_name=$order->getShippingAddress()->getFirstname();
- echo "<br>";
- echo "last name".$slast_name=$order->getShippingAddress()->getLastname();
- echo "<br>";
- $ShippingAddress = $order->getShippingAddress();
- echo "company".$scompany_name=$ShippingAddress->getCompany();
- echo "<br>";
- echo "email".$semail_name=$order->getBillingAddress()->getEmail();
- echo "<br>";
- //
- $ShippingAddress = $order->getShippingAddress();
- echo "ShippingAddress".$saddress1_name=$ShippingAddress->getStreet(1);
- echo "<br>";
- echo "ShippingAddress".$saddress2_name=$billingAddress->getStreet(2);
- echo "<br>";
- echo "telephone".$stelephone_name=$order->getShippingAddress()->getTelephone();
- echo "<br>";
- //fax
- echo "fax".$sfax_name=$ShippingAddress->getFax();
- echo "<br>";
- echo "city".$scity_name=$order->getShippingAddress()->getCity();
- echo "<br>";
- $billingAddress = $order->getShippingAddress();
- echo "state".$sstate_name=$billingAddress->getRegion();
- echo "<br>";
- // $address_shipping=$address_shipping->getCountry();
- $address_shipping =$address_billing->getCountry();
- echo "country".$scountry_name=Mage::app()->getLocale()->getCountryTranslation($address_shipping);
- echo "<br>";
- echo "zip".$szip_name=$order->getShippingAddress()->getPostcode();
- echo "<br>";
- echo "confirmzip".$sconzip_name=$order->getBillingAddress()->getPostcode();
- echo "<br>";
- echo "payment method" .$spayment = $order->getPayment()->getMethodInstance()->getTitle();
- echo "<br>";
- echo "shiping method".$shipping = $order->getShippingDescription();
- echo "<br>";
- //echo "product name".$itemname = $item->getName();
- $item_name[]=$item->getName();
- //$output.=explode(', ',$output);
- //$output.=$item->getName().PHP_EOL;
- //$output.=implode(PHP_EOL,$output);
- echo "<br>";
- //echo "sku".$sku=$item->getSku();
- $skucode[]=$item->getSku();
- echo "<br>";
- $product=Mage::getModel('catalog/product')->load($item->getProductId());
- //echo "quantity".$qtyw+= $item->getQtyOrdered();
- //echo "quantity".$qty= $item->getQtyOrdered();
- $item_qty[]= $item->getQtyOrdered();
- //echo $qty=$qtyw;
- //echo "quantity".$itemcount;
- //$qty=$itemcount;
- echo "<br>";
- //echo "sale price".$product_orignalprices=$product->getPrice() * $qty;
- $sale_price[]=$product->getPrice();
- //end shipping address variable
- echo "<br>";
- // draw MRP
- //$product=Mage::getModel('catalog/product')->load($item->getProductId());
- $mrp=$product->getData('mrp_price');
- if(!empty($mrp))
- {
- //echo "Mrp".$mrp;
- $mrps[]=$mrp;
- }
- else{
- //echo "Mrp"."0";
- $mrps[]=0;
- }
- echo "<br>";
- //discount
- $taxall=$item->getTaxAmount();
- $qty= $item->getQtyOrdered();
- $discountedprice = $item->getPriceInclTax() * $qty;
- $product_orignalprices=$product->getPrice() * $qty;
- $finaltot= $product_orignalprices - $discountedprice;
- $todatlsaving= round( $finaltot, 0, PHP_ROUND_HALF_UP);
- //echo "discount".$finaltot=money_format("%i",$todatlsaving);
- $finaltot_saving[]=money_format("%i",$todatlsaving);
- echo "<br>";
- //excluding vat
- echo "excluding vat".$excludingvat[]=$item->getPrice();
- echo "<br>";
- //VatAmt
- echo "VatAmt".$VatAmt[]=$order->formatPriceTxt($item->getTaxAmount());
- echo "<br>";
- // Vat %
- $store = Mage::app()->getStore('default');
- $taxCalculation = Mage::getModel('tax/calculation');
- $request = $taxCalculation->getRateRequest(null, null, null, $store);
- $taxClassId = $product->getTaxClassId();
- echo "vat %".$vatpercent[] = $taxCalculation->getRate($request->setProductClassId($taxClassId));
- echo "<br>";
- echo "gross pay".$gross_pay[]=$item->getRowTotalInclTax();
- echo "<br>";
- echo "subtotal".$subtotaleach[]=$item->getPrice() * $qty;
- echo "<br>";
- echo "taxes".$taxes[]=$order->formatPriceTxt($item->getTaxAmount());
- /**/
- /*
- echo "sub total".$subtotal=$item->getPrice() * $qty ;
- echo "<br>";
- echo "tax".$taxall=$item->getTaxAmount();
- echo "<br>";
- $shiping_amount=$order->getShippingAmount();
- $sub_total=$item->getPrice() * $qty;
- $net_pay=$shiping_amount + $sub_total + $taxall;
- echo "Net payble".round( $net_pay, 0, PHP_ROUND_HALF_UP);
- */
- echo "shiping amount".$shipingamount=$order->getShippingAmount();
- }
- //echo $output;
- // $output= str_replace(' ', ',', $output);
- //$arr = array();
- //$arr=$output;
- echo $item_name=implode(',', $item_name);
- echo "<br>";
- echo $skucode=implode(',', $skucode);
- echo "<br>";
- echo $sale_price=implode(',', $sale_price);
- echo "<br>";
- echo $item_qty=implode(',', $item_qty);
- echo "<br>";
- echo $mrps=implode(',', $mrps);
- echo "<br>";
- echo "saving discount".$finaltot_saving=implode(',',$finaltot_saving);
- echo "<br>";
- echo "excludingvat".$excludingvat=implode(',',$excludingvat);
- echo "<br>";
- echo "vatamount".$VatAmt=implode(',',$VatAmt);
- echo"<br>";
- echo "vatpercent".$vatpercent=implode(',',$vatpercent);
- echo "<br>";
- echo "gross pay".$gross_pay=implode(',',$gross_pay);
- echo "<br>";
- echo "subtotal each".$subtotaleach= implode(',',$subtotaleach);
- echo "<br>";
- echo "taxes".$taxes=implode(',',$taxes);
- //echo "shiping amount".$shipingamount=$product->getShippingAmount();
- /*
- echo "<br>";
- echo "Incl. applicable Taxes:".$order->getBaseTaxAmount();
- echo "<br>";
- echo "sub total".$order->getSubtotal();
- echo "<br>";
- echo "Net payble".$order->getBaseGrandTotal();
- */
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement