{"id":358,"date":"2020-02-28T16:05:35","date_gmt":"2020-02-28T16:05:35","guid":{"rendered":"http:\/\/wiki2.plumserver.com\/knowledge-base\/magento-newsletter-popup-developers-guide-and-api-reference"},"modified":"2021-09-24T09:03:45","modified_gmt":"2021-09-24T13:03:45","slug":"magento-newsletter-popup-developers-guide-and-api-reference","status":"publish","type":"post","link":"https:\/\/plumrocket.com\/docs\/magento-1-newsletter-popup\/v2\/devguide","title":{"rendered":"Magento 1 Newsletter Popup v2.x Developer Guide &#038; API Reference"},"content":{"rendered":"\n<h2 id=\"display-newsletter-popup-manually\">Display Newsletter Popup Manually<\/h2>\n\n\n\n<p>In order to display <a href=\"\/magento-1-newsletter-popup\">Newsletter Popup<\/a> manually you will have to perform the following steps:<\/p>\n\n\n\n<h3 id=\"select-display-popup-method-manually-in-your-magento-back-end-as-shown-below\">Select &#8220;Display Popup Method&#8221; = &#8220;Manually&#8221; in your Magento back-end as shown below:<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"\/docs\/wp-content\/uploads\/2020\/05\/Newsletter_popup_1.x_devguide_1.jpg\" target=\"_blank\" rel=\"noopener noreferrer\"><img src=\"\/docs\/wp-content\/uploads\/2020\/05\/Newsletter_popup_1.x_devguide_1.jpg\" alt=\"Newsletter popup 1.x devguide 1.jpg\"\/><\/a><\/figure>\n\n\n\n<h3 id=\"load-and-show-newsletter-popups-using-the-following-javascript-methods-below\">&#8220;Load&#8221; and &#8220;Show&#8221; newsletter popups using the following JavaScript methods below:<\/h3>\n\n\n\n<p>There are two available methods: .load() and .show(). &#8220;Load&#8221; allows to load newsletter popup content from server in background without displaying it. Then &#8220;Show&#8221; method will display the popup once its loaded.<\/p>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-javascript\">.load()<\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container\">\n<p>Load popup without any arguments. This method is executed automatically when the extension is initialized.<\/p>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-javascript\">.load([id][, callback ])<\/code><\/pre><\/div>\n\n\n\n<p>Load popup by specified newsletter popup ID. There is no need to check if the popup was already loaded. This method will not load the same popup twice. You can find popup ID by going to your magento back-end, then Plumrocket -&gt; Newsletter Popup -&gt; Manage Newsletter Popups -&gt; column &#8220;ID&#8221;.<\/p>\n\n\n\n<p>If supplied, the callback is fired once the newsletter popup is loaded. The callback passed to .load() is guaranteed to be executed after the DOM is ready, so this is usually the best place to attach all other events and run other JavaScript code. It is hard to predict the overall load time of the newsletter popup from server and therefore we strongly suggest to use callback function. If the popup is already loaded on page then the callback will be executed immediately<\/p>\n\n\n\n<p><strong>callback: <span style=\"color:#369\">function([<i><span style=\"color:#693\">bool<\/span><\/i> status][, <i><span style=\"color:#693\">bool<\/span><\/i> just_loaded])<\/span><\/strong><\/p>\n\n\n\n<p><strong>Parameters<\/strong><\/p>\n\n\n\n<p><strong>status<\/strong> \u2014 returns &#8220;true&#8221;, if the popup is available to be displayed, otherwise returns &#8220;false&#8221;. <\/p>\n\n\n\n<p><strong>just_loaded<\/strong> \u2014 returns &#8220;true&#8221;, if the popup was just loaded during this function call, otherwise returns &#8220;false&#8221; if it was previously loaded on page.<\/p>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-javascript\">.show()<\/code><\/pre><\/div>\n\n\n\n<p>Display popup on page after it was loaded with .load() method. It&#8217;s an easy way to display popup without providing any arguments. If on the same page two popups are loaded &#8211; one using automatic &#8220;Display Popup Method&#8221; (such as &#8220;after the time delay&#8221; or &#8220;when leaving the site&#8221;) and the second one using the &#8220;manual&#8221; display method, then the automatically loaded popup will be displayed. If you have loaded two or more popups using &#8220;manual&#8221; display popup method, then the first loaded popup will be displayed.<\/p>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-javascript\">.show([id][, callback ])<\/code><\/pre><\/div>\n\n\n\n<p>Display popup by specified newsletter popup ID. This newsletter popup must be previously loaded using .load() method. If popup with different &#8220;ID&#8221; is currently displayed on page while the .show([id]) is being executed, then the previous popup will be hidden and the requested popup is displayed instead. There is no need to check for overlapping popups.<\/p>\n\n\n\n<p><strong>callback: <span style=\"color:#369\">function([<i><span style=\"color:#693\">bool<\/span><\/i> status])<\/span><\/strong><\/p>\n\n\n\n<p><strong>Parameters<\/strong><\/p>\n\n\n\n<p><strong>status<\/strong> \u2014 returns &#8220;true&#8221;, if the popup exists and displayed on page, otherwise returns &#8220;false&#8221;.<\/p>\n\n\n\n<p><i>EXAMPLES:<\/i><\/p>\n\n\n\n<p><div class=\"example-block\">\n    <p class=\"example-block-title\">Example 1:<\/p>\n    \n    <p><strong>Let&#8217;s load &amp; display newsletter popup with ID=5 and output a message to the Web Console using our callback function:<\/strong><\/p>\n\n    <div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-markup\">&lt;script type=\"text\/javascript\"&gt;\n        newsletterPopup.load(5, function(status, just_loaded) {\n            if (just_loaded) {\n                console.log('Well done, Sir. The popup was just loaded.');\n                \/\/ alert('This is another successful newsletter load message!');\n                newsletterPopup.show(5);\n            }\n        }\n    &lt;\/script&gt;<\/code><\/pre><\/div>\n<\/div><\/p>\n\n\n\n<p><div class=\"example-block\">\n    <p class=\"example-block-title\">Example 2:<\/p>\n    \n    <p><strong>Load and display any available newsletter popup. Please note that &#8220;.load()&#8221; method without arguments is not required, it is executed automatically when the extension is initialized.<\/strong><\/p>\n    \n    <div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-markup\">&lt;script type=\"text\/javascript\"&gt;\n        newsletterPopup.show();\n    &lt;\/script&gt;<\/code><\/pre><\/div>\n<\/div><\/p>\n\n\n\n<p><div class=\"example-block\">\n    <p class=\"example-block-title\">Example 3:<\/p>\n    \n    <p><strong>Load and display newsletter popup with ID=5 on link click<\/strong><\/p>\n    \n    <div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-markup\">&lt;script type=\"text\/javascript\"&gt;\n        newsletterPopup.load(5);\n    &lt;\/script&gt;\n    \n    &lt;a href=\"javascript:void(0);\" onclick=\"return newsletterPopup.show(5)\"&gt;\n        See Newsletter Popup\n    &lt;\/a&gt;<\/code><\/pre><\/div>\n<\/div><\/p>\n\n\n\n<p><div class=\"example-block\">\n    <p class=\"example-block-title\">Example 4:<\/p>\n    \n    <p><strong>In this example we are trying to display any default newsletter popup on page (no matter what ID). If this attempt was unsuccessful, then we will try to load and show popup ID=3.<\/strong><\/p>\n\n    <div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-markup\">&lt;script type=\"text\/javascript\"&gt;\n        newsletterPopup.show(function(status) {\n            if (status == false) {\n                newsletterPopup.load(3, function(status) {\n                    newsletterPopup.show();\n                });\n            }\n        });\n    &lt;\/script&gt;<\/code><\/pre><\/div>\n<\/div><\/p>\n\n\n\n<h2 id=\"display-multi-step-newsletter-popup\">Display Multi-step Newsletter Popup<\/h2>\n\n\n\n<p>In order to display multi-step popups you need to select any popup you&#8217;ve created before, and specify another popup that will be displayed after clicking on the element in its HTML code. In order to perform this, add an attribute with popup ID that needs to be displayed to the element (e.g. button or link) required.<\/p>\n\n\n\n<p><div class=\"example-block\">\n    <p class=\"example-block-title\">Code Example<\/p>\n\n    <div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-markup\">data-npid=\"_POPUP_ID_\"<\/code><\/pre><\/div>\n<\/div><\/p>\n\n\n\n<p>You can also use an attribute that records custom subscribers&#8217; actions in the History section.<\/p>\n\n\n\n<p><div class=\"example-block\">\n    <p class=\"example-block-title\">Code Example<\/p>\n    \n    <div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-markup\">data-npaction=\"_DESCRIPTION_TO_HISTORY_\"<\/code><\/pre><\/div>\n<\/div><\/p>\n\n\n\n<p>Use this attribute with &#8220;Cancel&#8221; value in order to close the popup and write records to the History section.<\/p>\n\n\n\n<p><div class=\"example-block\">\n    <p class=\"example-block-title\">Code Example<\/p>\n    \n    <div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-markup\">data-npaction=\"Cancel\"<\/code><\/pre><\/div>\n<\/div><\/p>\n\n\n\n<div class=\"wp-block-group pr-notice pr-notice-info\"><div class=\"wp-block-group__inner-container\">\n<p class=\"pr-notice-title\">Detailed description:<\/p>\n\n\n\n<ol><li>This is an example of the html code in the template of the popup.<\/li><\/ol>\n<\/div><\/div>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"\/docs\/wp-content\/uploads\/2020\/05\/1_magento_newsletter_popup_developer_guide_multi-step-popus.jpg\" target=\"_blank\" rel=\"noopener noreferrer\"><img src=\"\/docs\/wp-content\/uploads\/2020\/05\/1_magento_newsletter_popup_developer_guide_multi-step-popus.jpg\" alt=\"1 magento newsletter popup developer guide multi-step-popus.jpg\"\/><\/a><\/figure>\n\n\n\n<h2 id=\"disable-newsletter-popup-manually\">Disable Newsletter Popup Manually<\/h2>\n\n\n\n<p>To disable Newsletter popup manually you need to add this code to XML layout:<\/p>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-markup\">&lt;reference name=\"newsletter.popup\">\n    &lt;action method=\"disable\" \/>\n&lt;\/reference><\/code><\/pre><\/div>\n\n\n\n<p><div class=\"example-block\">\n    <p class=\"example-block-title\">Code Example<\/p>\n    \n    <div class=\"wp-block-prismatic-blocks\"><div><\/div><pre data-line=\"2-4\"><code class=\"language-markup\">&lt;catalog_category_default translate=\"label\"&gt;\n        &lt;reference name=\"newsletter.popup\"&gt;\n            &lt;action method=\"disable\" \/&gt;\n        &lt;\/reference&gt;\n        ....\n    &lt;\/catalog_category_default&gt;<\/code><\/pre><\/div>\n<\/div><\/p>\n\n\n\n<p>In order to disable Newsletter Popup Extension using controller class, please use the following code:<\/p>\n\n\n\n<div class=\"wp-block-prismatic-blocks\"><div><\/div><pre><code class=\"language-php\">$newsletterBlock = $this->loadLayout()->getLayout()->getBlock('newsletter.popup');\nif ($newsletterBlock) { $newsletterBlock->disable(); }<\/code><\/pre><\/div>\n\n\n\n<p><div class=\"example-block\">\n    <p class=\"example-block-title\">Code Example<\/p>\n    \n    <div class=\"wp-block-prismatic-blocks\"><div><\/div><pre data-line=\"5-8\"><code class=\"language-php\">public function indexAction()\n    {\n        $this-&gt;loadLayout();\n        $this-&gt;getLayout()-&gt;getBlock('contactForm')-&gt;setFormAction( Mage::getUrl('*\/*\/post'));\n        $newsletterBlock = $this-&gt;loadLayout()-&gt;getLayout()-&gt;getBlock('newsletter.popup');\n        if ($newsletterBlock) {\n            $newsletterBlock-&gt;disable();\n        }\n        \n        $this-&gt;_initLayoutMessages('customer\/session');\n        $this-&gt;_initLayoutMessages('catalog\/session');\n        $this-&gt;renderLayout();\n    }<\/code><\/pre><\/div>\n<\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Display Newsletter Popup Manually In order to display Newsletter Popup manually you will have to perform the following steps: Select &#8220;Display Popup Method&#8221; = &#8220;Manually&#8221; in your Magento back-end as shown below: &#8220;Load&#8221; and &#8220;Show&#8221; newsletter popups using the following JavaScript methods below: There are two available methods: .load() and .show(). &#8220;Load&#8221; allows to load &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/plumrocket.com\/docs\/magento-1-newsletter-popup\/v2\/devguide\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Magento 1 Newsletter Popup v2.x Developer Guide &#038; API Reference&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[240],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v17.2 (Yoast SEO v17.2) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Magento Newsletter Popup v2.x Developer Guide &amp; API Reference - Plumrocket Documentation<\/title>\n<meta name=\"description\" content=\"Display Newsletter Popup Manually In order to display Newsletter Popup manually you will have to perform the following steps: Select &quot;Display Popup\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/plumrocket.com\/docs\/magento-1-newsletter-popup\/v2\/devguide\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Magento 1 Newsletter Popup v2.x Developer Guide &amp; API Reference\" \/>\n<meta property=\"og:description\" content=\"Display Newsletter Popup Manually In order to display Newsletter Popup manually you will have to perform the following steps: Select &quot;Display Popup\" \/>\n<meta property=\"og:url\" content=\"https:\/\/plumrocket.com\/docs\/magento-1-newsletter-popup\/v2\/devguide\" \/>\n<meta property=\"og:site_name\" content=\"Plumrocket Documentation\" \/>\n<meta property=\"article:published_time\" content=\"2020-02-28T16:05:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-09-24T13:03:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/plumrocket.com\/docs\/wp-content\/uploads\/2020\/05\/Newsletter_popup_1.x_devguide_1.jpg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Plumrocket\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Magento Newsletter Popup v2.x Developer Guide & API Reference - Plumrocket Documentation","description":"Display Newsletter Popup Manually In order to display Newsletter Popup manually you will have to perform the following steps: Select \"Display Popup","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/plumrocket.com\/docs\/magento-1-newsletter-popup\/v2\/devguide","og_locale":"en_US","og_type":"article","og_title":"Magento 1 Newsletter Popup v2.x Developer Guide & API Reference","og_description":"Display Newsletter Popup Manually In order to display Newsletter Popup manually you will have to perform the following steps: Select \"Display Popup","og_url":"https:\/\/plumrocket.com\/docs\/magento-1-newsletter-popup\/v2\/devguide","og_site_name":"Plumrocket Documentation","article_published_time":"2020-02-28T16:05:35+00:00","article_modified_time":"2021-09-24T13:03:45+00:00","og_image":[{"url":"https:\/\/plumrocket.com\/docs\/wp-content\/uploads\/2020\/05\/Newsletter_popup_1.x_devguide_1.jpg"}],"twitter_card":"summary_large_image","twitter_misc":{"Written by":"Plumrocket","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/plumrocket.com\/docs\/#website","url":"https:\/\/plumrocket.com\/docs\/","name":"Plumrocket Documentation","description":"Extensions docs, troubleshootings etc.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/plumrocket.com\/docs\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https:\/\/plumrocket.com\/docs\/magento-1-newsletter-popup\/v2\/devguide#primaryimage","inLanguage":"en-US","url":"\/docs\/wp-content\/uploads\/2020\/05\/Newsletter_popup_1.x_devguide_1.jpg","contentUrl":"\/docs\/wp-content\/uploads\/2020\/05\/Newsletter_popup_1.x_devguide_1.jpg"},{"@type":"WebPage","@id":"https:\/\/plumrocket.com\/docs\/magento-1-newsletter-popup\/v2\/devguide#webpage","url":"https:\/\/plumrocket.com\/docs\/magento-1-newsletter-popup\/v2\/devguide","name":"Magento 1 Newsletter Popup v2.x Developer Guide & API Reference - Plumrocket Documentation","isPartOf":{"@id":"https:\/\/plumrocket.com\/docs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/plumrocket.com\/docs\/magento-1-newsletter-popup\/v2\/devguide#primaryimage"},"datePublished":"2020-02-28T16:05:35+00:00","dateModified":"2021-09-24T13:03:45+00:00","author":{"@id":"https:\/\/plumrocket.com\/docs\/#\/schema\/person\/38b360639b934d6c984ee4f3ffce7d20"},"description":"Display Newsletter Popup Manually In order to display Newsletter Popup manually you will have to perform the following steps: Select \"Display Popup","breadcrumb":{"@id":"https:\/\/plumrocket.com\/docs\/magento-1-newsletter-popup\/v2\/devguide#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/plumrocket.com\/docs\/magento-1-newsletter-popup\/v2\/devguide"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/plumrocket.com\/docs\/magento-1-newsletter-popup\/v2\/devguide#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Magento Extensions","item":"https:\/\/plumrocket.com\/magento-1-extensions"},{"@type":"ListItem","position":2,"name":"Magento Newsletter Popup","item":"https:\/\/plumrocket.com\/magento-1-newsletter-popup"},{"@type":"ListItem","position":3,"name":"Documentation","item":"https:\/\/plumrocket.com\/docs\/magento-1-newsletter-popup"},{"@type":"ListItem","position":4,"name":"v2","item":"https:\/\/plumrocket.com\/docs\/magento-1-newsletter-popup\/v2"},{"@type":"ListItem","position":5,"name":"Developer Guide"}]},{"@type":"Person","@id":"https:\/\/plumrocket.com\/docs\/#\/schema\/person\/38b360639b934d6c984ee4f3ffce7d20","name":"Plumrocket","image":{"@type":"ImageObject","@id":"https:\/\/plumrocket.com\/docs\/#personlogo","inLanguage":"en-US","url":"https:\/\/secure.gravatar.com\/avatar\/72392a92ae750c66560be284502b6676?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/72392a92ae750c66560be284502b6676?s=96&d=mm&r=g","caption":"Plumrocket"},"sameAs":["https:\/\/plumrocket.com\/docs"]}]}},"_links":{"self":[{"href":"https:\/\/plumrocket.com\/docs\/wp-json\/wp\/v2\/posts\/358"}],"collection":[{"href":"https:\/\/plumrocket.com\/docs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/plumrocket.com\/docs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/plumrocket.com\/docs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/plumrocket.com\/docs\/wp-json\/wp\/v2\/comments?post=358"}],"version-history":[{"count":2,"href":"https:\/\/plumrocket.com\/docs\/wp-json\/wp\/v2\/posts\/358\/revisions"}],"predecessor-version":[{"id":24435,"href":"https:\/\/plumrocket.com\/docs\/wp-json\/wp\/v2\/posts\/358\/revisions\/24435"}],"wp:attachment":[{"href":"https:\/\/plumrocket.com\/docs\/wp-json\/wp\/v2\/media?parent=358"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/plumrocket.com\/docs\/wp-json\/wp\/v2\/categories?post=358"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/plumrocket.com\/docs\/wp-json\/wp\/v2\/tags?post=358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}