The php code excerpt below triggers "Call for Price" for select manufacturers on our Magento site. So, how do I "exclude" select products from these vendors? For instance, within our manufacturer "XMarks" there are 10 products that I do not want to show "Call for Price" but instead the sale price, list price & add to cart button. How do I do this? I'm a complete beginner. Thank you!
<p class="special-price">
<span class="price-label"><?php echo $this->__('Special Price:') ?></span>
<span class="price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php if($manufacturerName == 'XMarks' || $manufacturerName == 'Maxtor' || $manufacturerName == 'Trixfx' || $manufacturerName == "Oouph" || $manufacturerName == "Groffer" || $manufacturerName == "Wofstern"){ ?>
<span class="olyprice">Call for Price</span><?php }
<p class="special-price">
<span class="price-label"><?php echo $this->__('Special Price:') ?></span>
<span class="price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php
function callPrice(){ echo '<span class="olyprice">Call for Price</span>';}
switch ($manufacturerName){
case: 'XMarks'
if(product != prduct)
{
callPrice();
}
break;
case: 'Maxtor'
if(product != prduct)
{
callPrice();
}
break;
...
Related
I am customizing the wordpress woocommerce product category page. I successfully added an image inline with the product name. My issue arises when I try to make the images linkable. The formatting of the image gets lost as they display bigger, not inline with the product name and with a border. More details below, can anyone help?
This is the current code:
global $product;
$link = get_field('product_fiche');
$label = get_field('energy_label');
$full = get_field('full_energy_label');
?>
<div class="price-wrapper <?php if($link || $label) { echo 'has-col'; } ?>">
<?php if ( $price_html = $product->get_price_html() ) : ?>
<span class="price"><?php echo $price_html; ?></span>
<?php endif; ?>
<?php if(is_product_category() && $link || $label) : ?>
<span class="product-action">
<?php if($link) { echo '<a class="link" href="'.$link.'" target="_blank">Product Fiche</a>'; } ?>
<?php if($label) { echo '<img class="energy-label" src="'.$label.'" alt="energy label" />'; } ?>
</span>
<?php endif; ?>
</div>
This is how the category pages appear: (please note how the icons appear inline with the product name)
enter image description here
This is the updated code, I formatted the addition in bold.
global $product;
$link = get_field('product_fiche');
$label = get_field('energy_label');
$full = get_field('full_energy_label');
?>
<div class="price-wrapper <?php if($link || $label) { echo 'has-col'; } ?>">
<?php if ( $price_html = $product->get_price_html() ) : ?>
<span class="price"><?php echo $price_html; ?></span>
<?php endif; ?>
<?php if(is_product_category() && $link || $label) : ?>
<span class="product-action">
<?php if($link) { echo '<a class="link" href="'.$link.'" target="_blank">Product Fiche</a>'; } ?>
<?php if($label) { echo '****<img class="energy-label" src="'.$label.'" alt="energy label" />****'; } ?>
</span>
<?php endif; ?>
</div>
The above code leads to the below:
enter image description here
I wrote this code for a translation table which I use inside my dictionary website.
<div class="row">
<?php
$stmt_word1 = $auth_user->runQuery("SELECT * FROM word_language_meanings WHERE word_id = '".$word_id."'");
$stmt_word1->execute();
$wordLangRows=$stmt_word1->fetchAll(PDO::FETCH_ASSOC);
$counter = 1;
foreach($wordLangRows as $k => $v)
{
if($v['word_language'] != $language)
{
?>
<div class="col-sm-4 black_color" id="col-sm-4-translations">
<h5><strong><?php echo $v['word_language']; ?></strong></h5>
<span class="<?php if($v['word_language'] == 'Старобългарски') { echo 'bulgarian_font'; } ?>"><a style="color: gray;" href="dictionary.php?meaning=<?php echo $v['word_meaning']; ?>&language=<?php echo $word_language; ?>"><?php echo $v['word_meaning']; ?></a></span>
</div>
<?php
}
}
?>
</div>
Unfortunately the code below does not redirect me to the particular word I'd choose from the translation table.
<span class="<?php if($v['word_language'] == 'Старобългарски') { echo 'bulgarian_font'; } ?>"><a style="color: gray;" href="dictionary.php?meaning=<?php echo $v['word_meaning']; ?>&language=<?php echo $word_language; ?>"><?php echo $v['word_meaning']; ?></a></span>
It shows me this url but as u can see the language is not defined. What I am trying to do is to tell, if the word is for example "test" and its an english translation, to redirect me to that word of that particular language, as it's set in the database. Has anyone any idea how to make this work?
$word_language is not define. Use $v['word_language'] instead
<span class="<?php if($v['word_language'] == 'Старобългарски') { echo 'bulgarian_font'; } ?>"><a style="color: gray;" href="dictionary.php?meaning=<?php echo $v['word_meaning']; ?>&language=<?php echo $v['word_language'] ?>"><?php echo $v['word_meaning']; ?></a></span>
Below is my code for Google trusted Store. Currently it generates numeric values with four decimal places. For example, the value for this code: getGrandTotal(); ?>
it returns value in the format 25.0000 Is there a way it could be forced to return a value for 2 decimal places i.e 25.00
Thanks,
<?php
$orderId = $this->getOrderId();
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
$address = $order->getShippingAddress();
$backorder = false; // some backorder logic
$download = false; // some download logic
$shipDate = new Zend_Date(); // some logic to determine ship date
?>
<div id="gts-order" style="display:none;">
<span id="gts-o-id"><?php echo $orderId; ?></span>
<span id="gts-o-domain">www.example.com</span>
<span id="gts-o-email"><?php echo htmlentities($customer->getEmail()); ?></span>
<span id="gts-o-country"><?php echo htmlentities($address->getCountryId()); ?></span>
<span id="gts-o-currency">USD</span>
<span id="gts-o-total"><?php echo $order->getGrandTotal(); ?></span>
<span id="gts-o-discounts">-<?php echo $order->getDiscountAmount(); ?></span>
<span id="gts-o-shipping-total"><?php echo $order->getShippingAmount(); ?></span>
<span id="gts-o-tax-total"><?php echo $order->getTaxAmount(); ?></span>
<span id="gts-o-est-ship-date"><?php echo $shipDate->toString('yyyy-MM-dd'); ?></span>
<span id="gts-o-has-preorder"><?php echo $backorder ? 'Y' : 'N'; ?></span>
<span id="gts-o-has-digital"><?php echo $download ? 'Y' : 'N'; ?></span>
<?php foreach ($order->getAllItems() as $item): ?>
<span class="gts-item">
<span class="gts-i-name"><?php echo htmlentities($item->getName()); ?></span>
<span class="gts-i-price"><?php echo $item->getBasePrice(); ?></span>
<span class="gts-i-quantity"><?php echo (int)$item->getQtyOrdered(); ?></span>
<span class="gts-i-prodsearch-country">US</span>
<span class="gts-i-prodsearch-language">en</span>
</span>
<?php endforeach; ?>
</div>
Try using number_format function of PHP. For example,
<?php
$number = 25.0000;
echo number_format((float)$number, 2, '.', '');
?>
This will print
25.00
I modified the code as following to achieve the objective
<?php echo(round($order->getGrandTotal(),2)); ?>
I am looking to split the price from the currency symbol so i can add
<span class="price" itemprop="price">
Between the two.
I have found the code in the price.
<p class="special-price">
<span class="price-label"><?php echo $_specialPriceStoreLabel ?></span>
<span class="price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php echo $_coreHelper->currency($_finalPrice, true, false) ?>
</span>
</p>
How do i go about changing this so i can place the span between the symbol and price.
To get price without currency
$_coreHelper->currency($_finalPrice, false, false)
To get current currency symbol
Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol()
So your code would become something like this:
<p class="special-price">
...
<span class="currency-code"> <?php echo Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(); ?> </span>
<span class="price" itemprop="price"> <?php echo $_coreHelper->currency($_finalPrice, false, false); ?> </span>
</p>
Im struggling a bit here. Basically, out client want the prices on the listing and product page to exclude VAT which is fine. But they she wan't written after the price '+VAT (£0.00)'.
Obviously the £0.00 will be the exact amount of VAT that will be added onto the product. So if its £20, it will need to say:
£20.00 +VAT (£3.40)
Does anyone know of a way to do this?
thanks.
You need to override price.phtml. Create copy of price.phtml to new_price.phml and call it from catalog.xml file for product listing page. Also enable System->Configuration->Tax->Price Display Settings->Display Product Prices In Catalog : Including and Excluding Tax
Then, in new_price.phtml do some changes as below:
<span class="price-excluding-tax">
<span class="label"><?php echo $this->helper('tax')->__('Price:') ?></span>
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php if ($_finalPrice == $_price): ?>
<?php echo $_coreHelper->currency($_price, true, false) ?>
<?php else: ?>
<?php echo $_coreHelper->currency($_finalPrice, true, false) ?>
<?php endif; ?>
</span>
</span>
<span class="price-including-tax">
<span class="label"><?php echo $this->helper('tax')->__('Vat:') ?></span>
<span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php //echo $_coreHelper->currency($_finalPriceInclTax, true, false) ?>
<?php if ($_finalPrice == $_price): ?>
<?php echo $_coreHelper->currency($_finalPriceInclTax - $_price, true, false) ?>
<?php else: ?>
<?php echo $_coreHelper->currency($_finalPriceInclTax - $_finalPrice, true, false) ?>
<?php endif; ?>
</span>
</span>
Hope it will help!