2018-01-25 11:30:17 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2024-09-04 08:58:40 +02:00
|
|
|
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
2018-01-25 11:30:17 +01:00
|
|
|
*
|
2024-09-04 08:58:40 +02:00
|
|
|
* For the full copyright and license information, please view
|
|
|
|
* the LICENSE file that was distributed with this source code.
|
2018-01-25 11:30:17 +01:00
|
|
|
*
|
2024-09-04 08:58:40 +02:00
|
|
|
* https://www.d3data.de
|
2018-01-25 11:30:17 +01:00
|
|
|
*
|
2024-09-04 08:58:40 +02:00
|
|
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
|
|
|
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
|
|
|
* @link https://www.oxidmodule.com
|
2018-01-25 11:30:17 +01:00
|
|
|
*/
|
|
|
|
|
2019-10-16 14:56:55 +02:00
|
|
|
namespace D3\Devhelper\Modules\Application\Model;
|
|
|
|
|
2020-11-11 22:29:10 +01:00
|
|
|
use D3\Devhelper\Modules\Core\d3_dev_conf;
|
|
|
|
use oxArticleInputException;
|
2019-10-16 14:56:55 +02:00
|
|
|
use OxidEsales\Eshop\Application\Model\BasketItem;
|
|
|
|
use OxidEsales\Eshop\Application\Model\OrderArticle;
|
|
|
|
use OxidEsales\Eshop\Core\Registry;
|
2020-11-11 22:29:10 +01:00
|
|
|
use oxNoArticleException;
|
2019-10-16 14:56:55 +02:00
|
|
|
|
2018-01-25 11:30:17 +01:00
|
|
|
class d3_dev_oxbasket extends d3_dev_oxbasket_parent
|
|
|
|
{
|
|
|
|
public function deleteBasket()
|
|
|
|
{
|
2024-09-04 08:58:40 +02:00
|
|
|
if (Registry::getConfig()->getActiveShop()->isProductiveMode()
|
|
|
|
|| ! Registry::getConfig()->getConfigParam(d3_dev_conf::OPTION_PREVENTDELBASKET)
|
2018-01-25 11:30:17 +01:00
|
|
|
) {
|
|
|
|
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
|
|
|
|
*
|
2020-11-12 08:50:36 +01:00
|
|
|
* @return d3_dev_oxbasketitem|null
|
2020-11-11 22:29:10 +01:00
|
|
|
* @throws oxArticleInputException
|
|
|
|
* @throws oxNoArticleException
|
2019-10-16 14:56:55 +02:00
|
|
|
*/
|
|
|
|
public function d3addOrderArticleToBasket($oOrderArticle)
|
|
|
|
{
|
|
|
|
// adding only if amount > 0
|
2020-11-11 22:29:10 +01:00
|
|
|
if ($oOrderArticle->getFieldData('oxamount') > 0) {
|
2019-10-16 14:56:55 +02:00
|
|
|
$this->_isForOrderRecalculation = true;
|
|
|
|
$sItemId = $oOrderArticle->getId();
|
|
|
|
|
|
|
|
//inserting new
|
|
|
|
/** @var d3_dev_oxbasketitem $oBasketItem */
|
2024-09-04 08:58:40 +02:00
|
|
|
$oBasketItem = oxNew(BasketItem::class);
|
2019-10-16 14:56:55 +02:00
|
|
|
$oBasketItem->initFromOrderArticle($oOrderArticle);
|
|
|
|
$oBasketItem->d3ConvertToArticleObject();
|
2020-11-11 22:29:10 +01:00
|
|
|
$oBasketItem->setWrapping($oOrderArticle->getFieldData('oxwrapid'));
|
2019-10-16 14:56:55 +02:00
|
|
|
$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
|
|
|
}
|