I'll get straight to the point. What is going on here, is I have a webstore, that has an inventory system sync'ed up with it. The issue at hand, is that we get backordered a lot, or have preorders. In the system, it will go to zero or negative numbers all the time, but we still want them to be able to order them.. just not necessarily see that we are -100 of such and such an item.
I currently have;
<?php if ($_product->isAvailable()): ?>
<p class="availability in-stock"><?php echo $this->__('Availability:') ?> <?= (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()?> <span><?php echo $this->__('in stock') ?></span></p>
<?php else: ?>
<p class="availability out-of-stock"><?php echo $this->__('Availability: ') ?> <span><? php echo $this->__('Call for Availability') ?></span></p>
<?php endif; ?>
This currently will show the inventory at whatever number it is, be it plus, minus, or at zero, which makes sense since there is no conversion to send it to out of stock if the number is =< 0. I am just not sure how I would go about mocking that up. So I come to you geniuses! Thanks for any and all help!
Configuration => Catalog => Inventory:
Display Out of Stock Products => Yes
Manage Stock => No
This should allow to sell products without managing remained products in stocks
Otherwise just replace with
<?php if ($_product->isAvailable()): ?>
<p class="availability in-stock"><?php echo $this->__('Availability:') ?>
<span>
<?php
$qty = (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty();
if ($qty<=0){echo $this->__('Call for Availability');}
else {echo $qty;} ?>
</span>
</p>
<?php else: ?>
<p class="availability out-of-stock"><?php echo $this->__('Availability:') ?> <span><? php echo $this->__('Call for Availability') ?></span></p>
<?php endif; ?>
Related
I have created a new attribute with scope Global and input type Text field called "out_of_stock_delivery". This allows me to enter a custom text when the product is Out Of Stock and override the default one. The problem I have is that if I enter a text string from the backend it does not print anything. It only prints numbers or numbers followed by text!?.
The code I have modified is the following:
<?php If ($_product->getData('out_of_stock_delivery') == 0){?>
<p class="availability out-of-stock"><?php echo $this-
>__('Availability:') ?> <span><?php echo $this->__('Out of stock')."
- Call us for availability." ?></span></p>
<?php }
else { ?>
<p class="availability out-of-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('Out of stock')." - We deliver this product in ".$_product->getData('out_of_stock_delivery')." days." ?></span></p>
<?php } ?>
Why $_product->getData('out_of_stock_delivery') can only echo a number if the input type is text? Any pointers much appreciated.
I made a mistake in the If statement. I should have written:
($_product->getData('out_of_stock_delivery') == "") NOT ($_product->getData('out_of_stock_delivery') == 0)
I've got a problem with a translation. I don't understand why my content is well translated in the website but not in the email. The translation is done in csv files, but when I call the sentence, as usual, Magento got the english translation instead of the french one.
email/stock.phtml :
<?php if ($products = $this->getProducts()): ?>
<p><?php echo $this->__('You are receiving this notification because you subscribed to receive alerts when the following products are back in stock:') ?></p>
<table>
<?php foreach ($products as $product): ?>
<tr>
<td><img src="<?php echo $this->helper('catalog/image')->init($product, 'thumbnail')->resize(75, 75) ?>" border="0" align="left" height="75" width="75" alt="<?php echo $this->escapeHtml($product->getName()) ?>" /></td>
<td>
<p><strong><?php echo $this->escapeHtml($product->getName()) ?></strong></p>
<?php $shortDescription = $this->_getFilteredProductShortDescription($product) ?>
<?php if ($shortDescription): ?>
<p><small><?php echo $shortDescription ?></small></p>
<?php endif; ?>
<p><?php if ($product->getPrice() != $product->getFinalPrice()): ?>
<?php echo $this->__('Regular Price:') ?> <strong style="text-decoration:line-through;"><?php echo Mage::helper('core')->currency($product->getPrice()) ?></strong><br />
<strong><?php echo $this->__('Special price:') ?> <span style="color:#FF0000;"><?php echo Mage::helper('core')->currency($product->getFinalPrice()) ?></span></strong>
<?php else: ?>
<strong><?php echo $this->__('Price:') ?></strong> <?php echo Mage::helper('core')->currency($product->getPrice()) ?>
<?php endif; ?></p>
<p><small><?php echo $this->__('Click here not to receive alerts for this product') ?></small></p>
</td>
</tr>
<?php endforeach; ?>
</table>
<p><?php echo $this->__('Unsubscribe from all stock alerts') ?></p>
<?php endif; ?>
Do you know how to say to Magento that it has to take the french translation in my email template ?
To translate an email, you can copy it from the en_US folder to a corresponding language folder (es_ES, for example), then perform the translation. When you do this, you can also add or remove other vars from the email. Most emails will have headers that show you what vars are available.
As for adding a country code to the telephone number, you will need to define a new block in a module that will do this for you.
There is also another solution on link
First of possibility: https://magento.stackexchange.com/questions/25612/cron-job-template-block-not-being-translated-but-testobserver-is
Second possibility:
Function that's responsible for sending product out of stock alert is called send and exists in file around line 229:
app/code/core/Mage/ProductAlert/Model/Email.php
The function's using below code to get customer's store:
$store = Mage::getModel('core/store')->load($this->_customer->getStoreId());
Function getStoreId on customer gets data from field "Created from - account[created_in]"
So if customer was created by an Admin from backend - the customer will always get default store (admin's) settings for language, currency, translations, etc.
Check what is returned for the customer that get's wrong translation and/or url's by this code:
<?php if(Mage::getSingleton('customer/session')->isLoggedIn()) {
$customerData = Mage::getSingleton('customer/session')->getCustomer();
echo $customerData->getStoreId();
} ?>
If it's 0 - that's the case.
as the title suggests, I'm trying to display the "Sign up to be notified when this product is back in stock" link next to the "Out of Stock" Label.
So it should look like:
I'm going through all of the templates, and in template/catalog/product/view.phtml there is this code snippet:<?php echo $this->getChildHtml('alert_urls') ?>, which is from:template/productalert/product/view.phtml (which just contains the code to echo the actual link.) What I would like to do in this template is something like the following, where I have INSERT STOCK ALERT LINK HERE:
<?php $_product = $this->getProduct() ?>
<?php if ($this->displayProductStockStatus()): ?>
<?php if ($_product->isAvailable()): ?>
<p class="availability in-stock">
<span><?php echo $this->__('In stock') ?></span>
</p>
<?php else: ?>
<p class="availability out-of-stock">
<span><?php echo $this->__('Out of stock') ?></span>
<!-- ******* INSERT STOCK ALERT LINK HERE ******* -->
</p>
<?php endif; ?>
<?php endif; ?>
<?php echo $this->getChildHtml('product_type_data_extra') ?>
<?php echo $this->getPriceHtml($_product) ?>
I have disabled Price alerts as this is not needed. So the only alert will be the Sign up for stock notification.
I've tried many things, but I think perhaps that it is the scope of the $this variable that prevents me from accessing it. Your advice or suggestions are most welcomed!
Ok, so I just came across this page: http://forum.azmagento.com/how-to/product-alert-notify-html-in-product-list-view-55751.html, which gives instructions on how to edit the getSaveURL() function in the Core file (yikes!) /app/code/core/Mage/ProductAlert/Helper/Data.php with the following code:
public function getSaveUrl($type, $product = null)
{
if (!empty($product))
{
$product_id = $product->getId();
}
else
{
$product_id = $this->getProduct()->getId();
}
return $this->_getUrl('productalert/add/' . $type, array(
'product_id' => $product_id,
Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl()
));
}
and then to output the link: Notify Me When Available in your phtml.
Now this works well, but I'm a bit hesitant settling on a solution that involves modifying Core files. Is there any way I can make use of the above snippet of code without overriding any core files?
I am trying to merge these 2 line of code for an if statement. The purpose is to hide the attribute if Code1 is blank. Each one reports correct but when place together the code give errors. Thanks for the hint :)
Code1
<?php if ($_product->getAttributeText('tempi_consegna') != '') ?>
Code2
<p class="availability in-stock"><?php echo $this->__('Consegna:') ?>
<span>
<?php echo $_product->getAttributeText('tempi_consegna') ?>
</span>
</p>
They should be living friendly in magento product availability.
You can try as following:
<?php if ($_product->getAttributeText('tempi_consegna') != ''): ?>
<p class="availability in-stock"><?php echo $this->__('Consegna:') ?>
<span>
<?php echo $_product->getAttributeText('tempi_consegna') ?>
</span>
</p>
<?php endif; ?>
I've been having this problem for a while now. I use Magento with Bundle Products on this website:
http://canjicabrasil.com/bikinis/wave-brazilian-white-bikini.html
But when I apply a discount, it only shows the final price not a WAS and NOW like other sites.
What code should I use to call Prices in a way that:
If price is full it will display only one price
If Price has discount (on any of the budle items) it will display a WAS and a NOW price in the frontend of the site.
Anyone has come up with this solution?
This is the code on bundle.phtml
<?php endif; ?>
<?php if ($_product->isAvailable()): ?>
<p class="availability in-stock"><?php echo $this->helper('catalog')->__('Availability:') ?> <span><?php echo $this->helper('catalog')->__('In stock') ?></span></p>
<?php else: ?>
<p class="availability out-of-stock"><?php echo $this->helper('catalog')->__('Availability:') ?> <span><?php echo $this->helper('catalog')->__('Out of stock') ?></span></p>
<?php endif; ?>
<div class="price-box-bundle">
<?php echo $this->getPriceHtml($_product) ?>
</div>
<?php echo $this->getChildHtml('bundle_prices') ?>
without looking at the code to see how you applying discounts and generating the new discounted values, i can't give you an exact answer.
but you can keep track of the original price, then when the discount is applied, display the original value then the new discounted value.
for example.
$originalPrice = 200;
function getDiscount($value,$originalValue){
return ($originalValue - $value);
}
echo 'Was: ';
echo '<s>'.$originalPrice.'</s>;
echo 'Now: '.$getDiscount(50,$originalPrice);
Obviously you code will be different but this is a general overview.