Merge remote-tracking branch 'remotes/origin/rel_2.x'

This commit is contained in:
Daniel Seifert 2019-10-17 15:51:50 +02:00
commit 687e2bbee0
5 changed files with 176 additions and 37 deletions

View File

@ -40,7 +40,12 @@ class d3_dev_thankyou extends d3_dev_thankyou_parent
parent::init();
Registry::getSession()->setVariable('sess_challenge', $sSessChallenge);
if (Registry::get(Request::class)->getRequestEscapedParameter("d3dev")
&& false == (bool) Registry::getConfig()->getActiveShop()->isProductiveMode()
&& Registry::getConfig()->getConfigParam('blD3DevAvoidDelBasket')
) {
Registry::getSession()->setVariable( 'sess_challenge', $sSessChallenge );
}
if (Registry::get(Request::class)->getRequestEscapedParameter("d3dev")
&& false == (bool) Registry::getConfig()->getActiveShop()->isProductiveMode()
@ -96,6 +101,27 @@ class d3_dev_thankyou extends d3_dev_thankyou_parent
}
}
/**
* @return bool|d3_dev_oxorder|\oxOrder
* @throws DatabaseConnectionException
* @throws DatabaseErrorException
*/
public function getOrder()
{
$oOrder = parent::getOrder();
if ((false == $oOrder || !$oOrder->getFieldData('oxordernr'))
&& Registry::get(Request::class)->getRequestEscapedParameter("d3dev")
&& false == (bool) Registry::getConfig()->getActiveShop()->isProductiveMode()
&& Registry::getConfig()->getConfigParam('blD3DevShowThankyou')
) {
$this->_oOrder = $this->d3GetLastOrder();
$oOrder = $this->_oOrder;
}
return $oOrder;
}
/**
* @return bool|d3_dev_oxorder
* @throws DatabaseConnectionException

View File

@ -1,9 +1,5 @@
<?php
namespace D3\Devhelper\Modules\Application\Model;
use OxidEsales\Eshop\Core\Registry;
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
@ -19,6 +15,12 @@ use OxidEsales\Eshop\Core\Registry;
* @link http://www.oxidmodule.com
*/
namespace D3\Devhelper\Modules\Application\Model;
use OxidEsales\Eshop\Application\Model\BasketItem;
use OxidEsales\Eshop\Application\Model\OrderArticle;
use OxidEsales\Eshop\Core\Registry;
class d3_dev_oxbasket extends d3_dev_oxbasket_parent
{
public function deleteBasket()
@ -61,4 +63,37 @@ class d3_dev_oxbasket extends d3_dev_oxbasket_parent
}
}
}
/**
* @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;
}
}

View File

@ -16,6 +16,12 @@
namespace D3\Devhelper\Modules\Application\Model;
use OxidEsales\Eshop\Application\Model\Article;
use OxidEsales\Eshop\Application\Model\OrderArticle;
use OxidEsales\Eshop\Core\Exception\ArticleException;
use OxidEsales\Eshop\Core\Exception\ArticleInputException;
use OxidEsales\Eshop\Core\Exception\NoArticleException;
class d3_dev_oxbasketitem extends d3_dev_oxbasketitem_parent
{
public function d3ClearArticle()
@ -25,9 +31,9 @@ class d3_dev_oxbasketitem extends d3_dev_oxbasketitem_parent
/**
* @return string
* @throws \OxidEsales\Eshop\Core\Exception\ArticleException
* @throws \OxidEsales\Eshop\Core\Exception\ArticleInputException
* @throws \OxidEsales\Eshop\Core\Exception\NoArticleException
* @throws ArticleException
* @throws ArticleInputException
* @throws NoArticleException
*/
public function getTitle()
{
@ -40,4 +46,19 @@ class d3_dev_oxbasketitem extends d3_dev_oxbasketitem_parent
return $this->_sTitle;
}
/**
* @throws \oxArticleInputException
* @throws \oxNoArticleException
*/
public function d3ConvertToArticleObject()
{
$oEmbeddedArticle = $this->getArticle();
if ($oEmbeddedArticle instanceof OrderArticle) {
$oArticle = oxNew(Article::class);
$oArticle->load($oEmbeddedArticle->getFieldData('oxartid'));
$this->_oArticle = $oArticle;
}
}
}

View File

@ -1,16 +1,5 @@
<?php
namespace D3\Devhelper\Modules\Application\Model;
use OxidEsales\Eshop\Application\Model\OrderArticle;
use OxidEsales\Eshop\Application\Model\Voucher;
use OxidEsales\Eshop\Core\DatabaseProvider;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
use OxidEsales\Eshop\Core\Model\ListModel;
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\Eshop\Core\Request;
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
@ -26,6 +15,16 @@ use OxidEsales\Eshop\Core\Request;
* @link http://www.oxidmodule.com
*/
namespace D3\Devhelper\Modules\Application\Model;
use OxidEsales\Eshop\Application\Model\Voucher;
use OxidEsales\Eshop\Core\DatabaseProvider;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
use OxidEsales\Eshop\Core\Model\ListModel;
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\Eshop\Core\Request;
class d3_dev_oxorder extends d3_dev_oxorder_parent
{
/**
@ -36,18 +35,9 @@ class d3_dev_oxorder extends d3_dev_oxorder_parent
/** @var d3_dev_oxbasket $oBasket */
$oBasket = $this->_getOrderBasket();
// unsetting bundles
/** @var ListModel $oOrderArticles */
$oOrderArticles = $this->getOrderArticles();
foreach ($oOrderArticles as $sItemId => $oItem) {
/** @var $oItem OrderArticle */
if ($oItem->isBundle()) {
$oOrderArticles->offsetUnset($sItemId);
}
}
// add this order articles to basket and recalculate basket
$this->_addOrderArticlesToBasket($oBasket, $oOrderArticles);
$this->_d3AddOrderArticlesToBasket($oBasket, $this->getOrderArticles());
// recalculating basket
$oBasket->calculateBasket(true);
$oBasket->d3ClearBasketItemArticles();
@ -66,7 +56,7 @@ class d3_dev_oxorder extends d3_dev_oxorder_parent
$orderNr = (int) Registry::get(Request::class)->getRequestEscapedParameter('d3ordernr');
$sWhere = 1;
if ($orderNr) {
$sWhere = ' oxordernr = ' . $orderNr;
$sWhere = ' oxordernr = ' . DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC)->quote($orderNr);
}
$sSelect = "SELECT oxid FROM ".getViewName('oxorder')." WHERE ".$sWhere." ORDER BY oxorderdate DESC LIMIT 1";
@ -114,4 +104,21 @@ class d3_dev_oxorder extends d3_dev_oxorder_parent
$this->_aVoucherList[$oVoucher->getId()] = $oVoucher;
}
}
/**
* Adds order articles back to virtual basket. Needed for recalculating order.
*
* @param d3_dev_oxbasket $oBasket basket object
* @param ListModel $aOrderArticles order articles
*/
protected function _d3AddOrderArticlesToBasket($oBasket, $aOrderArticles)
{
// if no order articles, return empty basket
if (count($aOrderArticles) > 0) {
//adding order articles to basket
foreach ($aOrderArticles as $oOrderArticle) {
$oBasket->d3addOrderArticleToBasket($oOrderArticle);
}
}
}
}

View File

@ -1,10 +1,5 @@
<?php
namespace D3\Devhelper\Modules\Core;
use D3\Devhelper\Modules\Application\Model as ModuleModel;
use OxidEsales\Eshop\Core\Registry;
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
@ -20,6 +15,12 @@ use OxidEsales\Eshop\Core\Registry;
* @link http://www.oxidmodule.com
*/
namespace D3\Devhelper\Modules\Core;
use D3\Devhelper\Modules\Application\Model as ModuleModel;
use OxidEsales\Eshop\Core\Exception\StandardException;
use OxidEsales\Eshop\Core\Registry;
class d3_dev_oxemail extends d3_dev_oxemail_parent
{
/**
@ -94,7 +95,7 @@ class d3_dev_oxemail extends d3_dev_oxemail_parent
*
* @return mixed|string
*/
public function d3GetInquiryMailContent($oInquiry, $sType)
public function d3GetInquiryMailContent($oInquiry, $sType )
{
if (Registry::getConfig()->getActiveShop()->isProductiveMode()) {
return '';
@ -154,6 +155,10 @@ class d3_dev_oxemail extends d3_dev_oxemail_parent
return $oSmarty->fetch($myConfig->getTemplatePath($sTpl, false));
}
/**
* @return bool
* @throws StandardException
*/
protected function _sendMail()
{
if (Registry::getConfig()->getActiveShop()->isProductiveMode()) {
@ -161,6 +166,8 @@ class d3_dev_oxemail extends d3_dev_oxemail_parent
}
$this->d3clearRecipients();
$this->d3clearReplies();
$this->d3clearReplyTo();
$this->d3clearCC();
$this->d3clearBCC();
@ -190,6 +197,44 @@ class d3_dev_oxemail extends d3_dev_oxemail_parent
$this->_aRecipients = $aRecipients;
}
public function d3clearReplies()
{
$aRecipients = array();
if (is_array($this->_aReplies) && count($this->_aReplies)) {
foreach ($this->_aReplies as $aRecInfo) {
if (($sNewRecipient = $this->getNewRecipient($aRecInfo[0]))
&& $sNewRecipient != $aRecInfo[0]
) {
$aRecInfo[1] = $aRecInfo[1]." (".$aRecInfo[0].")";
$aRecInfo[0] = $sNewRecipient;
$aRecipients[] = $aRecInfo;
} elseif (($sNewRecipient = $this->getNewRecipient($aRecInfo[0]))) {
$aRecipients[] = $aRecInfo;
}
}
}
$this->_aReplies = $aRecipients;
}
public function d3clearReplyTo()
{
$aRecipients = array();
if (is_array($this->ReplyTo) && count($this->ReplyTo)) {
foreach ($this->ReplyTo as $aRecInfo) {
if (($sNewRecipient = $this->getNewRecipient($aRecInfo[0]))
&& $sNewRecipient != $aRecInfo[0]
) {
$aRecInfo[1] = $aRecInfo[1]." (".$aRecInfo[0].")";
$aRecInfo[0] = $sNewRecipient;
$aRecipients[] = $aRecInfo;
} elseif (($sNewRecipient = $this->getNewRecipient($aRecInfo[0]))) {
$aRecipients[] = $aRecInfo;
}
}
}
$this->ReplyTo = $aRecipients;
}
public function d3clearCC()
{
$aCc = array();
@ -230,6 +275,11 @@ class d3_dev_oxemail extends d3_dev_oxemail_parent
$this->bcc = $aCc;
}
/**
* @param $sMailAddress
*
* @return bool|string
*/
public function getNewRecipient($sMailAddress)
{
if (Registry::getConfig()->getConfigParam('blD3DevBlockMails')) {