Angelleye_PayPal_BML_Banners - Version 1.0.0

Version Notes

First stable release.

Download this release

Release Info

Developer Angell EYE, LLC
Extension Angelleye_PayPal_BML_Banners
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Angelleye/PaypalBanner/Block/Banner.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Angelleye_PaypalBanner_Block_Banner extends Mage_Core_Block_Template
3
+ {
4
+ /**
5
+ * Build an banners html code output
6
+ * @return mixed
7
+ */
8
+ public function getBannerCode()
9
+ {
10
+ return Mage::helper('paypalbanner')->getSnippetCode();
11
+ }
12
+
13
+ }
app/code/community/Angelleye/PaypalBanner/Helper/Data.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Angelleye_PaypalBanner_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ /**
5
+ * Configuration-controller-action map
6
+ * @var array
7
+ */
8
+ public static $_codeMap = array(
9
+ 'catalog.product.view'=>'catalog_product',
10
+ 'catalog.category.view'=>'catalog_category',
11
+ 'cms.index.index'=>'homepage',
12
+ 'checkout.cart.index'=>'checkout_cart'
13
+ );
14
+
15
+ /**
16
+ * Get configuration settings for current page
17
+ * @return Varien_Object $config
18
+ */
19
+ public function getSectionConfig()
20
+ {
21
+ $config = new Varien_Object();
22
+ $module = Mage::app()->getRequest()->getModuleName();
23
+ $controller = Mage::app()->getRequest()->getControllerName();
24
+ $action = Mage::app()->getRequest()->getActionName();
25
+
26
+ if (isset(self::$_codeMap[$module.'.'.$controller.'.'.$action])){
27
+ $pageCode = self::$_codeMap[$module.'.'.$controller.'.'.$action];
28
+ $size = Mage::getStoreConfig('paypalbanner/'.$pageCode.'/size');
29
+ $position = Mage::getStoreConfig('paypalbanner/'.$pageCode.'/position');
30
+ list($positionHorizontal, $positionVertical) = explode('-',$position);
31
+ $display = Mage::getStoreConfig('paypalbanner/'.$pageCode.'/display');
32
+ $config->setPageCode($pageCode)
33
+ ->setDisplay($display)
34
+ ->setSize($size)
35
+ ->setPositionHorizontal($positionHorizontal)
36
+ ->setPositionVertical($positionVertical);
37
+ }
38
+ return $config;
39
+ }
40
+
41
+ /**
42
+ * Get html code for banner snippet
43
+ *
44
+ * @param string $pageCode
45
+ * @return string $snippet
46
+ */
47
+ public function getSnippetCode($pageCode='')
48
+ {
49
+ if (!Mage::getStoreConfig('paypalbanner/settings/active') || !$this->getSectionConfig()->getDisplay()) {
50
+ return '';
51
+ }
52
+
53
+ $id = Mage::getStoreConfig('paypalbanner/settings/id');
54
+ $container = Mage::getStoreConfig('paypalbanner/settings/container');
55
+ $size = $this->getSectionConfig()->getSize();
56
+
57
+ $snippet = '<script type="text/javascript" data-pp-pubid="'.$id.'" data-pp-placementtype="'.$size.'">
58
+ (function (d, t) {
59
+ "use strict";
60
+ var s = d.getElementsByTagName(t)[0], n = d.createElement(t);
61
+ n.src = "//paypal.adtag.where.com/merchant.js";
62
+ s.parentNode.insertBefore(n, s);
63
+ }(document, "script"));
64
+ </script>';
65
+ if (!empty($container)) {
66
+ $snippet = str_replace('{container}', $snippet, $container);
67
+ }
68
+ return $snippet;
69
+ }
70
+ }
app/code/community/Angelleye/PaypalBanner/Model/Config.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Angelleye_PaypalBanner_Model_Config extends Mage_Paypal_Model_Config
3
+ {
4
+ /**
5
+ * BN code getter
6
+ *
7
+ * @param string $countryCode ISO 3166-1
8
+ */
9
+ public function getBuildNotationCode($countryCode = null)
10
+ {
11
+ return 'AngellEYE_PHPClass';
12
+ }
13
+ }
app/code/community/Angelleye/PaypalBanner/Model/Observer.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Angelleye_PaypalBanner_Model_Observer
3
+ {
4
+ /**
5
+ * Update page layout, add banner code.
6
+ *
7
+ * @param Varien_Event_Observer $observer
8
+ * @return Leiribits_Invoicexpress_Model_Observer
9
+ */
10
+ public function layoutGenerateBlocksBefore(Varien_Event_Observer $observer)
11
+ {
12
+ if (!Mage::getStoreConfig('paypalbanner/settings/active')) {
13
+ return '';
14
+ }
15
+
16
+ if (Mage::app()->getStore()->isAdmin()) {
17
+ return;
18
+ }
19
+ $config = Mage::helper('paypalbanner')->getSectionConfig();
20
+
21
+ if ($config->getDisplay()) {
22
+ switch ($config->getPositionHorizontal()) {
23
+ case 'left': $name = 'left'; break;
24
+ case 'right': $name = 'right'; break;
25
+ default: $name = 'content'; break;
26
+ }
27
+ $vertical = ('top'==$config->getPositionVertical() ? 'before="-"' : 'after="+"');
28
+ $layout = $observer->getEvent()->getLayout();
29
+ $layout->getUpdate()->addUpdate(
30
+ '<reference name="'.$name.'">
31
+ <block type="paypalbanner/banner" name="paypalbanner" template="paypalbanner/snippet.phtml" '.$vertical.'/>
32
+ </reference>');
33
+ }
34
+
35
+ return $this;
36
+ }
37
+ }
app/code/community/Angelleye/PaypalBanner/Model/System/Config/Position.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Angelleye_PaypalBanner_Model_System_Config_Position extends Varien_Object
4
+ {
5
+ public static $positions = array(
6
+ "left-top",
7
+ "left-bottom",
8
+ "center-top",
9
+ "center-bottom",
10
+ "right-top",
11
+ "right-bottom"
12
+ );
13
+
14
+ /**
15
+ * Get options array for configuration field
16
+ * @return array
17
+ */
18
+ public function toOptionArray()
19
+ {
20
+ $options = array();
21
+ foreach(self::$positions as $position) {
22
+ $options[] = array('value' => $position, 'label' => $position);
23
+ }
24
+ return $options;
25
+ }
26
+ }
app/code/community/Angelleye/PaypalBanner/Model/System/Config/Size.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Angelleye_PaypalBanner_Model_System_Config_Size extends Varien_Object
4
+ {
5
+ public static $sizes = array(
6
+ "336x280", "280x280", "300x250",
7
+ "190x100", "170x100", "150x100", "120x100",
8
+ "800x66", "728x90", "540x200", "468x60", "234x60",
9
+ "120x600", "234x400", "250x250", "120x240"
10
+ );
11
+
12
+ /**
13
+ * Get options array for configuration field
14
+ * @return array
15
+ */
16
+ public function toOptionArray()
17
+ {
18
+ $options = array();
19
+ foreach(self::$sizes as $size) {
20
+ $options[] = array('value' => $size, 'label' => $size);
21
+ }
22
+ return $options;
23
+ }
24
+ }
app/code/community/Angelleye/PaypalBanner/etc/config.xml ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Angelleye_PaypalBanner>
5
+ <version>1.0.0</version>
6
+ </Angelleye_PaypalBanner>
7
+ </modules>
8
+ <global>
9
+ <helpers>
10
+ <paypalbanner>
11
+ <class>Angelleye_PaypalBanner_Helper</class>
12
+ </paypalbanner>
13
+ </helpers>
14
+ <blocks>
15
+ <paypalbanner>
16
+ <class>Angelleye_PaypalBanner_Block</class>
17
+ </paypalbanner>
18
+ </blocks>
19
+ <models>
20
+ <paypalbanner>
21
+ <class>Angelleye_PaypalBanner_Model</class>
22
+ </paypalbanner>
23
+ <paypal>
24
+ <rewrite>
25
+ <config>Angelleye_PaypalBanner_Model_Config</config>
26
+ </rewrite>
27
+ </paypal>
28
+ </models>
29
+ <events>
30
+ <controller_action_layout_generate_xml_before>
31
+ <observers>
32
+ <angelleye_paypalbanner>
33
+ <class>paypalbanner/observer</class>
34
+ <method>layoutGenerateBlocksBefore</method>
35
+ </angelleye_paypalbanner>
36
+ </observers>
37
+ </controller_action_layout_generate_xml_before>
38
+ </events>
39
+ </global>
40
+ <frontend>
41
+ <layout>
42
+ <updates>
43
+ <paypalbanner module="Angelleye_Paypalbanner">
44
+ <file>paypalbanner.xml</file>
45
+ </paypalbanner>
46
+ </updates>
47
+ </layout>
48
+ </frontend>
49
+ <default>
50
+ <paypalbanner>
51
+ <settings>
52
+ <container><![CDATA[<div style="width: 100%; text-align: center; padding-bottom: 7px ">{container}</div>]]></container>
53
+ </settings>
54
+ </paypalbanner>
55
+ </default>
56
+ <adminhtml>
57
+ <acl>
58
+ <resources>
59
+ <admin>
60
+ <children>
61
+ <system>
62
+ <children>
63
+ <config>
64
+ <children>
65
+ <paypalbanner translate="title" module="paypalbanner">
66
+ <title>PayPal Bill Me Later Banners</title>
67
+ </paypalbanner>
68
+ </children>
69
+ </config>
70
+ </children>
71
+ </system>
72
+ </children>
73
+ </admin>
74
+ </resources>
75
+ </acl>
76
+ </adminhtml>
77
+ </config>
app/code/community/Angelleye/PaypalBanner/etc/system.xml ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <paypalbanner translate="label" module="paypalbanner">
5
+ <label>PayPal Bill Me Later Banners</label>
6
+ <tab>general</tab>
7
+ <frontend_type>text</frontend_type>
8
+ <sort_order>9999</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>1</show_in_store>
12
+ <groups>
13
+ <settings translate="label">
14
+ <label>General Settings</label>
15
+ <frontend_type>text</frontend_type>
16
+ <sort_order>10</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>0</show_in_website>
19
+ <show_in_store>0</show_in_store>
20
+ <fields>
21
+ <active translate="label">
22
+ <label>Active</label>
23
+ <frontend_type>select</frontend_type>
24
+ <source_model>adminhtml/system_config_source_yesno</source_model>
25
+ <sort_order>1</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>0</show_in_website>
28
+ <show_in_store>0</show_in_store>
29
+ </active>
30
+ <id translate="label,comment">
31
+ <label>API ID</label>
32
+ <comment><![CDATA[
33
+ Check <a href="https://financing.paypal.com/ppfinportal" target="_blank">here</a>
34
+ to obtain ID ("data-pp-pubid" field value from banner code)
35
+ ]]></comment>
36
+ <frontend_type>text</frontend_type>
37
+ <sort_order>2</sort_order>
38
+ <show_in_default>1</show_in_default>
39
+ <show_in_website>0</show_in_website>
40
+ <show_in_store>0</show_in_store>
41
+ </id>
42
+ <container translate="label,comment">
43
+ <label>Code Wrapper</label>
44
+ <comment><![CDATA[Place HTML/CSS code with a {container} tag inside, which will be replaced with your banner block]]></comment>
45
+ <frontend_type>textarea</frontend_type>
46
+ <sort_order>3</sort_order>
47
+ <show_in_default>1</show_in_default>
48
+ <show_in_website>0</show_in_website>
49
+ <show_in_store>0</show_in_store>
50
+ </container>
51
+ </fields>
52
+ </settings>
53
+ <homepage>
54
+ <label>Home Page</label>
55
+ <frontend_type>text</frontend_type>
56
+ <sort_order>20</sort_order>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>0</show_in_website>
59
+ <show_in_store>0</show_in_store>
60
+ <fields>
61
+ <display translate="label">
62
+ <label>Display</label>
63
+ <frontend_type>select</frontend_type>
64
+ <source_model>adminhtml/system_config_source_yesno</source_model>
65
+ <sort_order>1</sort_order>
66
+ <show_in_default>1</show_in_default>
67
+ <show_in_website>0</show_in_website>
68
+ <show_in_store>0</show_in_store>
69
+ </display>
70
+ <size translate="label">
71
+ <label>Banner Size</label>
72
+ <frontend_type>select</frontend_type>
73
+ <source_model>paypalbanner/system_config_size</source_model>
74
+ <sort_order>2</sort_order>
75
+ <show_in_default>1</show_in_default>
76
+ <show_in_website>0</show_in_website>
77
+ <show_in_store>0</show_in_store>
78
+ </size>
79
+ <position translate="label">
80
+ <label>Banner Position</label>
81
+ <frontend_type>select</frontend_type>
82
+ <source_model>paypalbanner/system_config_position</source_model>
83
+ <sort_order>3</sort_order>
84
+ <show_in_default>1</show_in_default>
85
+ <show_in_website>0</show_in_website>
86
+ <show_in_store>0</show_in_store>
87
+ </position>
88
+ </fields>
89
+ </homepage>
90
+ <catalog_category>
91
+ <label>Catalog Category Page</label>
92
+ <frontend_type>text</frontend_type>
93
+ <sort_order>30</sort_order>
94
+ <show_in_default>1</show_in_default>
95
+ <show_in_website>0</show_in_website>
96
+ <show_in_store>0</show_in_store>
97
+ <fields>
98
+ <display translate="label">
99
+ <label>Display</label>
100
+ <frontend_type>select</frontend_type>
101
+ <source_model>adminhtml/system_config_source_yesno</source_model>
102
+ <sort_order>1</sort_order>
103
+ <show_in_default>1</show_in_default>
104
+ <show_in_website>0</show_in_website>
105
+ <show_in_store>0</show_in_store>
106
+ </display>
107
+ <size translate="label">
108
+ <label>Banner Size</label>
109
+ <frontend_type>select</frontend_type>
110
+ <source_model>paypalbanner/system_config_size</source_model>
111
+ <sort_order>2</sort_order>
112
+ <show_in_default>1</show_in_default>
113
+ <show_in_website>0</show_in_website>
114
+ <show_in_store>0</show_in_store>
115
+ </size>
116
+ <position translate="label">
117
+ <label>Banner Position</label>
118
+ <frontend_type>select</frontend_type>
119
+ <source_model>paypalbanner/system_config_position</source_model>
120
+ <sort_order>3</sort_order>
121
+ <show_in_default>1</show_in_default>
122
+ <show_in_website>0</show_in_website>
123
+ <show_in_store>0</show_in_store>
124
+ </position>
125
+ </fields>
126
+ </catalog_category>
127
+ <catalog_product>
128
+ <label>Catalog Product Page</label>
129
+ <frontend_type>text</frontend_type>
130
+ <sort_order>40</sort_order>
131
+ <show_in_default>1</show_in_default>
132
+ <show_in_website>0</show_in_website>
133
+ <show_in_store>0</show_in_store>
134
+ <fields>
135
+ <display translate="label">
136
+ <label>Display</label>
137
+ <frontend_type>select</frontend_type>
138
+ <source_model>adminhtml/system_config_source_yesno</source_model>
139
+ <sort_order>1</sort_order>
140
+ <show_in_default>1</show_in_default>
141
+ <show_in_website>0</show_in_website>
142
+ <show_in_store>0</show_in_store>
143
+ </display>
144
+ <size translate="label">
145
+ <label>Banner Size</label>
146
+ <frontend_type>select</frontend_type>
147
+ <source_model>paypalbanner/system_config_size</source_model>
148
+ <sort_order>2</sort_order>
149
+ <show_in_default>1</show_in_default>
150
+ <show_in_website>0</show_in_website>
151
+ <show_in_store>0</show_in_store>
152
+ </size>
153
+ <position translate="label">
154
+ <label>Banner Position</label>
155
+ <frontend_type>select</frontend_type>
156
+ <source_model>paypalbanner/system_config_position</source_model>
157
+ <sort_order>3</sort_order>
158
+ <show_in_default>1</show_in_default>
159
+ <show_in_website>0</show_in_website>
160
+ <show_in_store>0</show_in_store>
161
+ </position>
162
+ </fields>
163
+ </catalog_product>
164
+ <checkout_cart>
165
+ <label>Checkout Cart Page</label>
166
+ <frontend_type>text</frontend_type>
167
+ <sort_order>50</sort_order>
168
+ <show_in_default>1</show_in_default>
169
+ <show_in_website>0</show_in_website>
170
+ <show_in_store>0</show_in_store>
171
+ <fields>
172
+ <display translate="label">
173
+ <label>Display</label>
174
+ <frontend_type>select</frontend_type>
175
+ <source_model>adminhtml/system_config_source_yesno</source_model>
176
+ <sort_order>1</sort_order>
177
+ <show_in_default>1</show_in_default>
178
+ <show_in_website>0</show_in_website>
179
+ <show_in_store>0</show_in_store>
180
+ </display>
181
+ <size translate="label">
182
+ <label>Banner Size</label>
183
+ <frontend_type>select</frontend_type>
184
+ <source_model>paypalbanner/system_config_size</source_model>
185
+ <sort_order>2</sort_order>
186
+ <show_in_default>1</show_in_default>
187
+ <show_in_website>0</show_in_website>
188
+ <show_in_store>0</show_in_store>
189
+ </size>
190
+ <position translate="label">
191
+ <label>Banner Position</label>
192
+ <frontend_type>select</frontend_type>
193
+ <source_model>paypalbanner/system_config_position</source_model>
194
+ <sort_order>3</sort_order>
195
+ <show_in_default>1</show_in_default>
196
+ <show_in_website>0</show_in_website>
197
+ <show_in_store>0</show_in_store>
198
+ </position>
199
+ </fields>
200
+ </checkout_cart>
201
+ </groups>
202
+ </paypalbanner>
203
+ </sections>
204
+ </config>
app/etc/modules/Angelleye_PaypalBanner.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Angelleye_PaypalBanner>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Angelleye_PaypalBanner>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Angelleye_PayPal_BML_Banners</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Easily add PayPal Bill Me Later banners to your home page, category pages, product pages, and shopping cart.</summary>
10
+ <description>Bill Me Later is a PayPal service that lets your customers buy now and pay later with a credit line that's built into their PayPal account. Bill Me Later is subject to credit approval and offered through WebBank, Salt Lake City, Utah. Think of it as instant and reusable credit at the point of sale. Bill Me Later is available as a payment option in select PayPal products. Read more about Eligibility to find out if Bill Me Later is part of your payment solution. &#xD;
11
+ &#xD;
12
+ If you're already using one of the eligible PayPal products you may use this module to advertise the Bill Me Later financing option on your website. Studies have shown that Bill Me Later drives a 75% lift in average order value (compared with overall order value.)&#xD;
13
+ &#xD;
14
+ The module will give you the ability to easily add a PayPal Bill Me Later promotional banner to your home page, category pages, product detail pages, and your shopping cart. You can choose to display the banner at the top or bottom of your content area or a side bar, and you can choose from variety of banner sizes.</description>
15
+ <notes>First stable release.</notes>
16
+ <authors><author><name>Angell EYE, LLC</name><user>angelleye</user><email>andrew@angelleye.com</email></author></authors>
17
+ <date>2013-03-13</date>
18
+ <time>23:02:02</time>
19
+ <contents><target name="magecommunity"><dir name="Angelleye"><dir name="PaypalBanner"><dir name="Block"><file name="Banner.php" hash="c1d46299ee0f006972d9b03f09469d32"/></dir><dir name="Helper"><file name="Data.php" hash="fb16793380d21ca06f4f558b49314d50"/></dir><dir name="Model"><file name="Config.php" hash="280d4f1bdcd5793c6be4bcb7a09d3a04"/><file name="Observer.php" hash="3e598f4cd6029a405fb72c31ec977317"/><dir name="System"><dir name="Config"><file name="Position.php" hash="414a7e9017f72ca2f230742cbc8abd6b"/><file name="Size.php" hash="a75fab8643bbbb2f41b1703dd6d2487a"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="789cd8e42eb16edfbdf7ee6f55e291f2"/><file name="system.xml" hash="84f44ba5c57380272b8ef5efcf5d68be"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Angelleye_PaypalBanner.xml" hash="1b360ec01ee752e5958551582a941dd8"/></dir></target></contents>
20
+ <compatible/>
21
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
22
+ </package>