Show the strike trough price with discount

Hi guys,

anoter time i need some help with oxid. I would like to show to the user the original price of a reduced product with an discount. The original code just show the reduced price of this product. I know that it is possible to achieve that by provide the UVP of a product, but in my case I need to work with discounts. Is there a way to manage this in a template or do I have to write a extension class?

Tanks in advance
nick

Is there at least a way to get the original price (without discount)?
at the moment Im trying to edit the getPrice function of oxarticle.

cheers

I think this issue has been discussed here some days ago in the german forum, and there was as well a solution

was it in the wiki, or in uservoice???

let me search, will find it!

Marco? any hint?

Maybe this can help you?

I think a red it already, they suggested to use the UVP value, this is already implemented. but i have to use the discount function

err - right… :frowning:

do you know a way to get the original price, then i can compare it and adjust the template.
If i call the getPrice function of oxartilce I only get the reduced price :frowning:

sorry - maybe a complete file with the database fields can help you out?

http://wiki.oxidforge.org/File:Oxid_ce43x_mysql_admin_nomenklatur.xls

finaly i know how to get the original price. But realy there should be a function to call to get the original price build in.

$aVariants = $this->getVariants(false);

    if (count($aVariants)) {
        foreach ($aVariants as $sKey => $oVariant) {
            $aPrices[] = $oVariant->getPrice()->getBruttoPrice();
        }
        
    }                
    return $aVariants[$sKey]->oxarticles__oxprice->value;

so the ready function will look like this

public function getOriginalPrice(){

    $aVariants = $this->getVariants(false);
    
    $oPrice = null;
    
    if (count($aVariants)) {
    
        $key = null;
        foreach($aVariants as $vKey => $vValue)
        {
            if($key == null)
            {    
                $key = $vKey;
            }
        }
        $oVariant = $aVariants[$key];            
                                
        $oPrice = oxNew( 'oxPrice' );
        $oPrice->setPrice( $oVariant->oxarticles__oxprice->value );                                 
    }     
    else
    {
        $oPrice = oxNew( 'oxPrice' );
        $oPrice->setPrice( $this->oxarticles__oxprice->value );
    }
    
    return oxLang::getInstance()->formatCurrency( $oPrice->getBruttoPrice() );
}

[QUOTE=Vermond;48154]I think a red it already, they suggested to use the UVP value, this is already implemented. but i have to use the discount function[/QUOTE]
I was looking for the same solution and came up with this:

     /**
     * Returns T price (aka UVP) if exists else returns price without discounts
     *
     * @return oxPrice
     */
    public function getTPrice()
    {
        $oTPrice = parent::getTPrice();
        if (!$oTPrice->getBruttoPrice()) {
            $oTPrice->setPrice($this->oxarticles__oxprice->value);
        }
        return $oTPrice;
    }

wrapped in a modul that extends the oxarticle class and you can use:

            [{if ($variant->getPrice() < $variant->getTPrice() ) }]
                <b class="old">[{ oxmultilang ident="DETAILS_REDUCEDFROM" }] <del>[{ $variant->getFTPrice()}] [{ $currency->sign}]</del></b>
                <span class="desc">[{ oxmultilang ident="DETAILS_REDUCEDTEXT" }]</span><br>
                <sub class="only">[{ oxmultilang ident="DETAILS_NOWONLY" }]</sub>
            [{/if}]

everytime where

[{if $product->getFTPrice()}]

is used for reduced prices.

This way you don’t have to set the tprice on every article instead it returns the orginal price without discounts. Then you can compare the tprice with price and show the discount if needed. This thread gives a good overview where prices are shown in templates