Add special price and discount amount to the catergory page - php

hello I am trying to display the special price and discount percentage to the category page products. I have managed to do it on the actual product view but it still displays just the base price on the category page so without clicking into the product the user would not be aware a different price exists. I have added the following code to this file:
app/design/frontend/mytheme/default/template/catalog/price
above this
<?php // Display Discount percents start ?>
<?php if($_finalPrice < $_price): ?>
<?php $_savingPercent = 100 - round(($_finalPrice / $_price)*100); ?>
<p class="special-price yoursaving">
<span class="label"><?php echo $this->__('Your Saving:') ?></span>
<span class="price">
<?php echo $_savingPercent; ?>%
</span>
</p>
<?php endif; ?>
It works nicely for the product page view but i just need to figure how to display on the category pages with the special price also shown.
Any help appreciated thanks!

Related

Multiple shortcodes on a same page not working

Basically, I am trying to display ratings (using kk star rating plugin) for different past bookings in my plugin. I am using do_shortcode() for different bookings with different ids. This is being echoed in a partial file.
<?php
/* GIVE RATINGS IF NOT ALREADY GIVEN */
if ($ratings_possible) {
echo do_shortcode("[kkstarratings id=" . $booking->id . "]");
?>
Here $booking->id is giving a unique booking id number based on which I am trying to get unique rating for each booking.
Issue
Currently, main file runs loop three times and this snippet does display stars perfectly, but of those three star-bar, last one is actually working. Last one accepts the ratings and updates the average, but the first two are not working. We can hover over all there stars-bar and click, but the only last one of it is actually working.
I have also used kk_star_ratings() method but same result.
More details
The following is a part of dashboard.php code. It is displaying every appointment/booking of a customer. Here $customer->future_bookings is displaying upcoming bookings (where obviously $ratings_possible is set to false). However, on $customer->past_bookings I have set $ratings_possible to true. Followed by the partial file that is responsible for each booking detail i.e. include('_booking_tile.php');
dashboard.php
<div class="customer-bookings-tiles">
<?php
foreach($customer->future_bookings as $booking){
$editable_booking = true;
$ratings_possible = false;
include('_booking_tile.php');
} ?>
</div>
<?php } ?>
<?php
if($customer->past_bookings){ ?>
<div class="latepoint-section-heading-w">
<h5 class="latepoint-section-heading"><?php _e('Past '.$appointterm, 'latepoint'); ?></h5>
<div class="heading-extra"><?php printf( __('%d '.$appointterm, 'latepoint'), count($customer->past_bookings)); ?></div>
</div>
<div class="customer-bookings-tiles">
<?php
foreach($customer->past_bookings as $booking){
$editable_booking = false;
$ratings_possible = true;
include('_booking_tile.php');
} ?>
</div>
Now, on the _booking_tile.php, it contains details of each booking like agent, time, status etc. Through $booking object we are getting the variables of a particular booking and their values and everything. Here is some part of code:
_booking_tile.php
<div class="customer-booking-info-row">
<span class="booking-info-label"><?php _e($agentterm, 'latepoint'); ?></span>
<span class="booking-info-value"><?php echo $booking->agent->full_name; ?></span></div>
<div class="customer-booking-info-row">
<span class="booking-info-label"><?php _e('Status', 'latepoint'); ?></span>
<span class="booking-info-value status-<?php echo $booking->status; ?>"><?php echo $booking->nice_status; ?></span></div>
</div>
<?php if ($editable_booking) { ?>
<div class="customer-booking-buttons">
<a href="<?php echo $booking->ical_download_link; ?>" target="_blank" class="latepoint-btn latepoint-btn-primary latepoint-btn-link">
<i class="latepoint-icon latepoint-icon-ui-83"></i>
<span><?php _e('Add to Calendar', 'latepoint'); ?></span>
</a>
<?php /* <i class="latepoint-icon latepoint-icon-ui-46"></i><span><?php _e('Edit', 'latepoint'); ?></span> */ ?>
<a href="#" class="latepoint-btn latepoint-btn-danger latepoint-request-booking-cancellation latepoint-btn-link" data-route="<?php echo OsRouterHelper::build_route_name('bookings', 'request_cancellation'); ?>">
<i class="latepoint-icon latepoint-icon-ui-24"></i>
<span><?php _e('Cancel', 'latepoint'); ?></span>
</a>
</div>
<?php } ?>
<?php /* GIVE RATINGS IF NOT ALREADY GIVEN */
if ($ratings_possible) {
echo do_shortcode("[kkstarratings id=" . $booking->id . "]");
?>
<?php } ?>
Resulting HTML code is perfectly fine, every rating-star (kk star plugin) has perfect code it has unique IDs meaning it should work fine. Moreover, as I said before when I insert three shortcodes with different IDs, it works fine.
That stars are displaying perfectly, but only the third one is actually working. When I click third one it records my rating and displays the average. While first two are not.
Stars work when I insert their shortcodes manually through WordPress. So it means that multiple shortcodes with IDs is possible.
Author provides kk_star_rating() function that can be used in the code, but it gives same result.
Only the last star is working others are just not recording anything. All three have same resulting HTML code except for the IDs which will be unique.
I will be happy to answer more of your questions.
Here's the screenshot, Third one is giving me the result when I click. But I can only hover over the first two and click multiple times with no result.
Screenshot
It was some sort of problem with the plugin. It was not compatible with newest version of WordPress. Used a different plugin and it worked fine. Calling multiple shortcodes through a loop worked perfectly.
Thanks to everyone who tried to help.

Variation Product Shows Price Twice | Wordpress WooCommerce

In wordpress WooCommerce, when i add a Variation Product, variation is set only by Two colors,
Starwhite = 9000
Ivory = 15000
On the Single Product page, I get to see price mentioned twice, as shown in screenshots.
I want to retain the price defined in variation. Remove the other one.
The price which is not required is showing up under the div below
<div itemprop="offers" itemscope="" itemtype="http://schema.org/Offer">
<p class="price"><span class="amount">Rs.9,000.00</span>–<span class="amount">Rs.15,000.00</span></p>
<meta itemprop="price" content="9000" style="
/* display: none; */
">
<meta itemprop="priceCurrency" content="INR">
<link itemprop="availability" href="http://schema.org/InStock">
</div>
But when i mark it has display none or visibility hidden, the price from variation is also gone..
1st Color Variation settings:
2nd Color Variation settings:
Also, there are times when i use Simple Product on the website, so any changes suggested should not impact simple product settings.
If i have to make any changes in the code, what should be the code and under which php files should it be changes.
I believe the file you need to edit is "/single-product/price.php", you should have a copy of that file in your theme folder (/your-theme/woocommerce/single-product/price.php), if not you can copy it there from /wp-content/plugins/woocommerce/templates/
Change:
<p class="price"><?php echo $product->get_price_html(); ?></p>
To:
<?php if( $product->is_type( 'simple' ) ){ ?><p class="price"><?php echo $product->get_price_html(); ?></p><?php } ?>
That will make it only display the price for Simple Products. The other price display that changes when you select a different variation is set in /single-product/add-to-cart/variable.php so that will be unaffected.

"Undefined" is display with discount price in magento

I am using magento 1.8.1 and i am trying to display discount percent with sell price on frontend.
with the help of this site discount
i am putting these code:
<?php // Discount percents output start ?>
<?php if($_finalPrice < $_price): ?>
<?php $_savePercent = 100 - round(($_finalPrice / $_price)*100); ?>
<p class="special-price yousave">
<span class="label"><?php echo $this->__('You Save:') ?></span>
<span class="price">
<?php echo $_savePercent; ?>%
</span>
</p>
<?php endif; ?>
in this page: app/design/frontend/yourpackage/yourtheme/template/catalog/product/price.phtml
but after that the result is showing as like this:
Now i am not able to find why "undefined" is showing here and how to remove this.
Please tell me how to remove this.
I seen in your question image you need this effect on product detail page so have to edit media.phtml
app\design\frontend\YOUR_PACKAGE\YOUR_THEME\default\template\catalog\product\view\media.phtml
And in that you have to do same coding to get this value. you can make wrapper class which is override to product image with some dynamic text over product image like as you want.
You can use css like in this page
I think its work...try in this way

add product link to sku (or product name) in new order mail

hy,
i'm trying to add a link to the new order email that the customer is getting when he is placeing a new order in magento (my version 1.6.2.0 )
i have edited /public_html/app/design/frontend/base/default/template/email/order/items/order/default.phtml
with the following:
<?php $_item = $this->getItem() ?>
<?php $_order = $this->getItem()->getOrder() ?>
----
<!-- Start of edit file -->
<a href="<?php echo $this->getProductUrl($_item) ?>">
<?php echo $this->htmlEscape($this->getSku($_item)) ?></a>
When i receive the confirmation email in the sku column the color changes form black ( default css ) to light blue link like, but it does not have any link property as shown below:
email_photo
I have also tried :
<a href="<?php echo $this->getUrlPath($_item) ?>">
<?php echo $this->htmlEscape($this->getSku($_item)) ?></a>
and i end up with the same thing.
Can anyone tell me what i'm doing wrong ?
Thanks.
In line
<a href="<?php echo $this->getUrlPath($_item) ?>">
$this is an instance of block *Mage_Sales_Block_Order_Email_Items_Order_Default*. It does not have a function getUrlPath() or getProductUrl.
You should use your $_item variable to get a product object and then it to get its URL
$_item->getProduct()->getProductUrl()
I earlier tried this code:
<?php echo $this->htmlEscape($this->getSku($_item)) ?>
Magento 2
To link a product name with its product page in your order emails, edit following files:
Magento_Sales/templates/email/items/order/default.phtml
Magento_Sales/templates/email/items/invoice/default.phtml
Magento_Sales/templates/email/items/shipment/default.phtml
To get the product URL, use the following snippet of code and insert it into a href attribute of the link.
<?= $_item->getProduct()->getProductUrl(); ?>
For example,
<p class="product-name"> <?= $block->escapeHtml($_item->getName()); ?> </p>
The result of the snippet of code will be a clickable product name in Magento Emails.
Tutorial from: https://themes.email/magento/product-links-in-magento-order-emails.html

How do I display the product Long Description in the product review page?

I have a layout that requires the product description on the reviews page. How can I accomplish this?
Magento version is 1.6
It appears as though the Review page is loading the Product View template just without some of the information; from product/view.phtml:
<div id="product-details">
<?php foreach ($this->getChildGroup('detailed_info', 'getChildHtml') as $alias => $html):?>
<div class="box-collateral <?php echo "box-{$alias}"?>">
<?php echo $html; ?>
</div>
<?php endforeach;?>
</div>
and on the main product view it shows the details here, but on the review view it does not.
What version of Magento? How is the product collection loaded?
You will need to customize one of the templates location in the below, make sure to move into your template and do not edit the base files.
/var/www/vhosts/site.com/www/app/design/frontend/base/default/template/review/
<?php echo $_helper->productAttribute($_product, $_product->getDescription(), 'description') ?>
Is how this is loaded on a standard product view.
You may have to set the $_product variable via <?php $_product = $this->getProduct(); ?> and <?php $_helper = $this->helper('catalog/output'); ?>

Categories