VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: thefbi on December 03, 2016, 15:49:32 PM

Title: Base price and discount price layout - J3.6.4 / VM3.0.18
Post by: thefbi on December 03, 2016, 15:49:32 PM
Hello,

i have read many post on this subject, but no one can resolve this basic problem for a e-shop. I dont understand we have this problem on a great component like Virtuemart...

I want to show the final price for all the products.
If i have a discount, i want to show the base price without discount, the final price with discount and the amount of discount.
If i activate the base price in my VM config, i have what i want, but for the non discount product, i have too the base price, and the final price, wich are the same = I dont want this.

So, actually, in my price configuration i have activate :
- Base price with tax, without discount => but it show NOTHING
- Final price
- Amount of discount

If you go in the url page : https://www.energie-sante.ch/accueil-boutique/consommables-argent-colloidal.html
you can see (at the end of the page) my "Argent colloidal TEST" with the Final price and discount amount but NOT the base price without discount.

I am not programmer and that make many month i try to resolve this issue, so if somebody can tell me what code i have to put in what folder, i was very happy :)

Thanks for help,
Frédéric
Title: Re: Base price and discount price layout - J3.6.4 / VM3.0.18
Post by: thefbi on December 03, 2016, 15:53:05 PM
Here is th code i have in my html override, in sublayout => price.php

<?php
/**
 *
 * Show the product prices
 *
 * @package    VirtueMart
 * @subpackage
 * @author Max Milbers, Valerie Isaksen
 * @link http://www.virtuemart.net
 * @copyright Copyright (c) 2004 - 2014 VirtueMart Team. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * VirtueMart is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * @version $Id: default_showprices.php 8024 2014-06-12 15:08:59Z Milbo $
 */
// Check to ensure this file is included in Joomla!
defined ('_JEXEC') or die('Restricted access');
$product $viewData['product'];
$currency $viewData['currency'];
?>

<div class="product-price" id="productPrice<?php echo $product->virtuemart_product_id ?>">
<?php
if (!empty(
$product->prices['salesPrice'])) {
//echo '<div class="vm-cart-price">' . vmText::_ ('COM_VIRTUEMART_CART_PRICE') . '</div>';

}

if ($product->prices['salesPrice']<=and VmConfig::get ('askprice'1) and isset($product->images[0]) and !$product->images[0]->file_is_downloadable) {
$askquestion_url JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' $product->virtuemart_product_id '&virtuemart_category_id=' $product->virtuemart_category_id '&tmpl=component'FALSE);
?>

<a class="ask-a-question bold" href="<?php echo $askquestion_url ?>" rel="nofollow" ><?php echo vmText::('COM_VIRTUEMART_PRODUCT_ASKPRICE'?></a>
<?php
} else {
//if ($showBasePrice) {
echo $currency->createPriceDiv ('basePrice''COM_VIRTUEMART_PRODUCT_BASEPRICE'$product->prices);
//if (round($product->prices['basePrice'],$currency->_priceConfig['basePriceVariant'][1]) != $product->prices['basePriceVariant']) {
echo $currency->createPriceDiv ('basePriceVariant''COM_VIRTUEMART_PRODUCT_BASEPRICE_VARIANT'$product->prices);
//}

//}
echo $currency->createPriceDiv ('variantModification''COM_VIRTUEMART_PRODUCT_VARIANT_MOD'$product->prices);
if (round($product->prices['basePriceWithTax'],$currency->_priceConfig['salesPrice'][1]) != $product->prices['salesPrice']) {
echo '<span class="price-crossed" >' $currency->createPriceDiv ('basePriceWithTax''COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX'$product->prices) . "</span>";
}
if (round($product->prices['salesPriceWithDiscount'],$currency->_priceConfig['salesPrice'][1]) != $product->prices['salesPrice']) {
echo $currency->createPriceDiv ('salesPriceWithDiscount''COM_VIRTUEMART_PRODUCT_SALESPRICE_WITH_DISCOUNT'$product->prices);
}



echo $currency->createPriceDiv ('salesPrice''COM_VIRTUEMART_PRODUCT_SALESPRICE'$product->prices);
if ($product->prices['discountedPriceWithoutTax'] != $product->prices['priceWithoutTax']) {
echo $currency->createPriceDiv ('discountedPriceWithoutTax''COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX'$product->prices);
} else {
echo $currency->createPriceDiv ('priceWithoutTax''COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX'$product->prices);
}
echo $currency->createPriceDiv ('discountAmount''COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT'$product->prices);
echo $currency->createPriceDiv ('taxAmount''COM_VIRTUEMART_PRODUCT_TAX_AMOUNT'$product->prices);
$unitPriceDescription vmText::sprintf ('COM_VIRTUEMART_PRODUCT_UNITPRICE'vmText::_('COM_VIRTUEMART_UNIT_SYMBOL_'.$product->product_unit));
echo $currency->createPriceDiv ('unitPrice'$unitPriceDescription$product->prices);
}
?>

<div class="clear"></div>
</div>
Title: Re: Base price and discount price layout - J3.6.4 / VM3.0.18
Post by: maxispin on December 03, 2016, 22:08:43 PM
Hmm.. what is the problem? all other products are not having discount price showing
Title: Re: Base price and discount price layout - J3.6.4 / VM3.0.18
Post by: thefbi on December 03, 2016, 22:32:50 PM
QuoteSo, actually, in my price configuration i have activate :
- Base price with tax, without discount => but it show NOTHING
- Final price
- Amount of discount

The problem is for the product with discount price...
Do you see the Base price with tax, without discount ??? Me not
Title: Re: Base price and discount price layout - J3.6.4 / VM3.0.18
Post by: maxispin on December 04, 2016, 11:48:04 AM
It is much easier to understand if you give calculation example.

Am I right,

Baseprice 150
Discount price 120.

So please open the calculation of yours here.
Title: Re: Base price and discount price layout - J3.6.4 / VM3.0.18
Post by: thefbi on December 20, 2016, 20:45:26 PM
Hello yes,

i have chang my template now, but the problem still here.

Actually i have (for example) :

Final price : 150.-
Base price : 120.-

This is a discount price, it is OK like this, but i have on all my other non discount price :

Final price : 150.-
Base price : 150.-

It is a non-sense to have the same price twice.
I want the base price ONLY when i have a discount
Title: Re: Base price and discount price layout - J3.6.4 / VM3.0.18
Post by: maxispin on December 20, 2016, 21:33:45 PM
https://postimg.org/image/t6f48ra2p/
Title: Re: Base price and discount price layout - J3.6.4 / VM3.0.18
Post by: thefbi on December 20, 2016, 21:46:44 PM
Hum... if i make this one, i have ONLY the final price. I want the Base price AND final price for discount products.
I want the clients see the base price and final price for the discount products.

If you see only the final price in a discount product, how do you do to know the price without discount ???
Title: Re: Base price and discount price layout - J3.6.4 / VM3.0.18
Post by: GJC Web Design on December 20, 2016, 22:41:24 PM
If you don't specifically charge tax or use b4 tax discounts  then the logic of the strikethru / discount display is wrong in the sublayout/prices.php

you need to add something like

//GJC added to show strikethru price on b4 tax discounts
    if (abs($product->prices['discountAmount']) > 0 && ($product->prices['salesPrice'] < $product->prices['product_price'] ) ){
        echo '<span class="price-crossed" >' .$this->currency->createPriceDiv ('product_price', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITH_DISCOUNT', $product->prices). "</span>";
    }
//GJC added to show strikethru price on b4 tax discounts


but echo out your $product->prices to see which ones to us in the logic

Title: Re: Base price and discount price layout - J3.6.4 / VM3.0.18
Post by: maxispin on December 21, 2016, 05:41:08 AM
It was not meant to be perfect solution for your case.

As you wrote. It works. Play with settings and code 
Title: Re: Base price and discount price layout - J3.6.4 / VM3.0.18
Post by: thefbi on December 24, 2016, 11:23:09 AM
Thank you, but my knowledge is limited on coding...
I gone try to edit it, but i have already tested and i never succeeded to make append the "Base price without discount" in my site.
Because i thing it is this parameter. But if you select it in the VM config, it never appear... In all template.
Title: Re: Base price and discount price layout - J3.6.4 / VM3.0.18
Post by: thefbi on December 25, 2016, 12:35:55 PM
Hello,

OK, that is OK now. I have add this code, but not work :

<?php if ($product->prices['discountedPriceWithoutTax'] != $product->prices['priceWithoutTax']) {
echo $this->currency->createPriceDiv('basePriceWithTax','COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX',$product->prices);
} ?>


I have replace basePriceWithTax BY basePrice and is OK.