extend sending order mails

This commit is contained in:
Daniel Seifert 2022-07-04 16:33:49 +02:00
parent f3402e6393
commit 4676d57ee2
Signed by: DanielS
GPG Key ID: 8A7C4C6ED1915C6F
13 changed files with 455 additions and 58 deletions

View File

@ -85,19 +85,16 @@ class AdminOrder extends AdminController
$order = oxNew(Order::class);
$order->load($this->getEditObjectId());
$sms = oxNew(Sms::class);
if ($sms->sendOrderMessage($order, $messageBody)) {
$this->setRemark( $messageBody );
Registry::getUtilsView()->addErrorToDisplay(
sprintf(
Registry::getLang()->translateString('D3LM_EXC_SMS_SUCC_SENT'),
$sms->getResponse()->getSmsCount()
)
);
} else {
Registry::getUtilsView()->addErrorToDisplay(
Registry::getLang()->translateString('D3LM_EXC_MESSAGE_UNEXPECTED_ERR_SEND')
);
try {
$sms = oxNew( Sms::class );
if ( $sms->sendOrderMessage( $order, $messageBody ) ) {
$this->setRemark( $messageBody );
Registry::getUtilsView()->addErrorToDisplay( sprintf( Registry::getLang()->translateString( 'D3LM_EXC_SMS_SUCC_SENT' ), $sms->getResponse()->getSmsCount() ) );
} else {
Registry::getUtilsView()->addErrorToDisplay( Registry::getLang()->translateString( 'D3LM_EXC_MESSAGE_UNEXPECTED_ERR_SEND' ) );
}
} catch (noRecipientFoundException $e) {
Registry::getUtilsView()->addErrorToDisplay($e);
}
}

View File

@ -0,0 +1,76 @@
<?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 (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link http://www.oxidmodule.com
*/
namespace D3\Linkmobility4OXID\Application\Model;
use D3\Linkmobility4OXID\Application\Model\Exceptions\noRecipientFoundException;
use D3\LinkmobilityClient\Client;
use D3\LinkmobilityClient\Request\RequestInterface;
use D3\LinkmobilityClient\ValueObject\Sender;
use Exception;
use OxidEsales\Eshop\Application\Model\Order;
use OxidEsales\Eshop\Application\Model\Remark;
use OxidEsales\Eshop\Core\Registry;
class MessageSender
{
/**
* @param Order $order
* @param $messageBody
*
* @throws Exception
*/
public function sendOrderMessage(Order $order, $messageBody)
{
if (false === (bool) Registry::getConfig()->getConfigParam('d3linkmobility_orderActive') ||
trim(strlen($messageBody)) < 1
) {
return;
}
try {
$sms = oxNew( Sms::class );
if ( $sms->sendOrderMessage( $order, $messageBody ) ) {
$this->setRemark( $order->getId(), $messageBody );
}
} catch (noRecipientFoundException $e) {}
}
/**
* @param $orderId
* @param $message
*
* @throws Exception
*/
protected function setRemark($orderId, $message)
{
$remark = oxNew( Remark::class );
$remark->assign( [
'oxtype' => 'LMSMS',
'oxparentid' => $orderId,
'oxtext' => $message
] );
$remark->save();
}
public function sendContactMessage($email, $subject, $message)
{
$lmClient = oxNew(Client::class, 'token');
$request = oxNew(Request::class, oxNew(Sender::class, 'sender'), oxNew(SmsMessage::class, $message));
$request->setMethod(RequestInterface::METHOD_POST);
$response = $lmClient->request($request);
dumpvar($response);
}
}

View File

@ -13,9 +13,8 @@
* @link http://www.oxidmodule.com
*/
namespace D3\Linkmobility4OXID\Modules\Application\Model;
namespace D3\Linkmobility4OXID\Application\Model;
use D3\Linkmobility4OXID\Application\Model\Configuration;
use D3\LinkmobilityClient\Request\RequestInterface;
use D3\LinkmobilityClient\SMS\SmsRequestInterface;
use D3\LinkmobilityClient\ValueObject\Sender;

View File

@ -17,7 +17,7 @@ namespace D3\Linkmobility4OXID\Application\Model;
use D3\Linkmobility4OXID\Application\Model\Exceptions\abortSendingExceptionInterface;
use D3\Linkmobility4OXID\Application\Model\Exceptions\noRecipientFoundException;
use D3\Linkmobility4OXID\Modules\Application\Model\RequestFactory;
use D3\Linkmobility4OXID\Application\Model\RequestFactory;
use D3\LinkmobilityClient\Exceptions\ApiException;
use D3\LinkmobilityClient\Request\RequestInterface;
use D3\LinkmobilityClient\Response\ResponseInterface;
@ -54,9 +54,10 @@ class Sms
/**
* @param Order $order
* @param $message
* @param $message
*
* @return bool
* @throws noRecipientFoundException
*/
public function sendOrderMessage(Order $order, $message): bool
{
@ -67,10 +68,8 @@ class Sms
);
} catch (noRecipientFoundException $e) {
Registry::getLogger()->warning($e->getMessage());
Registry::getUtilsView()->addErrorToDisplay($e);
throw $e;
}
return false;
}
/**

View File

@ -1,34 +0,0 @@
<?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 (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link http://www.oxidmodule.com
*/
namespace D3\Linkmobility4OXID\Application\Model;
use D3\LinkmobilityClient\Client;
use D3\LinkmobilityClient\Request\RequestInterface;
use D3\LinkmobilityClient\SMS\Request;
use D3\LinkmobilityClient\ValueObject\Sender;
use D3\LinkmobilityClient\ValueObject\SmsMessage;
class contactMessageSender
{
public function send($email, $subject, $message)
{
$lmClient = oxNew(Client::class, 'token');
$request = oxNew(Request::class, oxNew(Sender::class, 'sender'), oxNew(SmsMessage::class, $message));
$request->setMethod(RequestInterface::METHOD_POST);
$response = $lmClient->request($request);
dumpvar($response);
}
}

View File

@ -23,7 +23,7 @@
<label for="recipient">[{oxmultilang ident="D3LM_ADMIN_USER_RECIPIENT"}]</label>
</td>
<td class="edittext">
<input type="text" id="recipient" name="recipient" class="editinput" size="60" value="[{$oView->getRecipientFromCurrentUser()}]" readonly disabled>
<input type="text" id="recipient" name="recipient" class="editinput" size="60" value="[{$recipient}]" readonly disabled>
</td>
</tr>
<tr>

View File

@ -0,0 +1,247 @@
[{assign var="shop" value=$oEmailView->getShop()}]
[{assign var="oViewConf" value=$oEmailView->getViewConfig()}]
[{assign var="currency" value=$oEmailView->getCurrency()}]
[{assign var="user" value=$oEmailView->getUser()}]
[{assign var="oDelSet" value=$order->getDelSet()}]
[{assign var="basket" value=$order->getBasket()}]
[{assign var="payment" value=$order->getPayment()}]
[{assign var="sOrderId" value=$order->getId()}]
[{assign var="oOrderFileList" value=$oEmailView->getOrderFileList($sOrderId)}]
[{block name="email_plain_order_cust_orderemail"}]
[{if $payment->oxuserpayments__oxpaymentsid->value == "oxempty"}]
[{oxcontent ident="oxuserordernpplainemail"}]
[{else}]
[{oxcontent ident="oxuserorderplainemail"}]
[{/if}]
[{/block}]
[{oxmultilang ident="ORDER_NUMBER"}] [{$order->oxorder__oxordernr->value}]
[{assign var="basketitemlist" value=$basket->getBasketArticles()}]
[{foreach key=basketindex from=$basket->getContents() item=basketitem}]
[{block name="email_plain_order_cust_basketitem"}]
[{assign var="basketproduct" value=$basketitemlist.$basketindex}]
[{block name="email_plain_order_cust_title"}][{$basketproduct->oxarticles__oxtitle->getRawValue()|strip_tags}][{if $basketproduct->oxarticles__oxvarselect->value}], [{$basketproduct->oxarticles__oxvarselect->value}][{/if}][{/block}]
[{block name="email_plain_order_cust_sellist"}][{if $basketitem->getChosenSelList()}][{foreach from=$basketitem->getChosenSelList() item=oList}]
[{$oList->name}] [{$oList->value}]
[{/foreach}][{/if}][{/block}]
[{block name="email_plain_order_cust_persparams"}][{if $basketitem->getPersParams()}]
[{foreach key=sVar from=$basketitem->getPersParams() item=aParam}]
[{$sVar}] : [{$aParam}]
[{/foreach}]
[{/if}][{/block}]
[{if $oViewConf->getShowGiftWrapping()}]
[{assign var="oWrapping" value=$basketitem->getWrapping()}]
[{oxmultilang ident="GIFT_WRAPPING"}] [{if !$basketitem->getWrappingId()}][{oxmultilang ident="NONE"}][{else}][{$oWrapping->oxwrapping__oxname->value}][{/if}]
[{/if}]
[{block name="email_plain_order_cust_orderinfo"}][{if $basketproduct->oxarticles__oxorderinfo->value}]
[{$basketproduct->oxarticles__oxorderinfo->getRawValue()}]
[{/if}][{/block}]
[{assign var=dRegUnitPrice value=$basketitem->getRegularUnitPrice()}]
[{assign var=dUnitPrice value=$basketitem->getUnitPrice()}]
[{block name="email_plain_order_cust_unitprice"}][{oxmultilang ident="UNIT_PRICE"}] [{$basketitem->getFUnitPrice()}] [{$currency->name}] [{if !$basketitem->isBundle()}][{if $dRegUnitPrice->getPrice() > $dUnitPrice->getPrice()}] ([{$basketitem->getFRegularUnitPrice()}] [{$currency->sign}]) [{/if}][{/if}][{/block}]
[{block name="email_plain_order_cust_amount"}][{oxmultilang ident="QUANTITY"}] [{$basketitem->getAmount()}][{/block}]
[{block name="email_plain_order_cust_vat"}][{oxmultilang ident="VAT"}] [{$basketitem->getVatPercent()}]%[{/block}]
[{block name="email_plain_order_cust_price"}][{oxmultilang ident="TOTAL"}] [{$basketitem->getFTotalPrice()}] [{$currency->name}][{/block}]
[{/block}]
[{/foreach}]
------------------------------------------------------------------
[{if !$basket->getDiscounts()}]
[{block name="email_plain_order_cust_nodiscounttotalnet"}]
[{* netto price *}]
[{oxmultilang ident="TOTAL_NET"}] [{$basket->getProductsNetPrice()}] [{$currency->name}]
[{/block}]
[{block name="email_plain_order_cust_nodiscountproductvats"}]
[{* VATs *}]
[{foreach from=$basket->getProductVats() item=VATitem key=key}]
[{oxmultilang ident="VAT_PLUS_PERCENT_AMOUNT" suffix="COLON" args=$key}] [{$VATitem}] [{$currency->name}]
[{/foreach}]
[{/block}]
[{block name="email_plain_order_cust_nodiscounttotalgross"}]
[{* brutto price *}]
[{oxmultilang ident="TOTAL_GROSS"}] [{$basket->getFProductsPrice()}] [{$currency->name}]
[{/block}]
[{/if}]
[{* applied discounts *}]
[{if $basket->getDiscounts()}]
[{if $order->isNettoMode()}]
[{block name="email_plain_order_ownerdiscounttotalnet"}]
[{* netto price *}]
[{oxmultilang ident="TOTAL_NET"}] [{$basket->getProductsNetPrice()}] [{$currency->name}]
[{/block}]
[{else}]
[{block name="email_plain_order_discountownertotalgross"}]
[{* brutto price *}]
[{oxmultilang ident="TOTAL_GROSS"}] [{$basket->getFProductsPrice()}] [{$currency->name}]
[{/block}]
[{/if}]
[{block name="email_plain_order_cust_discounts"}]
[{foreach from=$basket->getDiscounts() item=oDiscount}]
[{if $oDiscount->dDiscount < 0}][{oxmultilang ident="SURCHARGE"}][{else}][{oxmultilang ident="DISCOUNT"}][{/if}] [{$oDiscount->sDiscount}]: [{if $oDiscount->dDiscount < 0}][{$oDiscount->fDiscount|replace:"-":""}][{else}]-[{$oDiscount->fDiscount}][{/if}] [{$currency->name}]
[{/foreach}]
[{/block}]
[{if !$order->isNettoMode()}]
[{block name="email_plain_order_cust_totalnet"}]
[{* netto price *}]
[{oxmultilang ident="TOTAL_NET"}] [{$basket->getProductsNetPrice()}] [{$currency->name}]
[{/block}]
[{/if}]
[{block name="email_plain_order_cust_productvats"}]
[{* VATs *}]
[{foreach from=$basket->getProductVats() item=VATitem key=key}]
[{oxmultilang ident="VAT_PLUS_PERCENT_AMOUNT" suffix="COLON" args=$key}] [{$VATitem}] [{$currency->name}]
[{/foreach}]
[{/block}]
[{/if}]
[{if $order->isNettoMode()}]
[{block name="email_plain_order_ownertotalgross"}]
[{* brutto price *}]
[{oxmultilang ident="TOTAL_GROSS"}] [{$basket->getFProductsPrice()}] [{$currency->name}]
[{/block}]
[{/if}]
[{block name="email_plain_order_cust_voucherdiscount"}]
[{* voucher discounts *}]
[{if $oViewConf->getShowVouchers() && $basket->getVoucherDiscValue()}]
[{oxmultilang ident="COUPON"}] [{if $basket->getFVoucherDiscountValue() > 0}]-[{/if}][{$basket->getFVoucherDiscountValue()|replace:"-":""}] [{$currency->name}]
[{/if}]
[{/block}]
[{block name="email_plain_order_cust_delcosts"}]
[{* delivery costs *}]
[{if $basket->getDelCostNet()}]
[{oxmultilang ident="SHIPPING_NET" suffix="COLON"}] [{$basket->getDelCostNet()}] [{$currency->sign}]
[{if $basket->getDelCostVat()}] [{oxmultilang ident="BASKET_TOTAL_PLUS_PROPORTIONAL_VAT"}] [{else}] [{oxmultilang ident="VAT_PLUS_PERCENT_AMOUNT" suffix="COLON" args=$basket->getDelCostVatPercent()}][{/if}] [{$basket->getDelCostVat()}] [{$currency->sign}]
[{elseif $basket->getFDeliveryCosts()}]
[{oxmultilang ident="SHIPPING_COST"}] [{$basket->getFDeliveryCosts()}] [{$currency->sign}]
[{/if}]
[{/block}]
[{block name="email_plain_order_cust_paymentcosts"}]
[{* payment sum *}]
[{if $basket->getPayCostNet()}]
[{if $basket->getPaymentCosts() >= 0}][{oxmultilang ident="SURCHARGE"}][{else}][{oxmultilang ident="DEDUCTION"}][{/if}] [{oxmultilang ident="PAYMENT_METHOD"}] [{$basket->getPayCostNet()}] [{$currency->sign}]
[{if $basket->getPayCostVat()}]
[{if $basket->isProportionalCalculationOn()}] [{oxmultilang ident="BASKET_TOTAL_PLUS_PROPORTIONAL_VAT"}][{else}] [{oxmultilang ident="VAT_PLUS_PERCENT_AMOUNT" suffix="COLON" args=$basket->getPayCostVatPercent()}][{/if}] [{$basket->getPayCostVat()}] [{$currency->sign}]
[{/if}]
[{elseif $basket->getFPaymentCosts()}]
[{oxmultilang ident="SURCHARGE"}] [{$basket->getFPaymentCosts()}] [{$currency->sign}]
[{/if}]
[{/block}]
[{block name="email_plain_order_cust_wrappingcosts"}]
[{* Gift wrapping *}]
[{if $oViewConf->getShowGiftWrapping()}]
[{if $basket->getWrappCostNet()}]
[{oxmultilang ident="BASKET_TOTAL_WRAPPING_COSTS_NET"}] [{$basket->getWrappCostNet()}] [{$currency->sign}]
[{if $basket->getWrappCostVat()}]
[{oxmultilang ident="PLUS_VAT"}] [{$basket->getWrappCostVat()}] [{$currency->sign}]
[{/if}]
[{elseif $basket->getFWrappingCosts()}]
[{oxmultilang ident="GIFT_WRAPPING"}] [{$basket->getFWrappingCosts()}] [{$currency->sign}]
[{/if}]
[{/if}]
[{/block}]
[{block name="email_plain_order_cust_giftwrapping"}]
[{* Greeting card *}]
[{if $oViewConf->getShowGiftWrapping()}]
[{if $basket->getGiftCardCostNet()}]
[{oxmultilang ident="BASKET_TOTAL_GIFTCARD_COSTS_NET"}] [{$basket->getGiftCardCostNet()}] [{$currency->sign}]
[{if $basket->getGiftCardCostVat()}]
[{if $basket->isProportionalCalculationOn()}][{oxmultilang ident="BASKET_TOTAL_PLUS_PROPORTIONAL_VAT"}][{else}] [{oxmultilang ident="VAT_PLUS_PERCENT_AMOUNT" suffix="COLON" args=$basket->getGiftCardCostVatPercent()}][{/if}] [{$basket->getGiftCardCostVat()}] [{$currency->sign}]
[{/if}]
[{elseif $basket->getFGiftCardCosts()}]
[{oxmultilang ident="GREETING_CARD"}] [{$basket->getFGiftCardCosts()}] [{$currency->sign}]
[{/if}]
[{/if}]
[{/block}]
[{block name="email_plain_order_cust_grandtotal"}]
[{* grand total price *}]
[{oxmultilang ident="GRAND_TOTAL"}] [{$basket->getFPrice()}] [{$currency->name}]
[{if $basket->getCard()}]
[{oxmultilang ident="YOUR_GREETING_CARD"}]
[{$basket->getCardMessage()}]
[{/if}]
[{/block}]
[{block name="email_plain_order_cust_userremark"}]
[{if $order->oxorder__oxremark->value}]
[{oxmultilang ident="WHAT_I_WANTED_TO_SAY"}] [{$order->oxorder__oxremark->getRawValue()}]
[{/if}]
[{/block}]
[{block name="email_plain_order_cust_download_link"}]
[{if $oOrderFileList}]
[{oxmultilang ident="MY_DOWNLOADS_DESC"}]
[{foreach from=$oOrderFileList item="oOrderFile"}]
[{if $order->oxorder__oxpaid->value || !$oOrderFile->oxorderfiles__oxpurchasedonly->value}]
[{oxgetseourl ident=$oViewConf->getSelfLink()|cat:"cl=download" params="sorderfileid="|cat:$oOrderFile->getId()}]
[{else}]
[{$oOrderFile->oxorderfiles__oxfilename->value}] [{oxmultilang ident="DOWNLOADS_PAYMENT_PENDING"}]
[{/if}]
[{/foreach}]
[{/if}]
[{/block}]
[{block name="email_plain_order_cust_paymentinfo"}]
[{if $payment->oxuserpayments__oxpaymentsid->value != "oxempty"}]
[{oxmultilang ident="PAYMENT_METHOD"}] [{$payment->oxpayments__oxdesc->getRawValue()}] [{if $basket->getPaymentCosts()}]([{$basket->getFPaymentCosts()}] [{$currency->sign}])[{/if}]
[{/if}]
[{/block}]
[{block name="email_plain_order_cust_username"}]
[{oxmultilang ident="EMAIL_ADDRESS"}] [{$user->oxuser__oxusername->value}]
[{/block}]
[{block name="email_plain_order_cust_address"}]
[{oxmultilang ident="BILLING_ADDRESS"}]
[{$order->oxorder__oxbillcompany->getRawValue()}]
[{$order->oxorder__oxbillsal->value|oxmultilangsal}] [{$order->oxorder__oxbillfname->getRawValue()}] [{$order->oxorder__oxbilllname->getRawValue()}]
[{if $order->oxorder__oxbilladdinfo->value}][{$order->oxorder__oxbilladdinfo->getRawValue()}][{/if}]
[{$order->oxorder__oxbillstreet->getRawValue()}] [{$order->oxorder__oxbillstreetnr->value}]
[{$order->oxorder__oxbillstateid->value}]
[{$order->oxorder__oxbillzip->value}] [{$order->oxorder__oxbillcity->getRawValue()}]
[{$order->oxorder__oxbillcountry->getRawValue()}]
[{if $order->oxorder__oxbillustid->value}][{oxmultilang ident="VAT_ID_NUMBER"}] [{$order->oxorder__oxbillustid->value}][{/if}]
[{oxmultilang ident="PHONE"}] [{$order->oxorder__oxbillfon->value}]
[{if $order->oxorder__oxdellname->value}][{oxmultilang ident="SHIPPING_ADDRESS"}]
[{$order->oxorder__oxdelcompany->getRawValue()}]
[{$order->oxorder__oxdelsal->value|oxmultilangsal}] [{$order->oxorder__oxdelfname->getRawValue()}] [{$order->oxorder__oxdellname->getRawValue()}]
[{if $order->oxorder__oxdeladdinfo->value}][{$order->oxorder__oxdeladdinfo->getRawValue()}][{/if}]
[{$order->oxorder__oxdelstreet->getRawValue()}] [{$order->oxorder__oxdelstreetnr->value}]
[{$order->oxorder__oxdelstateid->getRawValue()}]
[{$order->oxorder__oxdelzip->value}] [{$order->oxorder__oxdelcity->getRawValue()}]
[{$order->oxorder__oxdelcountry->getRawValue()}]
[{/if}]
[{/block}]
[{block name="email_plain_order_cust_deliveryinfo"}]
[{if $payment->oxuserpayments__oxpaymentsid->value != "oxempty"}][{oxmultilang ident="SHIPPING_CARRIER" suffix="COLON"}] [{$order->oDelSet->oxdeliveryset__oxtitle->getRawValue()}]
[{/if}]
[{/block}]
[{block name="email_plain_order_cust_paymentinfo"}]
[{if $payment->oxuserpayments__oxpaymentsid->value == "oxidpayadvance"}]
[{oxmultilang ident="BANK"}] [{$shop->oxshops__oxbankname->getRawValue()}]<br>
[{oxmultilang ident="BANK_CODE"}] [{$shop->oxshops__oxbankcode->value}]<br>
[{oxmultilang ident="BANK_ACCOUNT_NUMBER"}] [{$shop->oxshops__oxbanknumber->value}]<br>
[{oxmultilang ident="BIC"}] [{$shop->oxshops__oxbiccode->value}]<br>
[{oxmultilang ident="IBAN"}] [{$shop->oxshops__oxibannumber->value}]
[{/if}]
[{/block}]
[{block name="email_plain_order_cust_orderemailend"}]
[{oxcontent ident="oxuserorderemailendplain"}]
[{/block}]
[{oxcontent ident="oxemailfooterplain"}]

View File

@ -18,4 +18,11 @@ namespace D3\Linkmobility4OXID\Modules\Application\Controller
class ContactController_parent extends ContactController {}
class StartController_parent extends StartController {}
}
namespace D3\Linkmobility4OXID\Modules\Core {
use OxidEsales\Eshop\Core\Email;
class EmailCore_parent extends Email{}
}

View File

@ -32,7 +32,7 @@ class ContactController extends ContactController_parent
$form->handleRequest($this->getMappedContactFormRequest());
if ($form->isValid()) {
$contactMessageSender = oxNew(contactMessageSender::class);
$contactMessageSender = oxNew(MessageSender::class);
$contactMessageSender->send(
$form->email->getValue(),
$form->subject->getValue(),

View File

@ -16,7 +16,10 @@
namespace D3\Linkmobility4OXID\Modules\Application\Controller;
use D3\Linkmobility4OXID\Application\Model\Sms;
use D3\Linkmobility4OXID\Modules\Core\EmailCore;
use OxidEsales\Eshop\Application\Model\Order;
use OxidEsales\Eshop\Application\Model\User;
use OxidEsales\Eshop\Core\Email;
class StartController extends StartController_parent
{
@ -25,6 +28,13 @@ class StartController extends StartController_parent
$message = "testMessagetestMessagetestMessagetestMessagetestMessagetestMessage";
//$message = "test\tMessage\ttest\tMessage";
$order = oxNew(Order::class);
$order->load('03444d89ad35b138c150003e69fdff34');
dumpvar(__METHOD__.__LINE__.PHP_EOL);
/** @var EmailCore $mail */
$mail = oxNew(Email::class);
$mail->d3SendOrderMessage($order);
die();
$user = oxNew(User::class);
$user->load('oxdefaultadmin');
$success = oxNew(Sms::class)->sendUserAccountMessage($user, $message);

View File

@ -0,0 +1,83 @@
<?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 (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link http://www.oxidmodule.com
*/
namespace D3\Linkmobility4OXID\Modules\Core;
use D3\Linkmobility4OXID\Application\Model\MessageSender;
use Exception;
use OxidEsales\Eshop\Application\Model\Order;
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererBridgeInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererInterface;
class EmailCore extends EmailCore_parent
{
protected $orderCustSmsTemplate = 'd3sms_ordercust.tpl';
/**
* @param Order $order
* @param null $subject
*
* @return bool
*/
public function sendOrderEmailToUser($order, $subject = null)
{
$ret = parent::sendOrderEmailToUser($order, $subject);
$this->d3SendOrderMessage($order);
return $ret;
}
/**
* @param Order $order
*
* @throws Exception
*/
public function d3SendOrderMessage(Order $order)
{
dumpvar($this->d3GetOrderSmsMessageBody($order));
die();
$messageSender = oxNew(MessageSender::class);
$messageSender->sendOrderMessage($order, $this->d3GetOrderSmsMessageBody($order));
}
/**
* @param Order $order
*
* @return string
*/
protected function d3GetOrderSmsMessageBody(Order $order): string
{
$renderer = $this->d3GetTplRenderer();
$this->setViewData("order", $order);
dumpvar($this->orderCustSmsTemplate);
return $renderer->renderTemplate($this->orderCustSmsTemplate, $this->getViewData());
}
/**
* Templating instance getter
*
* @return TemplateRendererInterface
*/
protected function d3GetTplRenderer()
{
$bridge = \OxidEsales\EshopCommunity\Internal\Container\ContainerFactory::getInstance()->getContainer()->get(TemplateRendererBridgeInterface::class);
$bridge->setEngine($this->_getSmarty());
return $bridge->getTemplateRenderer();
}
}

View File

@ -5,6 +5,9 @@
<SUBMENU id="mxusers" cl="admin_user" list="user_list">
<TAB id="tbcluser_linkmobility" cl="d3linkmobility_user" />
</SUBMENU>
<SUBMENU id="mxorders" cl="admin_orders" list="order_list">
<TAB id="tbclorder_linkmobility" cl="d3linkmobility_order" />
</SUBMENU>
</MAINMENU>
</OXMENU>
</OX>

View File

@ -5,6 +5,8 @@
use D3\Linkmobility4OXID\Application\Controller\Admin\AdminOrder;
use D3\Linkmobility4OXID\Application\Controller\Admin\AdminUser;
use D3\Linkmobility4OXID\Modules\Core\EmailCore;
use OxidEsales\Eshop\Core\Email;
$sMetadataVersion = '2.1';
$sModuleId = 'd3linkmobility';
@ -27,7 +29,8 @@ $aModule = [
'url' => 'https://www.oxidmodule.com/',
'extend' => [
\OxidEsales\Eshop\Application\Controller\StartController::class => \D3\Linkmobility4OXID\Modules\Application\Controller\StartController::class,
\OxidEsales\Eshop\Application\Controller\ContactController::class => \D3\Linkmobility4OXID\Modules\Application\Controller\ContactController::class
\OxidEsales\Eshop\Application\Controller\ContactController::class => \D3\Linkmobility4OXID\Modules\Application\Controller\ContactController::class,
Email::class => EmailCore::class
],
'controllers' => [
'd3linkmobility_user' => AdminUser::class,
@ -35,7 +38,8 @@ $aModule = [
],
'templates' => [
'd3adminuser.tpl' => 'd3/linkmobility/Application/views/admin/tpl/adminuser.tpl',
'd3adminorder.tpl' => 'd3/linkmobility/Application/views/admin/tpl/adminuser.tpl'
'd3adminorder.tpl' => 'd3/linkmobility/Application/views/admin/tpl/adminuser.tpl',
'd3sms_ordercust.tpl' => 'd3/linkmobility/Application/views/tpl/SMS/order_cust.tpl',
],
'events' => [],
'settings' => [
@ -62,6 +66,12 @@ $aModule = [
'name' => $sModuleId.'_smsSenderCountry',
'type' => 'str',
'value' => 'DE'
],
[
'group' => $sModuleId.'_order',
'name' => $sModuleId.'_orderActive',
'type' => 'bool',
'value' => false
]
]
];