+49 69 83008980 service@xqueue.com

Benötigen Sie Hilfe?

Code Snippets PHP

Sie sind hier:
< Alle Themen

 

About code snippets

The snippets provided here have been taken from larger code projects and will probably not run out of the box. Often configurations are included or other unknown objects will be accessed but the idea of the snippet should be clear.

 

Checking for missing custom contactfields

If you are about to just report the usage of customfields that do not exist the following snippet might be of help. It reads all used fields from a configuration array as it uses a mapping from some database columns to Maileon fields.

function checkForMissingCustomcontactfields() {
global $logHandler;

$contactsService = new \com_maileon_api_contacts_ContactsService($this->config['MAILEON']);
$contactsService->setDebug($this->config['DEBUG']);
$response = $contactsService->getCustomFields();

if (!$response->isSuccess()) {
$msg = "Unable to get customfields: " . $response->toString();
$logHandler->processFatalError(new \Exception($msg));
}

$missing = array();
foreach ($this->config['DB']['TABLES']['CONTACTS']['MAPPING'] as $key => $value) {
if ($value['TYPE'] == "CUSTOM" && !empty($value['MAILEON_FIELD_NAME']) && !array_key_exists($value['MAILEON_FIELD_NAME'], $response->getResult()->custom_fields)) {
$missing[] = $value['MAILEON_FIELD_NAME'];
}
}
if (sizeof($missing) > 0) {
$msg = "Missing custom contactfields: " . join($missing, ", ");
$logHandler->processFatalError(new \Exception($msg));
}
}

 

Creating custom contactfields if required

In this case we create a simple boolean custom field if not available.

<!DOCTYPE html>
<html class="no-js" lang="de-DE">
    <head>
                <link rel="profile" href="http://gmpg.org/xfn/11" />
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        
        <title>Maileon Developers « </title>
        
                <link rel='dns-prefetch' href='//d1n0x3qji82z53.cloudfront.net' />
<link rel='dns-prefetch' href='//platform-api.sharethis.com' />
<link rel='dns-prefetch' href='//ajax.googleapis.com' />
<link rel='dns-prefetch' href='//s.w.org' />
<link rel="alternate" type="application/rss+xml" title="Maileon Developers » Feed" href="https://dev.maileon.com/feed/" />
<link rel="alternate" type="application/rss+xml" title="Maileon Developers » Kommentar-Feed" href="https://dev.maileon.com/comments/feed/" />
        <script type="text/javascript">
            window._wpemojiSettings = {"baseUrl":"https:\/\/s.w.org\/images\/core\/emoji\/13.0.0\/72x72\/","ext":".png","svgUrl":"https:\/\/s.w.org\/images\/core\/emoji\/13.0.0\/svg\/","svgExt":".svg","source":{"concatemoji":"https:\/\/dev.maileon.com\/wp-includes\/js\/wp-emoji-release.min.js?ver=5.5"}};
            !function(e,a,t){var r,n,o,i,p=a.createElement("canvas"),s=p.getContext&&p.getContext("2d");function c(e,t){var a=String.fromCharCode;s.clearRect(0,0,p.width,p.height),s.fillText(a.apply(this,e),0,0);var r=p.toDataURL();return s.clearRect(0,0,p.width,p.height),s.fillText(a.apply(this,t),0,0),r===p.toDataURL()}function l(e){if(!s||!s.fillText)return!1;switch(s.textBaseline="top",s.font="600 32px Arial",e){case"flag":return!c([127987,65039,8205,9895,65039],[127987,65039,8203,9895,65039])&&(!c([55356,56826,55356,56819],[55356,56826,8203,55356,56819])&&!c([55356,57332,56128,56423,56128,56418,56128,56421,56128,56430,56128,56423,56128,56447],[55356,57332,8203,56128,56423,8203,56128,56418,8203,56128,56421,8203,56128,56430,8203,56128,56423,8203,56128,56447]));case"emoji":return!c([55357,56424,8205,55356,57212],[55357,56424,8203,55356,57212])}return!1}function d(e){var t=a.createElement("script");t.src=e,t.defer=t.type="text/javascript",a.getElementsByTagName("head")[0].appendChild(t)}for(i=Array("flag","emoji"),t.supports={everything:!0,everythingExceptFlag:!0},o=0;o<i.length;o++)t.supports[i[o]]=l(i[o]),t.supports.everything=t.supports.everything&&t.supports[i[o]],"flag"!==i[o]&&(t.supports.everythingExceptFlag=t.supports.everythingExceptFlag&&t.supports[i[o]]);t.supports.everythingExceptFlag=t.supports.everythingExceptFlag&&!t.supports.flag,t.DOMReady=!1,t.readyCallback=function(){t.DOMReady=!0},t.supports.everything||(n=function(){t.readyCallback()},a.addEventListener?(a.addEventListener("DOMContentLoaded",n,!1),e.addEventListener("load",n,!1)):(e.attachEvent("onload",n),a.attachEvent("onreadystatechange",function(){"complete"===a.readyState&&t.readyCallback()})),(r=t.source||{}).concatemoji?d(r.concatemoji):r.wpemoji&&r.twemoji&&(d(r.twemoji),d(r.wpemoji)))}(window,document,window._wpemojiSettings);
        </script>
        <style type="text/css">
img.wp-smiley,
img.emoji {
    display: inline !important;
    border: none !important;
    box-shadow: none !important;
    height: 1em !important;
    width: 1em !important;
    margin: 0 .07em !important;
    vertical-align: -0.1em !important;
    background: none !important;
    padding: 0 !important;
}
</style>
    <link rel='stylesheet' id='crayon-css'  href='https://dev.maileon.com/wp-content/plugins/crayon-syntax-highlighter/css/min/crayon.min.css?ver=_2.7.2_beta' type='text/css' media='all' />
<link rel='stylesheet' id='wp-block-library-css'  href='https://dev.maileon.com/wp-includes/css/dist/block-library/style.min.css?ver=5.5' type='text/css' media='all' />
<link rel='stylesheet' id='jquery-ui-standard-css-css'  href='//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css?ver=5.5' type='text/css' media='all' />
<link rel='stylesheet' id='ce_responsive-css'  href='https://dev.maileon.com/wp-content/plugins/simple-embed-code/css/video-container.min.css?ver=5.5' type='text/css' media='all' />
<link rel='stylesheet' id='toc-screen-css'  href='https://dev.maileon.com/wp-content/plugins/table-of-contents-plus/screen.min.css?ver=2002' type='text/css' media='all' />
<link rel='stylesheet' id='tw-bootstrap-css'  href='https://dev.maileon.com/wp-content/themes/the-bootstrap/css/bootstrap.min.css?ver=2.0.3' type='text/css' media='all' />
<link rel='stylesheet' id='the-bootstrap-css'  href='https://dev.maileon.com/wp-content/themes/the-bootstrap/style.min.css?ver=2.0.1' type='text/css' media='all' />
<link rel='stylesheet' id='maileon-contact-form-css-css'  href='https://dev.maileon.com/wp-content/plugins/xqueue-maileon/class/../css/maileon-contact-form.css?ver=5.5' type='text/css' media='all' />
<link rel='stylesheet' id='fancybox-css'  href='https://dev.maileon.com/wp-content/plugins/easy-fancybox/css/jquery.fancybox.min.css?ver=1.3.24' type='text/css' media='screen' />
<script type='text/javascript' src='https://dev.maileon.com/wp-includes/js/jquery/jquery.js?ver=1.12.4-wp' id='jquery-js'></script>
<script type='text/javascript' id='maileon-contact-form-widget-js-js-extra'>
/* <![CDATA[ */
var config = {"ajax_url":"https:\/\/dev.maileon.com\/wp-admin\/admin-ajax.php"};
/* ]]> */
</script>
<script type='text/javascript' src='https://dev.maileon.com/wp-content/plugins/xqueue-maileon/js/maileon-contact-form-widget.js?ver=5.5' id='maileon-contact-form-widget-js-js'></script>
<script type='text/javascript' id='crayon_js-js-extra'>
/* <![CDATA[ */
var CrayonSyntaxSettings = {"version":"_2.7.2_beta","is_admin":"0","ajaxurl":"https:\/\/dev.maileon.com\/wp-admin\/admin-ajax.php","prefix":"crayon-","setting":"crayon-setting","selected":"crayon-setting-selected","changed":"crayon-setting-changed","special":"crayon-setting-special","orig_value":"data-orig-value","debug":""};
var CrayonSyntaxStrings = {"copy":"Press %s to Copy, %s to Paste","minimize":"Click To Expand Code"};
/* ]]> */
</script>
<script type='text/javascript' src='https://dev.maileon.com/wp-content/plugins/crayon-syntax-highlighter/js/min/crayon.min.js?ver=_2.7.2_beta' id='crayon_js-js'></script>
<script type='text/javascript' src='http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js?ver=5.5' id='ace-js'></script>
<script type='text/javascript' src='//platform-api.sharethis.com/js/sharethis.js#product=ga&property=5efdd221f8f53a00131ec72b' id='googleanalytics-platform-sharethis-js'></script>
<script type='text/javascript' id='maileon-contact-form-js-js-extra'>
/* <![CDATA[ */
var maileon_ajax = {"url":"https:\/\/dev.maileon.com\/wp-admin\/admin-ajax.php"};
var maileon_ajax = {"url":"https:\/\/dev.maileon.com\/wp-admin\/admin-ajax.php"};
/* ]]> */
</script>
<script type='text/javascript' src='https://dev.maileon.com/wp-content/plugins/xqueue-maileon/class/../js/maileon-contact-form.js?ver=5.5' id='maileon-contact-form-js-js'></script>
<link rel="https://api.w.org/" href="https://dev.maileon.com/wp-json/" /><link rel="alternate" type="application/json" href="https://dev.maileon.com/wp-json/wp/v2/pages/2" /><link rel="EditURI" type="application/rsd+xml" title="RSD" href="https://dev.maileon.com/xmlrpc.php?rsd" />
<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="https://dev.maileon.com/wp-includes/wlwmanifest.xml" /> 
<meta name="generator" content="WordPress 5.5" />
<link rel="canonical" href="https://dev.maileon.com/" />
<link rel='shortlink' href='https://dev.maileon.com/' />
<link rel="alternate" type="application/json+oembed" href="https://dev.maileon.com/wp-json/oembed/1.0/embed?url=https%3A%2F%2Fdev.maileon.com%2F" />
<link rel="alternate" type="text/xml+oembed" href="https://dev.maileon.com/wp-json/oembed/1.0/embed?url=https%3A%2F%2Fdev.maileon.com%2F&format=xml" />
<script type="text/javascript" src="https://dev.maileon.com/wp-content/plugins/si-captcha-for-wordpress/captcha/si_captcha.js?ver=1599013147"></script>
<!-- begin SI CAPTCHA Anti-Spam - login/register form style -->
<style type="text/css">
.si_captcha_small { width:175px; height:45px; padding-top:10px; padding-bottom:10px; }
.si_captcha_large { width:250px; height:60px; padding-top:10px; padding-bottom:10px; }
img#si_image_com { border-style:none; margin:0; padding-right:5px; float:left; }
img#si_image_reg { border-style:none; margin:0; padding-right:5px; float:left; }
img#si_image_log { border-style:none; margin:0; padding-right:5px; float:left; }
img#si_image_side_login { border-style:none; margin:0; padding-right:5px; float:left; }
img#si_image_checkout { border-style:none; margin:0; padding-right:5px; float:left; }
img#si_image_jetpack { border-style:none; margin:0; padding-right:5px; float:left; }
img#si_image_bbpress_topic { border-style:none; margin:0; padding-right:5px; float:left; }
.si_captcha_refresh { border-style:none; margin:0; vertical-align:bottom; }
div#si_captcha_input { display:block; padding-top:15px; padding-bottom:5px; }
label#si_captcha_code_label { margin:0; }
input#si_captcha_code_input { width:65px; }
p#si_captcha_code_p { clear: left; padding-top:10px; }
.si-captcha-jetpack-error { color:#DC3232; }
</style>
<!-- end SI CAPTCHA Anti-Spam - login/register form style -->
<style type="text/css" id="custom-background-css">
body.custom-background { background-color: #efefef; }
</style>
        <!--[if lt IE 9]>
        <script src="https://dev.maileon.com/wp-content/themes/the-bootstrap/js/html5shiv.min.js" type="text/javascript"></script>
        <script src="https://dev.maileon.com/wp-content/themes/the-bootstrap/js/respond.min.js" type="text/javascript"></script>
    <![endif]-->
        </head>
    
    <body class="home page-template-default page page-id-2 custom-background content-sidebar">
        <div class="container">
            <div id="page" class="hfeed row">
                                <header id="branding" role="banner" class="span12">
                    <nav class="subnav clearfix"><ul id="menu-main" class="nav nav-pills pull-right"><li id="menu-item-667" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-667 dropdown" data-dropdown="dropdown"><a href="https://dev.maileon.com/api/" class="dropdown-toggle" data-toggle="dropdown">Docs <b class="caret"></b></a>
<ul class="dropdown-menu">
    <li id="menu-item-509" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-509"><a href="https://dev.maileon.com/api/rest-api-1-0/">Rest API v1.0</a></li>
    <li id="menu-item-2434" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2434"><a href="https://dev.maileon.com/api/maileon-api-clients/">API Clients</a></li>
    <li id="menu-item-2512" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2512"><a href="https://dev.maileon.com/api/webhooks-maileon/">Webhooks – Incoming (Calls from Third-Party- Application towards Maileon)</a></li>
    <li id="menu-item-2431" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2431"><a href="https://dev.maileon.com/api/webhooks_external/">Webhooks – Outgoing (Calls from Maileon to Third-Party-Webhoook)</a></li>
    <li id="menu-item-2435" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2435"><a href="https://dev.maileon.com/api/plugins/">Plugins</a></li>
    <li id="menu-item-3176" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-3176"><a href="https://dev.maileon.com/rss-feeds/">RSS Feeds</a></li>
    <li id="menu-item-3259" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-3259"><a href="https://dev.maileon.com/code-snippets/">Code Snippets</a></li>
</ul>
</li>
<li id="menu-item-2441" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2441"><a href="https://dev.maileon.com/newsletter/">Newsletter</a></li>
<li id="menu-item-2442" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2442"><a href="https://dev.maileon.com/wp-login.php?action=login">Login</a></li>
<li id="menu-item-2444" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2444"><a href="https://dev.maileon.com/sitemap/">Sitemap</a></li>
</ul></nav>					<hgroup>
                        <h1 id="site-title">
                            <a href="https://dev.maileon.com/" title="Maileon Developers" rel="home">
                                <span>Maileon Developers</span>
                            </a>
                        </h1>
                        <h2 id="site-description"></h2>
                    </hgroup>
                    
                                        <a id="header-image" href="https://dev.maileon.com/" title="Maileon Developers" rel="home">
                        <img src="https://dev.maileon.com/wp-content/uploads/copy-xqlogo.jpg" width="198" height="63" alt="" />
                    </a>
                    
                    <nav id="access" role="navigation">
                        <h3 class="assistive-text">Main menu</h3>
                        <div class="skip-link"><a class="assistive-text" href="#content" title="Skip to primary content">Skip to primary content</a></div>
                        <div class="skip-link"><a class="assistive-text" href="#secondary" title="Skip to secondary content">Skip to secondary content</a></div>
                                                <div class="navbar navbar-inverse">
                            <div class="navbar-inner">
                                <div class="container">
                                    <!-- .btn-navbar is used as the toggle for collapsed navbar content -->
                                    <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                                        <span class="icon-bar"></span>
                                        <span class="icon-bar"></span>
                                        <span class="icon-bar"></span>
                                    </a>
                                                                        <div class="nav-collapse">
                                        <div class="menu-main-container"><ul id="menu-main-1" class="nav"><li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-667 dropdown" data-dropdown="dropdown"><a href="https://dev.maileon.com/api/" class="dropdown-toggle" data-toggle="dropdown">Docs <b class="caret"></b></a>
<ul class="dropdown-menu">
    <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-509"><a href="https://dev.maileon.com/api/rest-api-1-0/">Rest API v1.0</a></li>
    <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2434"><a href="https://dev.maileon.com/api/maileon-api-clients/">API Clients</a></li>
    <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2512"><a href="https://dev.maileon.com/api/webhooks-maileon/">Webhooks – Incoming (Calls from Third-Party- Application towards Maileon)</a></li>
    <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2431"><a href="https://dev.maileon.com/api/webhooks_external/">Webhooks – Outgoing (Calls from Maileon to Third-Party-Webhoook)</a></li>
    <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2435"><a href="https://dev.maileon.com/api/plugins/">Plugins</a></li>
    <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-3176"><a href="https://dev.maileon.com/rss-feeds/">RSS Feeds</a></li>
    <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-3259"><a href="https://dev.maileon.com/code-snippets/">Code Snippets</a></li>
</ul>
</li>
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2441"><a href="https://dev.maileon.com/newsletter/">Newsletter</a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2442"><a href="https://dev.maileon.com/wp-login.php?action=login">Login</a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2444"><a href="https://dev.maileon.com/sitemap/">Sitemap</a></li>
</ul></div>	<form id="searchform" class="navbar-search pull-right" method="get" action="https://dev.maileon.com/">
                        <label for="s" class="assistive-text hidden">Search</label>
                        <input type="search" class="search-query" name="s" id="s" placeholder="Search" />
                    </form>								    </div>
                                </div>
                            </div>
                        </div>
                                            </nav><!-- #access -->
                                    </header><!-- #branding -->
<div id="primary" class="span8">
    <div class="breadcrumbs">
    </div>
    <div id="content" role="main">
        <article id="post-2" class="post-2 page type-page status-publish hentry">
        
    <header class="page-header">
        <h1 class="entry-title">Welcome Developers</h1>	</header><!-- .entry-header -->

    <div class="entry-content clearfix">
        <p>Read our technical documentations, learn how to connect your system to Maileon by using the API and more. Here you will find code samples, tutorials, tools and help for developers to integrate Maileon efficiently and easy into your own applications.</p>
<p>Please note that this portal is currently not complete as work on the API continues and new releases are published regularly. We suggest you check this documentation before you start working with the API or make changes to your existing API connection as ressources and methods may have changed.</p>
    </div><!-- .entry-content -->
    </article><!-- #post-2 -->
    </div><!-- #content -->
    </div><!-- #primary -->

<section id="secondary" class="widget-area span4" role="complementary">
    <aside id="recently_updated_pages-4" class="widget well Recently_Updated_Pages"><h2 class="widget-title">Change Log</h2><ul><li class='page_item page-item-316'><a href='https://dev.maileon.com/api/rest-api-1-0/' title='Rest API v1.0'>Rest API v1.0</a></li><li class='page_item page-item-2032'><a href='https://dev.maileon.com/api/rest-api-1-0/reports/get-unique-opens/' title='Get Unique Opens'>Get Unique Opens</a></li><li class='page_item page-item-311'><a href='https://dev.maileon.com/api/rest-api-1-0/reports/get-bounces/' title='Get Bounces'>Get Bounces</a></li><li class='page_item page-item-309'><a href='https://dev.maileon.com/api/rest-api-1-0/reports/get-opens/' title='Get Opens'>Get Opens</a></li><li class='page_item page-item-312'><a href='https://dev.maileon.com/api/rest-api-1-0/reports/get-unsubscriptions/' title='Get Unsubscriptions'>Get Unsubscriptions</a></li><li class='page_item page-item-1694'><a href='https://dev.maileon.com/api/rest-api-1-0/reports/get-subscribers/' title='Get Subscribers'>Get Subscribers</a></li><li class='page_item page-item-1848'><a href='https://dev.maileon.com/api/rest-api-1-0/reports/get-recipients/' title='Get Recipients'>Get Recipients</a></li><li class='page_item page-item-2151'><a href='https://dev.maileon.com/api/rest-api-1-0/reports/get-unique-bounces/' title='Get Unique Bounces'>Get Unique Bounces</a></li><li class='page_item page-item-2031'><a href='https://dev.maileon.com/api/rest-api-1-0/reports/get-unique-clicks/' title='Get Unique Clicks'>Get Unique Clicks</a></li><li class='page_item page-item-310'><a href='https://dev.maileon.com/api/rest-api-1-0/reports/draft-get-clicks/' title='Get Clicks'>Get Clicks</a></li></ul></aside></section><!-- #secondary .widget-area -->
                <footer id="colophon" role="contentinfo" class="span12">
                                        <div id="page-footer" class="well clearfix">
                        <nav class="subnav"><ul id="menu-main-2" class="credits nav nav-pills pull-left"><li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-667 dropdown" data-dropdown="dropdown"><a href="https://dev.maileon.com/api/" class="dropdown-toggle" data-toggle="dropdown">Docs <b class="caret"></b></a>
<ul class="dropdown-menu">
    <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-509"><a href="https://dev.maileon.com/api/rest-api-1-0/">Rest API v1.0</a></li>
    <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2434"><a href="https://dev.maileon.com/api/maileon-api-clients/">API Clients</a></li>
    <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2512"><a href="https://dev.maileon.com/api/webhooks-maileon/">Webhooks – Incoming (Calls from Third-Party- Application towards Maileon)</a></li>
    <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2431"><a href="https://dev.maileon.com/api/webhooks_external/">Webhooks – Outgoing (Calls from Maileon to Third-Party-Webhoook)</a></li>
    <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2435"><a href="https://dev.maileon.com/api/plugins/">Plugins</a></li>
    <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-3176"><a href="https://dev.maileon.com/rss-feeds/">RSS Feeds</a></li>
    <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-3259"><a href="https://dev.maileon.com/code-snippets/">Code Snippets</a></li>
</ul>
</li>
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2441"><a href="https://dev.maileon.com/newsletter/">Newsletter</a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2442"><a href="https://dev.maileon.com/wp-login.php?action=login">Login</a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2444"><a href="https://dev.maileon.com/sitemap/">Sitemap</a></li>
</ul></nav>						<div class="footer-logo" align="right">
                            <a href="http://www.xqueue.de" target="_blank">
                <img src="http://dev.maileon.com/wp-content/uploads/xqlogo.jpg">
                            </a>
                        </div>
                    </div><!-- #page-footer .well .clearfix -->
                                    </footer><!-- #colophon -->
                            </div><!-- #page -->
        </div><!-- .container -->
    <!-- 72 queries. 0,295 seconds. -->
    <script type='text/javascript' id='toc-front-js-extra'>
/* <![CDATA[ */
var tocplus = {"smooth_scroll":"1","visibility_show":"show","visibility_hide":"hide","visibility_hide_by_default":"1","width":"Auto"};
/* ]]> */
</script>
<script type='text/javascript' src='https://dev.maileon.com/wp-content/plugins/table-of-contents-plus/front.min.js?ver=2002' id='toc-front-js'></script>
<script type='text/javascript' src='https://dev.maileon.com/wp-content/themes/the-bootstrap/js/bootstrap.min.js?ver=2.0.3' id='tw-bootstrap-js'></script>
<script type='text/javascript' src='https://dev.maileon.com/wp-content/themes/the-bootstrap/js/the-bootstrap.min.js?ver=2.0.1' id='the-bootstrap-js'></script>
<script type='text/javascript' src='https://dev.maileon.com/wp-content/plugins/page-links-to/dist/new-tab.js?ver=3.3.4' id='page-links-to-js'></script>
<script type='text/javascript' src='https://dev.maileon.com/wp-content/plugins/easy-fancybox/js/jquery.fancybox.min.js?ver=1.3.24' id='jquery-fancybox-js'></script>
<script type='text/javascript' id='jquery-fancybox-js-after'>
var fb_timeout, fb_opts={'overlayShow':true,'hideOnOverlayClick':true,'showCloseButton':true,'margin':20,'centerOnScroll':true,'enableEscapeButton':true,'autoScale':true };
if(typeof easy_fancybox_handler==='undefined'){
var easy_fancybox_handler=function(){
jQuery('.nofancybox,a.wp-block-file__button,a.pin-it-button,a[href*="pinterest.com/pin/create"],a[href*="facebook.com/share"],a[href*="twitter.com/share"]').addClass('nolightbox');
/* IMG */
var fb_IMG_select='a[href*=".jpg"]:not(.nolightbox,li.nolightbox>a),area[href*=".jpg"]:not(.nolightbox),a[href*=".gif"]:not(.nolightbox,li.nolightbox>a),area[href*=".gif"]:not(.nolightbox),a[href*=".png"]:not(.nolightbox,li.nolightbox>a),area[href*=".png"]:not(.nolightbox)';
jQuery(fb_IMG_select).addClass('fancybox image').attr('rel','gallery');
jQuery('a.fancybox,area.fancybox,li.fancybox a').each(function(){jQuery(this).fancybox(jQuery.extend({},fb_opts,{'transitionIn':'elastic','easingIn':'easeOutBack','transitionOut':'elastic','easingOut':'easeInBack','opacity':false,'hideOnContentClick':false,'titleShow':true,'titlePosition':'over','titleFromAlt':true,'showNavArrows':true,'enableKeyboardNav':true,'cyclic':false}))});};
jQuery('a.fancybox-close').on('click',function(e){e.preventDefault();jQuery.fancybox.close()});
};
var easy_fancybox_auto=function(){setTimeout(function(){jQuery('#fancybox-auto').trigger('click')},1000);};
jQuery(easy_fancybox_handler);jQuery(document).on('post-load',easy_fancybox_handler);
jQuery(easy_fancybox_auto);
</script>
<script type='text/javascript' src='https://dev.maileon.com/wp-content/plugins/easy-fancybox/js/jquery.easing.min.js?ver=1.4.1' id='jquery-easing-js'></script>
<script type='text/javascript' src='https://dev.maileon.com/wp-content/plugins/easy-fancybox/js/jquery.mousewheel.min.js?ver=3.1.13' id='jquery-mousewheel-js'></script>
<script type='text/javascript' src='https://dev.maileon.com/wp-includes/js/wp-embed.min.js?ver=5.5' id='wp-embed-js'></script>
    </body>
</html>

 

Creating transaction types if not available

The idea behind this snippet is that you provide a transaction name and a transaction id in a configuration array. If the ID is not set, the script will search for a transaction with the given name. If that is not found, it will be set up using all the attributes which are also predefined in the configuration.

function checkTransactionType() {
    global $errorHandler;
    
    // If not set manually try finding it automatically
    if (empty($this->config['ORDER_IMPORTER']['TRANSACTION_TYPE_ID'])) {
    
        $transactionsService = new \com_maileon_api_transactions_TransactionsService($this->config['MAILEON']);
        $transactionsService->setDebug($this->config['DEBUG']);
    
        // Get from maileon the transaction type. If it does not exist: create it
        $response = $transactionsService->getTransactionTypes(1, 1000);

        // Print all results
        if ($response->isSuccess()) {
            $transactionTypeId = null;
            foreach ($response->getResult() as $transactionType) {
                if ($transactionType->name == $this->config['ORDER_IMPORTER']['TRANSACTION_TYPE_NAME']) {
                    $transactionTypeId = $transactionType->id;
                }
            }
            if (empty($transactionTypeId)) {
                $transactionTypeId = $this->createTransactionType();
            }
        }
        
        $this->config['ORDER_IMPORTER']['TRANSACTION_TYPE_ID'] = intval($transactionTypeId);
        $errorHandler->getErrorLogger()->warning("No transaction type set for order transactions. Please set config['ORDER_IMPORTER']['TRANSACTION_TYPE_ID'] to '$transactionTypeId'", 'checkTransactionType');
    }
}

function createTransactionType() {
    global $errorHandler;
    
    $transactionsService = new \com_maileon_api_transactions_TransactionsService($this->config['MAILEON']);
    $transactionsService->setDebug($this->config['DEBUG']);
    
    $attributes = array();
    foreach ($this->config['DB']['TABLES']['ORDERS']['MAPPING'] as $key => $value) {
        
        if (!empty($value['TYPE']) && $value['TYPE'] == "IGNORE") {
            // Some special fields like email, just ignore it
            continue;
        }
        array_push($attributes, new \com_maileon_api_transactions_AttributeType(null, $value['MAILEON_TX_ATTRIBUTE_NAME'], \com_maileon_api_transactions_DataType::getDataType($value['MAILEON_TX_ATTRIBUTE_DATATYPE']), false));
    }
    
    $transactionType = new \com_maileon_api_transactions_TransactionType(null, $this->config['ORDER_IMPORTER']['TRANSACTION_TYPE_NAME'], $attributes, 365);
    
    $response = $transactionsService->createTransactionType($transactionType);

    if (!$response->isSuccess()) {
        $errorHandler->processFatalError(new \Exception("Unable create transaction type: " . $response->getBodyData()));
    } else {
        $errorHandler->getInfoLogger()->warning("No transaction type found for submitting orders. Created type with ID " . $response->getResult());
    }
    
    return $response->getResult();
}

 

Inhaltsverzeichnis