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)
Related
When an item is chosen on my site, it opens a details page. This is the top of the details page above the html tags:
<?php require_once('dbconnection.php');
mysqli_select_db($conn, $dbname);
$recordID = $_GET['recordID'];
$query_Master_details = "
SELECT *
FROM Master_List
WHERE Master_List.Master_Id = $recordID
";
$Master_details = mysqli_query($conn, $query_Master_details) or die(mysqli_error());
$row_Master_details = mysqli_fetch_assoc($Master_details);
$totalRows_Master_details = mysqli_num_rows($Master_details);
?>
This is the code that makes the body of the page:
<div class="container2">
<div class="category"><h2><?php echo $row_Master_details['Name']; ?></h2></div>
<p><?php echo $row_Master_details['Name']; ?></p>
<p><img src="img/<?php echo $row_Master_details['Img']; ?>" /></p>
<p><?php echo $row_Master_details['Code']; ?></p>
<p><?php echo $row_Master_details['Length']; ?> Characters</p>
<?php
mysqli_free_result($Master_details);
?>
<!-- end .container2 --></div>
What I would like to do is create an if/else statement that will look at the Style_ID of the selected item and determine if the number is > 3. If it is, I want it to choose an item that has a Style_Id of 1, 2, or 3 and the same Length as the item chosen and return a random row in the layout above, skip a few lines and then display the information for the selected item in the layout above. Else if it is < or = 3, then I need it to just display as above.
I have tried using:
<?php
If (Style_ID > 3) {
echo 'Test';
}Else {
<div class="category"><h2><?php echo $row_Master_details['Name']; ?></h2></div>
<p><?php echo $row_Master_details['Name']; ?></p>
<p><img src="img/<?php echo $row_Master_details['Img']; ?>" /></p>
<p><?php echo $row_Master_details['Code']; ?></p>
<p><?php echo $row_Master_details['Length']; ?> Characters</p>
}
?>
<?php
mysqli_free_result($Master_details);
?>
But it doesn't work and has syntax errors. How can I create this if/else statement?
Note: I would appreciate being able to get one setup for all of it, but if not just fixing this part would be a big help right now.
Thanks to #Brad for his responses, I finally got this one figured out. I ended up changing some of my field names and finally figured out where to close the php tags to make this work. Here is what I ended up with:
<div class="container2">
<div class="category"><h2><?php echo $row_master_details['name']; ?></h2></div>
<?php
if ($row_master_details['type_id'] > 3) {
echo "Test";
}else { ?>
<p><?php echo $row_master_details['name']; ?></p>
<p><img src="img/<?php echo $row_master_details['img']; ?>" /></p>
<p><?php echo $row_master_details['item_code']; ?></p>
<p><?php echo $row_master_details['length']; ?> Characters</p>
<?php
mysqli_free_result($master_details);
?>
<?php } ?>
<!-- end .container2 --></div>
For starters, PHP is case-sensitive.
If (...) {
...
}Else {
You'll want to use lower-case if and else.
Next, if Style_ID is an attribute of the record, you'll need to access it like you did the others.
if ($row_Master_details['Style_ID'] > 3) {
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'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.
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; ?>