<?php

namespace YSquare\GiftCert\Model;

class BasketItem extends BasketItem_parent{

    /**
     * Sets $this->_oPrice
     *
     * @param object $oPrice price
     */
    public function setPrice($oPrice)
    {
        $oArticle = $this->getArticle();
        if(!$this->isAdmin()){
            if($oArticle->isGiftCertArticle()){
                $aPersParam = $this->getPersParams();
                $dPrice = $aPersParam['details'];
                if(!empty($dPrice)){
                    $dPrice = str_replace(",", ".", $dPrice);
                    $oPrice->setPrice($dPrice);
                }
            }

        }

        return parent::setPrice($oPrice);
    }

    public function isGiftCertArticle() {
        $oArticle = $this->getArticle();
        return $oArticle->isGiftCertArticle();
    }
}