Magento, my cart, subtotal - magento

My cart shows wrong subtotal and I think this is als oaffecting calculation of tax (20%)in the Shoppin Cart and in the Checkout (prices here are correct but Subtotal, and total, have no 20% Vat tax)
Any idea what could be the problem?
new user.. i can't post images

<?php
$subTotal = Mage::getModel('checkout/cart')->getQuote()->getSubtotal();
$totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals();?>
Total Items in Cart: <?php $totalItems = Mage::getModel('checkout/cart')->getQuote()->getItemsCount();
if($totalItems == 0){echo "0";}else{echo $totalItems;}?>
Subtotal: $ <strong><?php $subTotal = Mage::getModel('checkout/cart')->getQuote()->getSubtotal(); echo number_format($subTotal,2); ?>
<?php if(isset($totals['tax']) && $totals['tax']->getValue()) {
echo 'Tax: '.strip_tags(Mage::helper('core')->currency(number_format($totals['tax']->getValue(),2))); //Tax value if present
} ?>
<?php if(isset($totals['discount']) && $totals['discount']->getValue()) {
echo 'Discount: '.strip_tags(Mage::helper('core')->currency(number_format($totals['discount']->getValue(),2))); //Discount value if applied
} ?>
<?php if(isset($order->getShippingAmount)){
echo 'Shipping Charges:'.strip_tags(Mage::helper('core')->currency(number_format($order->getShippingAmount,2)));
}?>
Grand Total: $<?php $grandTotal = Mage::getModel('checkout/cart')->getQuote()->getGrandTotal(); echo number_format($grandTotal,2); ?>
Please use this code, it will be show all cart info.

Related

how to get checkout cart specific item totat price?

I have a custom html I want to implement this html into checkout cart page . I have implement it but i cant get cart item total price , eg. I have 5 item in cart . I have updated only one specific item in the cart then I don’t get these specific item total price .
default item $50 *1 =$50
After Update quantity
item price : $50 * 2 = ??(I want to get total of this specific item ).
Thanks
You can calculate the price as:
<?php
$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
foreach($items as $item) {
$qty = $item->getQty();
$price = $item->getPrice();
$totalPrice = $qty * $price;
}
?>
To get cart item specific details, you can use :
$quote = Mage::getSingleton('checkout/session')->getQuote();
foreach ($quote->getAllItems() as $item){
$qty = $item->getQty() ;
$price = $item->getPrice();
$totalPrice = $qty * $price;
}
i am using default magento functionality to get specific item price in magento chekout cart page
<?php if ($canApplyMsrp): ?>
<span class="cart-msrp-subtotal">--</span>
<?php else: ?>
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<?php echo $this->helper('checkout')->formatPrice($_item->getRowTotal() + $_item->getWeeeTaxAppliedRowAmount() + $_item->getWeeeTaxRowDisposition()); ?>
<?php else: ?>
<?php echo $this->helper('checkout')->formatPrice($_item->getRowTotal()) ?>
<?php endif; ?>
<?php endif; ?>

Show the stock for configurable Products MAGENTO

Im trying to show on the frontend the stock when we have less than 5 products.
For simple products is easy but when we are talking about configurable products it is not working.
This is the code I tried but is not working, the var $product is coming empty so I am always getting a 0 in $total_qty
Here is the code that I am using:
$product=Mage::getModel("catalog/product");
$prod=$product->load($prod_id);
$conf = Mage::getModel('catalog/product_type_configurable')->setProduct($prod);
$col = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
$total_qty=0;
foreach($col as $sprod)
{
$sprod=$product->load($sprod->getId());
$qty = intval(Mage::getModel('cataloginventory/stock_item')->loadByProduct($sprod)->getQty());
$total_qty+=$qty;
}
?>
---
<p class="availability in-stock">
<?php //echo $this->__('Availability:') ?> <span>
<?php
if (($__manStock >= 1) && ($__manStock < 5))
{
echo $this->__("¡ JUST $total_qty LEFT !");
}
?>
</span></p>
Any help will be appreciated, thanks.
Configurable Products don't have stock. The simple products do.
You will have to query the associated products.
You can get the associated products using getAllowProducts()

Magento Retail Store and Wholesale with Different Prices

Hey I was wondering about magento Retail/Wholesale capabilities.
The main store will be for normal customers (retail) and they see normal prices but for wholesalers they need to login and see wholesale prices?
I don't want normal visitors to see wholesale prices.
Is that possible?
Assign product price as customer groups after that use this code on list or view page, you will see product different price on both side same and equal to admin price.
<?php $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
if($groupId ==1 || $groupId ==""){?>
<?php if($product->getSpecialPrice()){?>
<?php echo "$".$rprice = number_format($product->getPrice(),2); ?> </div>
<?php }else{?>
<?php $product->setCustomerGroupId($groupId);
echo "$".$price = number_format($product->getPriceModel()->getFinalPrice(1, $product),2); ?>
<?php } ?>
</div>
<?php if($product->getSpecialPrice()){ echo "Special Price $".number_format($product->getSpecialPrice(),2);?>
<?php } ?>
<?php }else{echo "$".$price = number_format($product->getPriceModel()->getFinalPrice(1, $product),2); }
?>
for create customer group check this link:
http://www.magentocommerce.com/knowledge-base/entry/customer-groups

Cart page content, display product individual according to quantity

if i add product with quantity two then in cart contect there is only one product with 2 quantity display. but i want to display separate rows of same product according to quantity.
like cart contect should be as below.
product name Qty price
ABC 1 $10
ABC 1 $10
Finally i got solution. Here is an answer
open this file \app\code\core\Mage\Sales\Model\Quote.php and search for "_addCatalogProduct" function
and replace
$item = $this->getItemByProduct($product);
if (!$item) {
$item = Mage::getModel('sales/quote_item');
$item->setQuote($this);
if (Mage::app()->getStore()->isAdmin()) {
$item->setStoreId($this->getStore()->getId());
}
else {
$item->setStoreId(Mage::app()->getStore()->getId());
}
$newItem = true;
}
to with commenting code.
// $item = $this->getItemByProduct($product);
//if (!$item) {
$item = Mage::getModel('sales/quote_item');
$item->setQuote($this);
if (Mage::app()->getStore()->isAdmin()) {
$item->setStoreId($this->getStore()->getId());
}
else {
$item->setStoreId(Mage::app()->getStore()->getId());
}
$newItem = true;
// }
and in \app\code\core\Mage\Checkout\controllers\CartController.php
replace
$cart->addProduct($product, $params);
to
if($params['qty'] == 0 || $params['qty'] == '')
{
$params['qty'] = 1;
}
$quantity = $params['qty'];
for($loop=1; $loop<=$quantity; $loop++)
{
$params['qty'] = 1;
$cart->addProduct($product, $params);
}
If you really must do this then you could try creating an observer for the event sales_order_place_before and then in your observer you could modify the quote by looping through it and finding multiple qty items, change the qty back to 1 and then add the remainder of items as quote items to the quote object. Not sure if Magento will group them together again during/after the order is placed. You could maybe do the same thing using the event sales_quote_product_add_after which might be better as the user will see the individual lines on the cart page, but again, don't know if Magento will group the qty's back together during the checkout process without actually having a go at making it work. If it does, you could maybe try setting the product to be a super product and override the sku so it has a unique identifer tagged on (e.g. SKU100-1, SKU100-2 etc) before you add it to the quote.
What about this:
Replace this
<?php foreach($this->getItems() as $_item): ?>
<?php echo $this->getItemHtml($_item) ?>
<?php endforeach ?>
with that on line 130 default theme /app/design/frontend/yourtheme/default/template/checkout/cart.phtml
<?php foreach($this->getItems() as $_item): ?>
<?php $qty = $_item->getQty() ?>
<?php for($i=0; $i < $qty; $i++) : ?>
<?php $_item->setQty(1); ?>
<?php echo $this->getItemHtml($_item); ?>
<?php endfor; ?>
<?php endforeach ?>

How can I get product min sale quantity on product list view?

When I tried following code, it will just print empty string. How can I get product min sale quantity on this page?
catalog/product/list.phtml
<?php echo $_product->getStockItem()->getMinSaleQty(); ?>
This code solved my problem, because I use quantity increments:
$productData = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);
$qtyIncrements = $productData->getQtyIncrements();
$_stock_data = $product->getStockItem()->getData();
$_qtde_min = (intval($_stock_data['min_sale_qty'])) ? intval($_stock_data['min_sale_qty']) : 1;
<?php $loadProduct = Mage::getModel('catalog/product')->load( $_product->getId() ); ?>
<label for="qty"><?php echo $this->__('Minimum Quantity:') ?><span class="h1">
<?php echo $this->getMinimalQty($loadProduct); ?></span>Piece/s </label>
This code is Working 100% OK!

Resources