Bloompcommerce - Version 2.0.0

Version Notes

Totally rewrited extension and now is safer and easy to install.

Download this release

Release Info

Developer Bloompa
Extension Bloompcommerce
Version 2.0.0
Comparing to
See all releases


Version 2.0.0

app/code/community/Bloompa/Bloompcommerce/.DS_Store ADDED
Binary file
app/code/community/Bloompa/Bloompcommerce/Block/Bc_Shopping_Cart.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Bloompa_Bloompcommerce_Block_Bc_Shopping_Cart
3
+ extends Mage_Core_Block_Abstract
4
+ implements Mage_Widget_Block_Interface
5
+ {
6
+
7
+ protected function _toHtml()
8
+ {
9
+ $html ='';
10
+ $html .= 'bc_shopping_cart parameter1 = '.$this->getData('parameter1').'<br/>';
11
+ $html .= 'bc_shopping_cart parameter2 = '.$this->getData('parameter2').'<br/>';
12
+ $html .= 'bc_shopping_cart parameter3 = '.$this->getData('parameter3').'<br/>';
13
+ $html .= 'bc_shopping_cart parameter4 = '.$this->getData('parameter4').'<br/>';
14
+ $html .= 'bc_shopping_cart parameter5 = '.$this->getData('parameter5').'<br/>';
15
+ return $html;
16
+ }
17
+
18
+ }
app/code/community/Bloompa/Bloompcommerce/Block/Bc_Social_Expressions.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Bloompa_Bloompcommerce_Block_Bc_Social_Expressions
3
+ extends Mage_Core_Block_Abstract
4
+ implements Mage_Widget_Block_Interface
5
+ {
6
+
7
+ protected function _toHtml()
8
+ {
9
+ $html ='';
10
+ $html .= 'bc_social_expressions parameter1 = '.$this->getData('parameter1').'<br/>';
11
+ $html .= 'bc_social_expressions parameter2 = '.$this->getData('parameter2').'<br/>';
12
+ $html .= 'bc_social_expressions parameter3 = '.$this->getData('parameter3').'<br/>';
13
+ $html .= 'bc_social_expressions parameter4 = '.$this->getData('parameter4').'<br/>';
14
+ $html .= 'bc_social_expressions parameter5 = '.$this->getData('parameter5').'<br/>';
15
+ return $html;
16
+ }
17
+
18
+ }
app/code/community/Bloompa/Bloompcommerce/Block/Index.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Bloompa_Bloompcommerce_Block_Index extends Mage_Core_Block_Template{
3
+
4
+
5
+
6
+
7
+
8
+ }
app/code/community/Bloompa/Bloompcommerce/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Bloompa_Bloompcommerce_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
5
+
app/code/community/Bloompa/Bloompcommerce/controllers/IndexController.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'Mage/Checkout/controllers/CartController.php';
3
+ class Bloompa_Bloompcommerce_IndexController extends Mage_Core_Controller_Front_Action{
4
+
5
+ public function IndexAction() {
6
+ //$this->_redirectUrl('http://www.bloompa.com.br');
7
+
8
+ @session_start();
9
+
10
+ $social_network = ucfirst(trim($this->getRequest()->getParam('social_network')));
11
+ if(is_null($social_network)){
12
+ $this->_redirect('/');
13
+ exit();
14
+ }else
15
+ $_SESSION['bc_social_network'] = $social_network;
16
+
17
+ $readConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
18
+ $bc_discount_percent = $readConnection->fetchOne("SELECT value FROM `bloompa_settings` WHERE `param`='discount_value_".strtolower($social_network)."' AND product='BloompCommerce' LIMIT 1");
19
+ if(!is_null($bc_discount_percent)){
20
+
21
+ $new_code = false;
22
+ if(isset($_SESSION['bc_customer_id']))
23
+ $customer_id = $_SESSION['bc_customer_id'];
24
+ else{
25
+ $customer_id = Mage::getSingleton('customer/session')->getCustomerId();
26
+ if(is_null($customer_id) OR empty($customer_id)){
27
+ $customer_id = 'generic_'.strtoupper(Mage::helper('core')->getRandomString(5));
28
+ $_SESSION['bc_customer_id'] = $customer_id;
29
+ $new_code = true;
30
+ }
31
+ }
32
+
33
+
34
+ if($new_code==true){
35
+ // data to create coupon
36
+ $data = array(
37
+ 'product_ids' => null,
38
+ 'name' => sprintf('AUTO_GENERATION CUSTOMER_%s - '.intval($bc_discount_percent).'%% BloompCommerce-'.$social_network.' discount', $customer_id),
39
+ 'description' => 'Cupom de desconto fornecido pelo compartilhamento do site nas redes sociais (BloompCommerce).',
40
+ 'is_active' => 1,
41
+ 'website_ids' => array(1),
42
+ 'customer_group_ids' => array(0,1,2,3,4),
43
+ 'coupon_type' => 2,
44
+ 'coupon_code' => strtoupper('BC'.Mage::helper('core')->getRandomString(5)),
45
+ 'uses_per_coupon' => 1,
46
+ 'uses_per_customer' => 1,
47
+ 'from_date' => null,
48
+ 'to_date' => null,
49
+ 'sort_order' => null,
50
+ 'is_rss' => 1,
51
+ 'rule' => array(
52
+ 'conditions' => array(
53
+ array(
54
+ 'type' => 'salesrule/rule_condition_combine',
55
+ 'aggregator' => 'all',
56
+ 'value' => 1,
57
+ 'new_child' => null
58
+ )
59
+ )
60
+ ),
61
+ 'simple_action' => 'by_percent',
62
+ 'discount_amount' => $bc_discount_percent,
63
+ 'discount_qty' => 0,
64
+ 'discount_step' => null,
65
+ 'apply_to_shipping' => 0,
66
+ 'simple_free_shipping' => 0,
67
+ 'stop_rules_processing' => 0,
68
+ 'rule' => array(
69
+ 'actions' => array(
70
+ array(
71
+ 'type' => 'salesrule/rule_condition_product_combine',
72
+ 'aggregator' => 'all',
73
+ 'value' => 1,
74
+ 'new_child' => null
75
+ )
76
+ )
77
+ ),
78
+ 'store_labels' => array(intval($bc_discount_percent).'% off - Compartilhamento')
79
+ );
80
+
81
+
82
+ // create coupon
83
+ $model = Mage::getModel('salesrule/rule');
84
+ $data = $this->_filterDates($data, array('from_date', 'to_date'));
85
+ $validateResult = $model->validateData(new Varien_Object($data));
86
+ if ($validateResult == true) {
87
+ if (isset($data['simple_action']) && $data['simple_action'] == 'by_percent'
88
+ && isset($data['discount_amount'])) {
89
+ $data['discount_amount'] = min(100, $data['discount_amount']);
90
+ }
91
+ if (isset($data['rule']['conditions'])) {
92
+ $data['conditions'] = $data['rule']['conditions'];
93
+ }
94
+ if (isset($data['rule']['actions'])) {
95
+ $data['actions'] = $data['rule']['actions'];
96
+ }
97
+ unset($data['rule']);
98
+ $model->loadPost($data);
99
+ $model->save();
100
+ }
101
+ }
102
+
103
+ Mage::getSingleton('checkout/cart')->getQuote()->getShippingAddress()->setCollectShippingRates(true);
104
+
105
+ // find coupon
106
+ $model = Mage::getModel('salesrule/rule')
107
+ ->getCollection()
108
+ ->addFieldToFilter('name', array('eq'=>sprintf('AUTO_GENERATION CUSTOMER_'.$customer_id.' - '.intval($bc_discount_percent).'%% BloompCommerce-'.$social_network.' discount')))
109
+ ->getFirstItem();
110
+ $couponCode = $model->getCode();
111
+
112
+
113
+ if(!is_null($couponCode) AND $couponCode!=''){
114
+
115
+ //apply coupon
116
+ Mage::getSingleton("checkout/session")->setData("coupon_code",$couponCode);
117
+ Mage::getSingleton('checkout/cart')->getQuote()->setCouponCode($couponCode)->collectTotals()->save();
118
+ Mage::getSingleton('core/session')->addSuccess($this->__('Coupon BloompCommerce applied.'));
119
+
120
+ $this->_redirect('checkout/cart');
121
+
122
+
123
+ }else{
124
+ exit('Coupon discount not found.');
125
+ }
126
+
127
+
128
+ }else{
129
+ $this->_redirect('/');
130
+ }
131
+
132
+ }
133
+
134
+
135
+ /**
136
+ * Update Token - Request FROM Bloompa's server
137
+ */
138
+ public function UpdateTokenAction() {
139
+ header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"');
140
+ header("Access-Control-Allow-Methods: POST,GET,OPTIONS");
141
+ header("Access-Control-Allow-Origin: *");
142
+ header('Access-Control-Allow-Headers: X-Requested-With');
143
+
144
+ $token = trim($_POST['token']);
145
+
146
+ Mage::getSingleton('core/session', array('name' => 'adminhtml'));
147
+ $adminsession = Mage::getSingleton('admin/session', array('name' => 'adminhtml'));
148
+ $writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
149
+
150
+ if($writeConnection->query("UPDATE bloompa_settings SET value ='" .$token. "' WHERE product = 'BloompCommerce' AND param = 'token'"))
151
+ $res = array('status'=>'success');
152
+ else
153
+ $res = array('status'=>'fail');
154
+
155
+ exit(json_encode($res));
156
+ }
157
+
158
+
159
+ /**
160
+ * Update Discount - Request FROM Bloompa's Server
161
+ */
162
+ public function UpdateDiscountAction(){
163
+
164
+ header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"');
165
+ header("Access-Control-Allow-Methods: POST,GET,OPTIONS");
166
+ header("Access-Control-Allow-Origin: *");
167
+ header('Access-Control-Allow-Headers: X-Requested-With');
168
+
169
+ $social_network = strtolower(trim($_POST['social_network']));
170
+ $discount_value = trim($_REQUEST['set_discount']);
171
+
172
+
173
+ $writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
174
+
175
+ if(!$writeConnection->query("UPDATE bloompa_settings SET value ='".$discount_value."' WHERE product='BloompCommerce' AND param='discount_value_".$social_network."'"))
176
+ exit(json_encode(array('status'=>'fail')));
177
+
178
+ exit(json_encode(array('status'=>'success')));
179
+ }
180
+
181
+
182
+ }
app/code/community/Bloompa/Bloompcommerce/etc/config.xml ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Bloompa_Bloompcommerce>
5
+ <version>2.0.0</version>
6
+ </Bloompa_Bloompcommerce>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+
11
+ <bloompcommerce>
12
+ <use>standard</use>
13
+ <args>
14
+ <module>Bloompa_Bloompcommerce</module>
15
+ <frontName>bloompcommerce</frontName>
16
+ </args>
17
+ </bloompcommerce>
18
+
19
+ </routers>
20
+ <layout>
21
+ <updates>
22
+ <bloompcommerce>
23
+ <file>bloompcommerce.xml</file>
24
+ </bloompcommerce>
25
+ </updates>
26
+ </layout>
27
+ </frontend>
28
+ <global>
29
+ <helpers>
30
+ <bloompcommerce>
31
+ <class>Bloompa_Bloompcommerce_Helper</class>
32
+ </bloompcommerce>
33
+ </helpers>
34
+ <blocks>
35
+ <bloompcommerce>
36
+ <class>Bloompa_Bloompcommerce_Block</class>
37
+ </bloompcommerce>
38
+ </blocks>
39
+ <resources>
40
+ <bloompcommerce_setup>
41
+ <setup>
42
+ <module>Bloompa_Bloompcommerce</module>
43
+ </setup>
44
+ <connection>
45
+ <use>core_setup</use>
46
+ </connection>
47
+ </bloompcommerce_setup>
48
+ <bloompcommerce_write>
49
+ <connection>
50
+ <use>core_write</use>
51
+ </connection>
52
+ </bloompcommerce_write>
53
+ <bloompcommerce_read>
54
+ <connection>
55
+ <use>core_read</use>
56
+ </connection>
57
+ </bloompcommerce_read>
58
+ </resources>
59
+ </global>
60
+ </config>
app/code/community/Bloompa/Bloompcommerce/etc/widget.xml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <widgets>
3
+ <bloompcommerce_bc_social_expressions type="bloompcommerce/bc_social_expressions" translate="name description" module="bloompcommerce">
4
+ <name>BC Social Expressions</name>
5
+ <description type="desc">Enable the social expressions feature in your products page.</description>
6
+ </bloompcommerce_bc_social_expressions>
7
+ <bloompcommerce_bc_shopping_cart type="bloompcommerce/bc_shopping_cart" translate="name description" module="bloompcommerce">
8
+ <name>BC Shoppig Cart</name>
9
+ <description type="desc">Add a share buttons to your shopping cart page.</description>
10
+ <parameters>
11
+ <parameter1>
12
+ <label>parameter 1</label>
13
+ <visible>1</visible>
14
+ <required>1</required>
15
+ <type>text</type>
16
+ <value>parameter1</value>
17
+ </parameter1>
18
+ <parameter2>
19
+ <label>parameter 2</label>
20
+ <visible>1</visible>
21
+ <required>1</required>
22
+ <type>textarea</type>
23
+ <value>parameter2</value>
24
+ </parameter2>
25
+ <parameter3>
26
+ <label>parameter 3</label>
27
+ <visible>1</visible>
28
+ <required>1</required>
29
+ <type>select</type>
30
+ <source_model>adminhtml/system_config_source_yesno</source_model>
31
+ </parameter3>
32
+ <parameter4>
33
+ <label>parameter 4</label>
34
+ <visible>1</visible>
35
+ <required>1</required>
36
+ <type>multiselect</type>
37
+ <source_model>adminhtml/system_config_source_yesno</source_model>
38
+ </parameter4>
39
+ <parameter5>
40
+ <label>parameter 5</label>
41
+ <visible>1</visible>
42
+ <required>1</required>
43
+ <type>password</type>
44
+ <value>parameter5</value>
45
+ </parameter5>
46
+ </parameters>
47
+ </bloompcommerce_bc_shopping_cart>
48
+ </widgets>
app/code/community/Bloompa/Bloompcommerce/sql/bloompcommerce_setup/mysql4-install-1.5.0.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+ $sql=<<<SQLTEXT
5
+ DROP TABLE IF EXISTS `bloompa_settings`;
6
+ CREATE TABLE `bloompa_settings` (
7
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
8
+ `product` varchar(255) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL DEFAULT '',
9
+ `param` varchar(255) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL DEFAULT '',
10
+ `value` varchar(255) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL DEFAULT '',
11
+ PRIMARY KEY (`id`)
12
+ ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_german1_ci COMMENT='Tabela com as configurações do bloompa';
13
+ INSERT INTO bloompa_settings(id,product,param,value) VALUES(NULL,'BloompCommerce','token','novo');
14
+ INSERT INTO bloompa_settings(id,product,param,value) VALUES(NULL,'BloompCommerce','discount_value_facebook','5');
15
+ INSERT INTO bloompa_settings(id,product,param,value) VALUES(NULL,'BloompCommerce','discount_value_twitter','5');
16
+ SQLTEXT;
17
+
18
+ $installer->run($sql);
19
+
20
+ $installer->endSetup();
21
+
app/design/frontend/base/default/layout/bloompcommerce.xml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <layout version="1.5.0">
4
+
5
+ <bloompcommerce_index_index>
6
+ <reference name="root">
7
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
8
+ </reference>
9
+ <reference name="content">
10
+ <block type="bloompcommerce/index" name="bloompcommerce_index" template="bloompcommerce/index.phtml"/>
11
+ </reference>
12
+ </bloompcommerce_index_index>
13
+
14
+ <checkout_cart_index>
15
+ <reference name="content">
16
+ <reference name="checkout.cart.top_methods">
17
+ <block type="page/html" name="bloompcommerce_cart" before="-" template="bloompcommerce/cart.phtml"/>
18
+ </reference>
19
+ </reference>
20
+ </checkout_cart_index>
21
+
22
+ <catalog_product_view>
23
+ <reference name="content">
24
+ <reference name="product.info.addtocart">
25
+ <block type="page/html" name="bloompcommerce_product" before="-" template="bloompcommerce/product.phtml"/>
26
+ </reference>
27
+ </reference>
28
+ </catalog_product_view>
29
+
30
+ <checkout_onepage_success>
31
+ <reference name="content">
32
+ <block type="page/html" name="bloompcommerce_checkout" after="-" template="bloompcommerce/order_success.phtml"/>
33
+ </reference>
34
+ </checkout_onepage_success>
35
+
36
+ </layout>
37
+
app/etc/modules/Bloompa_Bloompcommerce.xml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Bloompa_Bloompcommerce>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Mage_Cms />
9
+ </depends>
10
+ <version>1.5.0</version>
11
+ </Bloompa_Bloompcommerce>
12
+ </modules>
13
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Bloompcommerce</name>
4
+ <version>2.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.gnu.org/licenses/gpl.html">GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Offer a real time discount for consumers that share their buying intention.</summary>
10
+ <description>E-commerce stores face a big problem; low sales conversion rates. BloompCommerce is a social behavior solution to improve e-commerce stores sales conversion rates by utilizing the power of customers social networks.</description>
11
+ <notes>Totally rewrited extension and now is safer and easy to install.</notes>
12
+ <authors><author><name>Bloompa</name><user>bloompa</user><email>dev@bloompa.com.br</email></author></authors>
13
+ <date>2012-11-26</date>
14
+ <time>03:02:53</time>
15
+ <contents><target name="magecommunity"><dir name="Bloompa"><dir name="Bloompcommerce"><dir name="Block"><file name="Bc_Shopping_Cart.php" hash="60430e2631dff2d8ad989a47a1a72076"/><file name="Bc_Social_Expressions.php" hash="261d578ff77edd0dbf85bca3e1de1adf"/><file name="Index.php" hash="bfa3379f338393829181d4da5c8bf9a3"/></dir><dir name="Helper"><file name="Data.php" hash="b86464697e0f7860ce665d3483390222"/></dir><dir name="controllers"><file name="IndexController.php" hash="e54f3a9055b94421284ac2140a670dc7"/></dir><dir name="etc"><file name="config.xml" hash="7b932c03ac230b42afa9d60410aade2a"/><file name="widget.xml" hash="dec6e8cd0f603a062bc9211ae6d296de"/></dir><dir name="sql"><dir name="bloompcommerce_setup"><file name="mysql4-install-1.5.0.php" hash="d86d2032355984522a05d11e817c8f57"/></dir></dir><file name=".DS_Store" hash="0b2416f51e60c2f1fbe47fc302674013"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Bloompa_Bloompcommerce.xml" hash="69ad42c1a9aeba93d6fc652862972003"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="bloompcommerce.xml" hash="f1d3b0d59b166ea4308ea694c6b66f4f"/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>