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
Related
I am trying to create a shopping cart with PHP, but, once the user leaves the cart area, all of the products disappear. That's what I'm trying to do:
<?php foreach($almofadas as $almofadas):?>
<form action="cart.php" method="GET">
<div class="base col-6 col-sm-4 col-md-5 col-lg-4 col-xl-4">
<div class="card">
<img src="uploads/<?php echo $almofadas['imagem']; ?>" alt="">
<div class="content-c">
<div class="row-p">
<div class="details">
<span><?php echo $almofadas['pnome'] ; ?></span>
</div>
<div class="price">R$ <?php echo $almofadas['preço'];?> </div>
</div>
<input type="hidden" name="id" value="<?php echo $almofadas['p_id']?>">
<div style="margin-top: 10px;">
<div style="margin-bottom: 5px;"><button class="buttons-1" data-toggle="modal" data-target="#myModal">Detalhes</button></div>
<div><button class="buttons-2" type="submit">Adicionar ao Carrinho</a> </button></div>
</div>
</div>
</div>
</div>
</form>
<?php endforeach; ?>
Now the cart system:
<?php
session_start();
require_once 'conn.php';
$_SESSION['id'] = $_GET['id'];
$result_pedido = "SELECT * FROM tb_produtos WHERE p_id = '{$_SESSION['id']}'";
$resultado_pedido = mysqli_query($conn, $result_pedido);
$pedidos = mysqli_fetch_all($resultado_pedido, MYSQLI_ASSOC);
?>
Here I can only add one product and, I can't save it into a $_SESSION, having said that the product disapears once iI leave the cart.
<?php foreach($pedidos as $pedidos):?>
<tr>
<td>
<div class="cart-img">
<img src="uploads/<?php echo $pedidos['imagem'];?>" width="125px">
</div>
</td>
<td>
<div class="cart-model">
<?php echo $pedidos['pnome'] ; ?>
</div>
</td>
<td>
<div class="cart-quantity">
<input class="i-quantity" type="number" value="1">
</div>
</td>
<td>
<div class="cart-price">
R$<?php echo $pedidos['preço'] ; ?>
</div>
</td>
</tr>
</tbody>
</table>
<?php endforeach; ?>
If you check this line:
$_SESSION['id'] = $_GET['id'];
This mean the "id" in your $_SESSION is always set to $_GET['id'], even if it is empty. So it is reset every time the user visit a page.
You should:
have some mechanism to store your shopping cart content. There is none in your code; and
have a way to check if the user visits a new id before storing it to shopping cart.
For example,
<?php
/**
* This only make sense if this script is called
* by some AJAX / javascript interaction to specifically
* add a new item to cart.
*/
session_start();
require_once 'conn.php';
if (isset($_GET['id']) && !empty($_GET['id'])) {
$_SESSION['id'] = $_GET['id'];
}
$result_pedido = "SELECT * FROM tb_produtos WHERE p_id = '{$_SESSION['id']}'";
$resultado_pedido = mysqli_query($conn, $result_pedido);
$pedidos = mysqli_fetch_all($resultado_pedido, MYSQLI_ASSOC);
// If the user visits a path where the $_GET['id'] have result in
// database and the user specified that he / she want to save something
// to his / her cart.
if (isset($_GET['id']) && !empty($_GET['id']) && !empty($pedidos)) {
if (!isset($_SESSION['cart'])) $_SESSION['cart'] = []; // initialize if not exists.
$_SESSION['cart'] = array_merge($_SESSION['cart'], $pedidos);
}
?>
Note: the quantity should be set to the cart somehow. You need to change the data structure to set or increment the "qty". But this is at least a start.
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 new to Magento, so I am stucked in a different situation for me. I found a guide on how to display best selling products on homepage, implemented it and everything is working fine, except the $this->getAddToCartUrl($product). The product are not added to the cart after clicking on "Add to cart".
Here is my code:
$totalPerPage = ($this->show_total) ? $this->show_total : 4;
$counter = 1;
$visibility = array(
Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
);
$storeId = Mage::app()->getStore()->getId();
$productCollection = Mage::getResourceModel('reports/product_collection')
->addAttributeToSelect('*')
->addOrderedQty()
->addAttributeToFilter('visibility', $visibility)
->setOrder('ordered_qty', 'desc');
<div class="main_content">
<div class="container">
<div class="products_list">
<div class="best_deals">
<div class="recommended_products best_deals_products">
<ul>
<?php foreach($productCollection as $product): ?>
<?php
$categories = null;
foreach (explode(",", $product->category_ids) as $catId){
//Mage_Catalog_Model_Category
$cat = Mage::getModel('catalog/category')
->setStoreId(Mage::app()->getStore()->getId())
->load($catId);
$catName = $cat->getName();
$catLink = $cat->getUrlPath();
$categories .= ''.$catName.' ';
}
?>
<?php if($counter <= $totalPerPage): ?>
<?php $productUrl = $product->getProductUrl() ?>
<li>
<div class="img_bottle">
<a href="<?php echo $productUrl ?>" title="View <?php echo $product->name ?>">
<img src="<?php echo $this->helper('catalog/image')->init($product, 'image')->resize(107, 339); ?>" alt="Product image" />
</a>
</div>
<div class="product_desc">
<span><?php echo $product->name ?></span>
<span>Our price: $<?php echo number_format($product->getPrice(), 2); ?></span>
<?php if($product['country_of_manufacture']): ?>
<span>Country: <i><?php echo strtoupper($product->getAttributeText('country_of_manufacture')); ?></i></span>
<?php endif; ?>
<?php if($product['region']): ?>
<span>Region: <i><?php echo strtoupper($product['region']); ?></i></span>
<?php endif; ?>
<?php if($product->isSaleable()): ?>
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart buy_now_button" onclick="setLocation('<?php echo $this->getAddToCartUrl($product) ?>')">Add to Cart</button>
<?php else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
</div>
</li>
<?php endif; $counter++; ?>
<?php endforeach; ?>
</ul>
</div>
</div>
</div>
</div>
</div>
Thank you in advance, I hope that my problem will be solved here.
Change your button with following.
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart buy_now_button" onclick="setLocation('<?php echo $this->helper('checkout/cart')->getAddUrl($product)?>')">Add to Cart</button>
I found the solution. The problem was in the admin panel.
I had problem with something else not the code...
When I went into the manage product and on a single product, I saw that the products that I want to add to cart had only 1 qty, so I had already added them to cart so I couldn't again.
I changed the qty number on more than 1. It works.
Sorry and thank you for your time, all the best
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>
I have followed the steps in here
Add Google trust badge to Magento
And then in here:
http://www.magentocommerce.com/magento-connect/google-trusted-stores.html
In all pages the first javascript part shows fine.
In the checkout success page, it doesnt show fine the code. (see update below)
I know I am editing the correct file because I typed static text into the success.phtml
But after ordering, I cant see the generated html that should be generated.
I placed that code at the end of the file.
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license#magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* #category design
* #package base_default
* #copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
* #license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
?>
123
<div class="page-title">
<h1><?php echo $this->__('Your order has been received') ?></h1>
</div>
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
<h2 class="sub-title"><?php echo $this->__('Thank you for your purchase!') ?></h2>
<?php if ($this->getOrderId()):?>
<?php if ($this->getCanViewOrder()) :?>
<p><?php echo $this->__('Your order # is: %s.', sprintf('%s', $this->escapeHtml($this->getViewOrderUrl()), $this->escapeHtml($this->getOrderId()))) ?></p>
<?php else :?>
<p><?php echo $this->__('Your order # is: %s.', $this->escapeHtml($this->getOrderId())) ?></p>
<?php endif;?>
<p><?php echo $this->__('You will receive an order confirmation email with details of your order and a link to track its progress.') ?></p>
<?php if ($this->getCanViewOrder() && $this->getCanPrintOrder()) :?>
<p>
<?php echo $this->__('Click here to print a copy of your order confirmation.', $this->getPrintUrl()) ?>
<?php echo $this->getChildHtml() ?>
</p>
<?php endif;?>
<?php endif;?>
<?php if ($this->getAgreementRefId()): ?>
<p><?php echo $this->__('Your billing agreement # is: %s.', sprintf('%s', $this->escapeHtml($this->getAgreementUrl()), $this->escapeHtml($this->getAgreementRefId())))?></p>
<?php endif;?>
<?php if ($profiles = $this->getRecurringProfiles()):?>
<p><?php echo $this->__('Your recurring payment profiles:'); ?></p>
<ul class="disc">
<?php foreach($profiles as $profile):?>
<?php $profileIdHtml = ($this->getCanViewProfiles() ? sprintf('%s', $this->escapeHtml($this->getProfileUrl($profile)), $this->escapeHtml($this->getObjectData($profile, 'reference_id'))) : $this->escapeHtml($this->getObjectData($profile, 'reference_id')));?>
<li><?php echo $this->__('Payment profile # %s: "%s".', $profileIdHtml, $this->escapeHtml($this->getObjectData($profile, 'schedule_description')))?></li>
<?php endforeach;?>
</ul>
<?php endif;?>
<div class="buttons-set">
<button type="button" class="button" title="<?php echo $this->__('Continue Shopping') ?>" onclick="window.location='<?php echo $this->getUrl() ?>'"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
</div>
<script type="text/javascript">
<!--
/* NexTag ROI Optimizer Data */
var id = '3551264';
var rev = '<<?php echo Mage::getSingleton('core/session')->getScriptRevenue(); ?>>';
var order = '<<?php echo $this->getOrderId(); ?>>';
var cats = '<?php echo Mage::getSingleton('core/session')->getScriptCats(); ?>';
var prods = '<?php echo Mage::getSingleton('core/session')->getScriptProds(); ?>';
var units = '<?php echo Mage::getSingleton('core/session')->getScriptUnits(); ?>';
//-->
</script>
<script type="text/javascript" src="https://imgsrv.nextag.com/imagefiles/includes/roitrack.js"></script>
<?php
$order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
$amount = number_format($order->getGrandTotal(),2);
?>
<?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
?>
<!-- START Trusted Stores Order -->
<div id="gts-order" style="display:none;">
<!-- start order and merchant information -->
<span id="gts-o-id"><?php echo $orderId; ?></span>
<span id="gts-o-domain">{www.theprinterdepo.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>
<!-- end order and merchant information -->
<!-- start repeated item specific information -->
<?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; ?>
<!-- end repeated item specific information -->
</div>
<!-- END Trusted Stores -->
UPDATE:
I removed the code as they show in the first link and I installed the magento extension that should insert the code automatically where it needs to be. After checking html on any page and in the order success page, I can see the code is really generated, I cant see the validation bar as google says.
(I still cant see the badge)
Its weird, I cant see hte html code when I right click view source, but if check with firebug lite the code is there
<div id="gts-order" style="display: none; ">
<span id="gts-o-id">900001439</span>
<span id="gts-o-domain">{www.theprinterdepo.com}</span>
<span id="gts-o-email">sam.x.x#outlook.com</span>
<span id="gts-o-country">US</span>
<span id="gts-o-currency">USD</span>
<span id="gts-o-total">449.8400</span>
<span id="gts-o-discounts">-0.0000</span>
<span id="gts-o-shipping-total">34.8500</span>
<span id="gts-o-tax-total">0.0000</span>
<span id="gts-o-est-ship-date">2012-09-18</span>
<span id="gts-o-has-preorder">N</span>
<span id="gts-o-has-digital">N</span>
<span class="gts-item">
<span class="gts-i-name">HP LaserJet Pro 100 M175nw MFP Printer</span>
<span class="gts-i-price">414.9900</span>
<span class="gts-i-quantity">1</span>
<span class="gts-i-prodsearch-country">US</span>
<span class="gts-i-prodsearch-language">en</span>
</span>
</div>
this can be done only in US ip adddresses, otherwise the validation toolbar and the preview badge wont appear. I connected to a desktop in us and then I could do all validations.