Magento coupon shows extremal discount - magento

I have a magento 1.7.0.2 install. I created a shopping price cart rule with coupon. Everything is fine except that the discount amount displayed in magento (cart, checkout,...) is an extremal value. I found out that extremal value is 2^64 (18 446 744 073 709 550 520). The configuration of the rule does not matter, the displayed discount is 2^64 always.
The subtotal is fine, the shipping is fine the sum of these is 11669. after applying the discount(10%) on the subtotal(10961) the result is 9864. 9864+708=10573 is an acceptable result. So Everything is perfect except the displayed discount.
I don't know where does it go wrong. I can't find the related file. Please help.
Thanks a lot,
István

After all I found the solution. The cause of this error is simple. The discount amount stored by magento is signed, that means it has a negative sign. The file app/design/frontend/[yourfrontend]/[yourtheme]/template/checkout/total/default.phtml ( this is where the amount is written on screen) contains the following code:
<tr>
<th colspan="<?php echo $this->getColspan(); ?>" style="<?php echo $this->getTotal()->getStyle() ?>" class="a-right">
<?php if ($this->getRenderingArea() == $this->getTotal()->getArea()): ?><strong><?php endif; ?>
<?php echo $this->escapeHtml($this->getTotal()->getTitle()); ?>
<?php if ($this->getRenderingArea() == $this->getTotal()->getArea()): ?></strong><?php endif; ?>
</th>
<td style="<?php echo $this->getTotal()->getStyle() ?>" class="a-right">
<?php if ($this->getRenderingArea() == $this->getTotal()->getArea()): ?><strong><?php endif; ?>
<?php echo $this->helper('checkout')->formatPrice($this->getTotal()->getValue()) ?>
<?php if ($this->getRenderingArea() == $this->getTotal()->getArea()): ?></strong><?php endif; ?>
</td>
The problem is the formatPrice() function, and the negative parameter. A simple solution is the abs() php function. Change the line
<?php echo $this->helper('checkout')->formatPrice($this->getTotal()->getValue()) ?>
to
<?php echo $this->helper('checkout')->formatPrice(abs($this->getTotal()->getValue())) ?>
And here we go, the problem solved.
I hope that helps.

Related

Configurable product is not showing out of stock items

We're running Magento 1.9.2.4
There are several simple products making up a few configurable products which we are wanting customers to be able to order if they are in stock or out of stock.
We're running custom themes and plugins, i've reverted back to RWD to ensure there are no template mistakes and disabled all of the plugins.
All options have been set globally, i've double checked the both the simple and configurable products to ensure that they are set with product levels and are in stock where applicable.
Cache has been cleared and all data has been re-indexed.
I've attached a screen shot of the settings.
https://www.dropbox.com/s/x96aqhh2h9b86ik/Screenshot%202017-02-14%2018.59.54.png?dl=0
I've read lots of threads and there appears to be a few people that have had this issue on different versions of Magento but none of the fixes appear to have worked.
I found the issue, the availability.phtm file needed updating to pull in another status.
There was an article I found online which helped, its not 100% right for 1.9.2.4 but got me most of the way there.
<?php $_product = $this->getProduct() ?>
<?php echo $this->getPriceHtml($_product) ?>
<?php $stockLevel = (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty(); ?>
<?php if($_product->isSaleable()<strong> && $stockLevel > 0</strong>): ?>
<p class="availability in-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('In stock') ?></span></p>
<?php elseif($_product->isSaleable() && $stockLevel <= 0): ?>
<p class="availability in-stock">
<?php echo $this->__('Availability:') ?> <span><?php echo $this->__('Available for Backorder') ?></span><br />
<?php echo $this->__('Please allow up to two weeks for delivery') ?>
</p>
<?php else: ?>
<p class="availability out-of-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
https://edmondscommerce.github.io/magento/ssssssssssssss.html

Google Sitemap grid not being filled/shown

On our Magento 1.6.2 website we have enabled Google Sitemaps and added some manually with updates through cron.
What happens now is that the page Catalog > Google Sitemap in it's filters tells us that 4 records were found.
But it doesn't show anything below the filters.
Through looking at the source code I've found that the div with class sitemapGrid only has a total height of 33px and the div with class grid that should display the sitemaps only has a total height of 7px, 6 of which are padding.
The sitemapGrid_table is 0px high, with a 1px border.
But no tr nor td.
After some more digging I've found that the file in which it all happens is design > adminhtml > default > default > template > widget > grid.phtml
The page runs till the end of the first foreach after "grid" and then stops.
<div class="grid">
<div class="hor-scroll">
<table cellspacing="0" class="data" id="<?php echo $this->getId() ?>_table">
<?php foreach ($this->getColumns() as $_column): ?>
<col <?php echo $_column->getHtmlProperty() ?> />
<?php endforeach; ?> <!-- Runs to here and then stops executing, but who knows why? -->
<?php if ($this->getHeadersVisibility() || $this->getFilterVisibility()): ?>
<thead>
<?php if ($this->getHeadersVisibility()): ?>
<tr class="headings">
<?php foreach ($this->getColumns() as $_column): ?>
<th<?php echo $_column->getHeaderHtmlProperty() ?>><span class="nobr"><?php echo $_column->getHeaderHtml() ?></span></th>
<?php endforeach; ?>
</tr>
<?php endif; ?>
<?php if ($this->getFilterVisibility()): ?>
<tr class="filter">
<?php $i=0;foreach ($this->getColumns() as $_column): ?>
<th<?php echo $_column->getHeaderHtmlProperty() ?>><?php echo $_column->getFilterHtml() ?></th>
<?php endforeach; ?>
</tr>
<?php endif ?>
</thead>
If I comment out the first foreach, the code keeps running till it ends the first foreach in "headings". And so on (comment out one, runs till end of next one, ...)
Anyone have any idea on where the problem really lies and/or a solution?
So,
Long story short:
exception.log wasn't being filled so once that was solved I got to see that Magento couldn't find a certain blocktype.
Solved an error in config.xml and it all works just fine.

Magento show discount in cart page even without applying a coupon

In cart page we can see the discount row only if a customer add a coupon code(?). What I want to do is adding the discount as zero for every cart page even there is not any coupon code applied.
What I see:
Total (Inc VAT) £42.00
Subtotal (net) £35.00
Subtotal (Inc VAT) £42.00
VAT £7.00
What I want:
Discount £0.00
Total (Inc VAT) £42.00
Subtotal (net) £35.00
Subtotal (Inc VAT) £42.00
VAT £7.00
This is my design/.../template/checkout/total/default.phtml file for viewing discount with coupon code:
<tr>
<td colspan="<?php echo $this->getColspan(); ?>" style="<?php echo $this->getTotal()->getStyle() ?>" class="a-right">
<?php if ($this->getRenderingArea() == $this->getTotal()->getArea()): ?><strong><?php endif; ?>
<?php echo $this->escapeHtml($this->getTotal()->getTitle()); ?>
<?php if ($this->getRenderingArea() == $this->getTotal()->getArea()): ?></strong><?php endif; ?>
</td>
<td style="<?php echo $this->getTotal()->getStyle() ?>" class="a-right">
<?php if ($this->getRenderingArea() == $this->getTotal()->getArea()): ?><strong><?php endif; ?>
<?php echo $this->helper('checkout')->formatPrice($this->getTotal()->getValue()) ?>
<?php if ($this->getRenderingArea() == $this->getTotal()->getArea()): ?></strong><?php endif; ?>
</td>
The problem I'm having is whenever cart page is loaded, this block won't load, unless there is coupon code applied, obviously. What I want to know is that is there any flag or controller for make the block appear even no coupon is applied so in above block I can check whether coupon is applied or not to customize the above view. Can you give me any suggestions?
PS: here coupons means shopping cart price rules.

Display only in stock options for configurable products on catalog pages in Magento

I've managed to add options to configurable products on my catalog pages using the code found here: http://www.magentocommerce.com/boards/viewthread/21039/P45/#t167724. What I'd like to do now is only show the options that are available according to the stock of the simple product that the option is coming from.
For example, if I have a t-shirt (configurable product) that has various colors (simple products) and my red color is out of stock, red wouldn't be shown as an option when the configurable product is displayed.
What's the best way to do this?
Update:
For the sake of clarity, here is the relevant block of code from the link I posted.
<?php if($product->getTypeId() == "configurable"): ?>
<?php $attValConfig = $product->getTypeInstance()->getConfigurableAttributesAsArray(); ?>
<?php if(sizeof($attValConfig)): ?>
<?php foreach($attValConfig as $attValConfigSingle): ?>
<fieldset class="product-options" id="product-options-wrapper">
<label><?php echo $attValConfigSingle['label']; ?>:</label>
<select name="super_attribute[<?php echo $attValConfigSingle['attribute_id'] ?>]" id="attribute<?php echo $_product->getId() ?>" class="required-entry super-attribute-select">
<?php foreach($attValConfigSingle['values'] as $attValConfigSingleVal): ?>
<option value="<?php echo $attValConfigSingleVal['value_index'] ?>"><?php echo $attValConfigSingleVal['label'] ?></option>
<?php endforeach; ?>
</select>
</fieldset>
<?php endforeach; ?>
<?php endif; ?>
<?php endif; ?>
Since this code is simply getting all of the configurable options and displaying them, it doesn't check to see if the simple product that backs the configurable option is in stock. How do I do this?
I just wondering why we are checking the quantity for stock status why dont't we look on stock availability of simple products.
I have achieved to show out of stock on configurable product according to stock status.
Now you can make product "out stock" and "in stock" through stock availability attribute of simple product.
Try the following ( do what you want returning result ) :
$_productCollection = Mage::getModel('cataloginventory/stock_item')->getCollection()
->addIdFilter($productId) // this line is wrong, don't care this
->addFieldToFilter('qty', array('gteq' => 1));

Magento: Adding current currency code infront of prices

I am wanting to show my prices in Magento with the current code in front of the price:
AUD $5.50
I can't seem to find a setting for this and I'm having trouble trying to find some code or a plugin to do this.
Any suggestions?
You can try free module Currency Manager
There is available currency symbol replace for every currency. Change "$" to "AUD $".
In app/design/frontend/YourInterface/YourTheme/template/catalog/product/price.phtml, find proper place(you should have many try :) )like this snippet code:
<span class="price-excluding-tax">
<span class="label"><?php echo $this->helper('tax')->__('Excl. Tax:') ?></span>
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php echo $_coreHelper->currency($_price+$_weeeTaxAmount,true,false) ?>
</span>
</span>
change
<?php echo $_coreHelper->currency($_price+$_weeeTaxAmount,true,false) ?>
to
<?php echo 'AUD '.$_coreHelper->currency($_price+$_weeeTaxAmount,true,false) ?>
This will add 'AUD ' to all of the prices.

Resources