having trouble getting the subtotal from the cart in magento? - magento

I am trying to get the subtotal from the cart using the code
<?php echo Mage::helper('checkout/cart')->getQuote()->getSubtotal(); ?>
It only works when i clean the cache, i don't know why. how to get the subtotal in a correct way? . Any help will be greatly appreciated.
Thank you in advance

$session= Mage::getSingleton('checkout/session');
$getotal = Mage::helper('checkout')->getQuote()->getGrandTotal();
//Total object
$totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals();
//Subtotal value
$subtotal = $totals["subtotal"]->getValue();
Use the above mentioned code you will surely get subtotal at the end.:-)

Related

Adding product reviews to the category page

I need to add product reviews to the list view of the category page, not just the summary rating. Need to add the “Detailed star rating”, “Summary of review”, “Nickname” and “Body of review”. Much the same as you would see it on the product review page.
I’ve had a look at the base Magento template file for the product review page app/design/frontend/base/default/review/product/view/list.phtml. There is an array $_items = $this->getReviewsCollection()->getItems(); that contains all the review info that I need.
However if I try to use $_items = $this->getReviewsCollection()->getItems(); in the category template file app/design/frontend/default/my_theme/template/catalog/product/list.phtml I get the following error
“Fatal error: Call to a member function getItems() on a non-object”.
How do I get past this error, or am I going about this the wrong way? Any advice or tips would be appreciated.
Hello you will use below code may be help you.
$entity_ids = array(22, 23);
$reviewcollection = Mage::getModel('review/review')->getCollection()
->addStoreFilter(Mage::app()->getStore()->getId())
->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
->addFieldToFilter('entity_id', Mage_Review_Model_Review::ENTITY_PRODUCT)
->addFieldToFilter('entity_pk_value', array('in' => $entity_ids))
->setDateOrder()
->addRateVotes();
$_items = $reviewcollection->getItems();

Magento Pre Order Product with Date attribute

I am new to Magento and maybe its a very basic question, but I want to display Pre-Order products on my home page. I have created an attribute Product_Release_Date and set it to a future date. When I try to get Product_Release_Date its returning blank. What I am doing wrong?
$_productCollection=$this->getLoadedProductCollection(); to get all products
foreach ($_productCollection as $_product):
<?php $currentDate = Mage::getModel('core/date')->date('Y-m-d H:i:s'); to get current date for compare
echo $_product->getResource()->getAttribute('Product_Release_Date');
When I try to display its showing blank, but it returns productName and other things. Only this date is not showing. Please help or provide some tutorial where it shows how to enable pre-order.
The $_product->getResource()->getAttribute('Product_Release_Date'); line is only loading the attribute collection. You can do this after to see what it contains: var_dump($_product->getResource()->getAttribute('Product_Release_Date'));. If it's NULL then make sure your new attribute is really set to Product_Release_Date and not product_release_date (lower-case).
You can use a "magic get" to retrieve the value, like this:
echo $_product->getProductReleaseDate();
Here is a fairly recent tutorial on how to enable display of out-of-stock items:
http://www.inmotionhosting.com/support/edu/magento/103-magento-products-and-inventory-settings/how-to-display-products-that-are-out-of-stock-in-magento
Its very likely the product attribute "Product_Release_Date" is not in the loaded product collection.
If you need to get it then load the products from Magento Product Resource Model
$productCollection = Mage::getResourceModel('catalog/product_collection')->addAttributeToSelect('*');
foreach($productCollection as $product):
echo '<br/>' . $product->getProductReleaseDate();
endforeach;

Magento get order shipping method title

Hi can anybody tell me how can i get after successfully order is placed shipping method title?
Here is what i have
$iOrderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$oOrder = Mage::getModel('sales/order')->loadByIncrementId($iOrderId);
echo $oOrder->getShippingMethod();
but how can i get this shipping method title?
$oOrder->getShippingDescription();
$order = Mage::getModel('sales/order')->loadByIncrementId($iOrderId);
$order->getShippingDescription();
Or
$shipping = $order->getShippingAddress()->getShippingMethod();
echo $shipping->getData('title');
This worked for me when looking for the custom title:
Mage::getModel('sales/order')->loadByIncrementId($orderId)->getTracksCollection()->getFirstItem()->getTitle();
$order->getShippingDescription(); // returns Shipping Method Title

Magento checkout success page: get some order information

I need some basic information on my Magento checkout success page to check some conversions through my shop. For that I need the total price of the order and all article IDs.
While searching I found a code to get the last order:
<?php
$_customerId = Mage::getSingleton('customer/session')->getCustomerId();
$lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId();
$order = Mage::getSingleton('sales/order');
$order->load($lastOrderId);
?>
But how can I get the total price and all article IDs (seperated by ,).
I'm quiet new to Magento, so everything is a bit confusing to me.
Can somebody help me?
Thank you.
Greetings from Germany,
Raisis
You can get order total by $order->getData('base_grand_total');
in order to get all articles (loop through) you need to do,
foreach($order->getAllItems() as $items) {
$items->getName();
}
Use this code to get order object and order total, it's cleaner
<?php
$order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId());
$total = $order->getGrandTotal();
?>

magento vat number pdf invoice

can anyone help me in placing the vat/tax number on the pdf invoice in Magento?
I tried this code but it didn't work:
$taxvat = $order->getData('customer_taxvat');
$page->drawText('Tax/Vat: '.$taxvat, 35, 567);
You can retrieve this by doing;
$order->getCustomerTaxvat()
If this value is empty you could try this;
$customer = Mage::getModel('customer/customer')->load($order->getData('customer_id'));
$taxVat = $customer->getData('taxvat');

Resources