Add Span Between Currency Symbol and Price in Magento - php

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>

Related

Add "Starting from" in front of prices on category page in open cart store

I'm trying to edit the template and I need to add "Starting from" in front of the prices on the catalog page (and then maybe the product page, but one step at a time)
I've located where it echos the price in the tpl file
<p class="price">
<?php if (!$product['special']) { ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-new"><?php echo $product['special']; ?></span> <span class="price-old"><?php echo $product['price']; ?></span>
<?php } ?>
What I tried was to add a row in the oc_product table called starting_from and manually enter "Starting from" in each one. (there are only 6 products for now).
With very little knowlegde i added
<?php echo $product['starting_from']; ?>
so it then looked like this
<p class="price">
<?php if (!$product['special']) { ?>
<?php echo $product['starting_from']; ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-new"><?php echo $product['special']; ?></span> <span class="price-old"><?php echo $product['price']; ?></span>
<?php } ?>
Shockingly, it didn't work.
Can someone try and explain the magnitude of my errors, please?
And maybe help me out.
Thank
If your want to simply add the hardcoded string Starting from, you can do:
<p class="price">Starting from
<?php if (!$product['special']) { ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-new"><?php echo $product['special']; ?></span> <span class="price-old"><?php echo $product['price']; ?></span>
<?php } ?>
Actually, if I got you right, this is very basic, so I'd recommend some PHP tutorial to start with.

Magento 1.9 Trusted Shops with reviews

I have the problem when I integrate Trusted Shops in a static block or via the plugin of Trusted Shops. The evaluation and the Stars are not on the Trusted Shops badge then the man has to insert the following Div element with the matching variables on the checkout page.
<div id="trustedShopsCheckout" style="display: none;">
<span id="tsCheckoutOrderNr">2016-05-21-001</span>
<span id="tsCheckoutBuyerEmail">mein.kunde#mail.de</span>
<span id="tsCheckoutOrderAmount">4005.95</span>
<span id="tsCheckoutOrderCurrency">EUR</span>
<span id="tsCheckoutOrderPaymentType">VORKASSE</span>
<span id="tsCheckoutOrderEstDeliveryDate">2016-05-24</span>
</div>
Now the question where can I find the variables for it or is there a simpler way to integrate that?
greetings
Leon
Add the following code to the checkout/success.phtml
/********************************************
* TRUSTED SHOPS BUYERS PROTECTION
*
* Variables needed for Trusted Shops PopOut-Card,
********************************************/
$orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
$order = Mage::getSingleton('sales/order')->load($orderId);
$grandTotal = $order->getGrandTotal();
$currencyCode = $order->getOrderCurrencyCode();
$customerId = Mage::getSingleton('customer/session')->getCustomerId();
$customer = Mage::getSingleton('customer/session')->getCustomer();
$email = $order->getCustomerEmail();
$paymentType = $order->getPayment()->getMethod();
?>
<div id="trustedShopsCheckout" style="display: none;">
<span id="tsCheckoutOrderNr"><?php echo $orderId ?></span>
<span id="tsCheckoutBuyerEmail"><?php echo $email ?></span>
<span id="tsCheckoutBuyerId"><?php echo $customerId ?></span>
<span id="tsCheckoutOrderAmount"><?php echo $grandTotal ?></span>
<span id="tsCheckoutOrderCurrency"><?php echo $currencyCode ?></span>
<span id="tsCheckoutOrderPaymentType"><?php echo $paymentType ?></span>
<span id="tsCheckoutOrderEstDeliveryDate"></span>
</div>
If you want to add Product Reviews too you have to add the following code before the final </div>
<!-- product reviews start -->
<?php foreach ($order->getAllVisibleItems() as $orderItem): ?>
<?php $product = $orderItem->getProduct(); ?>
<span class="tsCheckoutProductItem">
<span class="tsCheckoutProductUrl"><?php echo $product->getProductUrl() ?></span>
<span class="tsCheckoutProductImageUrl"><?php echo $product->getImageUrl() ?></span>
<span class="tsCheckoutProductName"><?php echo $product->getName() ?></span>
<span class="tsCheckoutProductSKU"><?php echo $product->getSku() ?></span>
</span>
<?php endforeach; ?>
<!-- product reviews end -->
Info:
You can also add GTIN, MPN and Brand. But this depends to your product structure. See http://www.trustedshops.de/shopbetreiber/integration/product-reviews/ for this

Return two decimal places value for the variable extracted from php code for Google Trusted Store

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)); ?>

Creating exceptions when comparing a variable to a string?

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;
...

How to display VAT after price in magento

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!

Categories