2018-01-25 11:30:17 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This Software is the property of Data Development and is protected
|
|
|
|
* by copyright law - it is NOT Freeware.
|
|
|
|
*
|
|
|
|
* Any unauthorized use of this software without a valid license
|
|
|
|
* is a violation of the license agreement and will be prosecuted by
|
|
|
|
* civil and criminal law.
|
|
|
|
*
|
|
|
|
* http://www.shopmodule.com
|
|
|
|
*
|
|
|
|
* @copyright © D³ Data Development, Thomas Dartsch
|
2018-02-23 12:30:57 +01:00
|
|
|
* @author D³ Data Development - Daniel Seifert <info@shopmodule.com>
|
2018-01-25 11:30:17 +01:00
|
|
|
* @link http://www.oxidmodule.com
|
|
|
|
*/
|
|
|
|
|
2019-10-16 14:56:55 +02:00
|
|
|
namespace D3\Devhelper\Modules\Application\Model;
|
|
|
|
|
|
|
|
use OxidEsales\Eshop\Application\Model\BasketItem;
|
|
|
|
use OxidEsales\Eshop\Application\Model\OrderArticle;
|
|
|
|
use OxidEsales\Eshop\Core\Registry;
|
|
|
|
|
2018-01-25 11:30:17 +01:00
|
|
|
class d3_dev_oxbasket extends d3_dev_oxbasket_parent
|
|
|
|
{
|
|
|
|
public function deleteBasket()
|
|
|
|
{
|
2018-02-23 12:30:57 +01:00
|
|
|
if (Registry::getConfig()->getActiveShop()->isProductiveMode()
|
2018-01-25 11:30:17 +01:00
|
|
|
|| false == Registry::getConfig()->getConfigParam('blD3DevAvoidDelBasket')
|
|
|
|
) {
|
|
|
|
parent::deleteBasket();
|
|
|
|
}
|
|
|
|
|
|
|
|
// else do nothing;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function d3ClearBasketItemArticles()
|
|
|
|
{
|
|
|
|
/** @var d3_dev_oxbasketitem $oBasketItem */
|
|
|
|
foreach ($this->_aBasketContents as $oBasketItem) {
|
|
|
|
$oBasketItem->d3ClearArticle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculates total basket discount value.
|
|
|
|
*/
|
|
|
|
protected function _calcBasketTotalDiscount()
|
|
|
|
{
|
|
|
|
if ($this->_oTotalDiscount === null || (!$this->isAdmin())) {
|
|
|
|
$this->_oTotalDiscount = $this->_getPriceObject();
|
|
|
|
|
|
|
|
if (is_array($this->_aDiscounts)) {
|
|
|
|
foreach ($this->_aDiscounts as $oDiscount) {
|
|
|
|
// skipping bundle discounts
|
|
|
|
if ($oDiscount->sType == 'itm') {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// add discount value to total basket discount
|
|
|
|
$this->_oTotalDiscount->add($oDiscount->dDiscount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-16 14:56:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param OrderArticle $oOrderArticle
|
|
|
|
*
|
|
|
|
* @return |null
|
|
|
|
* @throws \oxArticleInputException
|
|
|
|
* @throws \oxNoArticleException
|
|
|
|
*/
|
|
|
|
public function d3addOrderArticleToBasket($oOrderArticle)
|
|
|
|
{
|
|
|
|
// adding only if amount > 0
|
|
|
|
if ($oOrderArticle->oxorderarticles__oxamount->value > 0) {
|
|
|
|
$this->_isForOrderRecalculation = true;
|
|
|
|
$sItemId = $oOrderArticle->getId();
|
|
|
|
|
|
|
|
//inserting new
|
|
|
|
/** @var d3_dev_oxbasketitem $oBasketItem */
|
|
|
|
$oBasketItem = oxNew( BasketItem::class);
|
|
|
|
$oBasketItem->initFromOrderArticle($oOrderArticle);
|
|
|
|
$oBasketItem->d3ConvertToArticleObject();
|
|
|
|
$oBasketItem->setWrapping($oOrderArticle->oxorderarticles__oxwrapid->value);
|
|
|
|
$oBasketItem->setBundle($oOrderArticle->isBundle());
|
|
|
|
|
|
|
|
$this->_aBasketContents[$sItemId] = $oBasketItem;
|
|
|
|
|
|
|
|
//calling update method
|
|
|
|
$this->onUpdate();
|
|
|
|
|
|
|
|
return $this->_aBasketContents[$sItemId];
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
2018-01-25 11:30:17 +01:00
|
|
|
}
|