Skip to content

Commit cf6ce5d

Browse files
committedJun 4, 2013
Merge branch 'customer-reg-tc-configurable' of github.com:amenk/firegento-germansetup into amenk-customer-reg-tc
Conflicts: src/app/code/community/FireGento/GermanSetup/etc/config.xml src/app/design/frontend/base/default/layout/germansetup.xml src/app/locale/de_DE/FireGento_GermanSetup.csv
2 parents cce2273 + ec4ab31 commit cf6ce5d

File tree

7 files changed

+235
-3
lines changed

7 files changed

+235
-3
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
/**
3+
* This file is part of the FIREGENTO project.
4+
*
5+
* FireGento_GermanSetup is free software; you can redistribute it and/or
6+
* modify it under the terms of the GNU General Public License version 3 as
7+
* published by the Free Software Foundation.
8+
*
9+
* This script is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12+
*
13+
* PHP version 5
14+
*
15+
* @category FireGento
16+
* @package FireGento_GermanSetup
17+
* @author FireGento Team <team@firegento.com>
18+
* @copyright 2012 FireGento Team (http://www.firegento.de). All rights served.
19+
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
20+
* @version $Id:$
21+
* @since 0.1.0
22+
*/
23+
/**
24+
* Block to enable ip anonymization for german tracking.
25+
*
26+
* @category FireGento
27+
* @package FireGento_GermanSetup
28+
* @author FireGento Team <team@firegento.com>
29+
* @copyright 2012 FireGento Team (http://www.firegento.de). All rights served.
30+
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
31+
* @version $Id:$
32+
* @since 0.1.0
33+
*/
34+
35+
class FireGento_GermanSetup_Block_Customer_Account_Agreements extends Mage_Checkout_Block_Agreements
36+
{
37+
38+
/**
39+
* Filter by "Visible on registration"
40+
*
41+
* @return mixed
42+
*/
43+
public function getAgreements()
44+
{
45+
$agreements = parent::getAgreements();
46+
$agreements->addFieldToFilter('is_visible_on_registration', 1);
47+
return $agreements;
48+
}
49+
50+
}

‎src/app/code/community/FireGento/GermanSetup/Model/Observer.php

+43-2
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,13 @@ protected function _buildKeywords($categoryTypes)
227227
}
228228

229229
/**
230-
* Add "Required" Option to Checkout Agreements
230+
* Add "Required" and "Visible on Custom Creation" Option to Checkout Agreements
231231
*
232232
* @param Varien_Event_Observer $observer Observer
233233
* @event adminhtml_block_html_before
234234
* @return FireGento_GermanSetup_Model_Observer
235235
*/
236-
public function addIsRequiredOnAgreements(Varien_Event_Observer $observer)
236+
public function addOptionsForAgreements(Varien_Event_Observer $observer)
237237
{
238238
$block = $observer->getEvent()->getBlock();
239239
if ($block instanceof Mage_Adminhtml_Block_Checkout_Agreement_Edit_Form) {
@@ -252,6 +252,19 @@ public function addIsRequiredOnAgreements(Varien_Event_Observer $observer)
252252
),
253253
));
254254

255+
$fieldset->addField('is_visible_on_registration', 'select', array(
256+
'label' => Mage::helper('germansetup')->__('Use on Customer Creation'),
257+
'title' => Mage::helper('germansetup')->__('Use on Customer Creation'),
258+
'note' => Mage::helper('germansetup')->__('Require Confirmation on Customer Registration'),
259+
'name' => 'is_visible_on_registration',
260+
'required' => true,
261+
'options' => array(
262+
'1' => Mage::helper('germansetup')->__('Yes'),
263+
'0' => Mage::helper('germansetup')->__('No'),
264+
),
265+
));
266+
267+
255268
Mage::dispatchEvent('germansetup_adminhtml_checkout_agreement_edit_form', array(
256269
'form' => $form,
257270
'fieldset' => $fieldset,
@@ -282,4 +295,32 @@ public function recollectAfterQuoteItemUpdate()
282295
->collectTotals();
283296
}
284297
}
298+
299+
/**
300+
* Get required agreements on custom registration
301+
*
302+
* @return mixed
303+
*/
304+
protected function _getCustomerCreateAgreements()
305+
{
306+
$ids = $this->_agreements = Mage::getModel('checkout/agreement')->getCollection()
307+
->addStoreFilter(Mage::app()->getStore()->getId())
308+
->addFieldToFilter('is_active', 1)
309+
->addFieldToFilter('is_visible_on_registration', 1) // Only get Required Elements
310+
->getAllIds();
311+
return $ids;
312+
}
313+
314+
public function customerCreatePreDispatch(Varien_Event_Observer $event)
315+
{
316+
$requiredAgreements = $this->_getCustomerCreateAgreements();
317+
$controller = $event->getControllerAction();
318+
$postedAgreements = array_keys($controller->getRequest()->getPost('agreement', array()));
319+
if ($diff = array_diff($requiredAgreements, $postedAgreements)) {
320+
$session = Mage::getSingleton('customer/session');
321+
$session->addException(new Mage_Customer_Exception('Cannot create customer: agreements not confirmed'), Mage::helper('germansetup')->__('Agreements not confirmed.'));
322+
$controller->getResponse()->setRedirect( Mage::getUrl('*/*/create', array('_secure' => true)) );
323+
$controller->setFlag($controller->getRequest()->getActionName(), Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
324+
}
325+
}
285326
}

‎src/app/code/community/FireGento/GermanSetup/etc/config.xml

+13-1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@
100100
</germansetup_observer>
101101
</observers>
102102
</newsletter_subscriber_save_after>
103+
<controller_action_predispatch_customer_account_createpost>
104+
<observers>
105+
<germansetup_observer>
106+
<class>germansetup/observer</class>
107+
<type>model</type>
108+
<method>customerCreatePreDispatch</method>
109+
</germansetup_observer>
110+
</observers>
111+
</controller_action_predispatch_customer_account_createpost>
103112
</events>
104113
</global>
105114
<frontend>
@@ -222,7 +231,7 @@
222231
<germansetup_observer_agreement>
223232
<class>germansetup/observer</class>
224233
<type>model</type>
225-
<method>addIsRequiredOnAgreements</method>
234+
<method>addOptionsForAgreements</method>
226235
</germansetup_observer_agreement>
227236
</observers>
228237
</adminhtml_block_html_before>
@@ -266,6 +275,9 @@
266275
</cart>
267276
</checkout>
268277
<customer>
278+
<create_account>
279+
<avoid_tc>Yes</avoid_tc>
280+
</create_account>
269281
<address_templates>
270282
<text><![CDATA[
271283
{{depend company}}{{var company}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
/**
3+
* This file is part of the FIREGENTO project.
4+
*
5+
* FireGento_GermanSetup is free software; you can redistribute it and/or
6+
* modify it under the terms of the GNU General Public License version 3 as
7+
* published by the Free Software Foundation.
8+
*
9+
* This script is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12+
*
13+
* PHP version 5
14+
*
15+
* @category FireGento
16+
* @package FireGento_GermanSetup
17+
* @author FireGento Team <team@firegento.com>
18+
* @copyright 2012 FireGento Team (http://www.firegento.de). All rights served.
19+
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
20+
* @version $Id:$
21+
* @since 1.0.7
22+
*/
23+
/**
24+
* Setup script; Adds the is_required field for the checkout agreements
25+
*
26+
* @category FireGento
27+
* @package FireGento_GermanSetup
28+
* @author FireGento Team <team@firegento.com>
29+
* @copyright 2012 FireGento Team (http://www.firegento.de). All rights served.
30+
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
31+
* @version $Id:$
32+
* @since 1.0.7
33+
*/
34+
35+
/* @var $this Mage_Eav_Model_Entity_Setup */
36+
$installer = $this;
37+
$installer->startSetup();
38+
39+
if (version_compare(Mage::getVersion(), '1.6', '<')) {
40+
41+
$installer->run("
42+
ALTER TABLE `{$installer->getTable('checkout/agreement')}`
43+
ADD `is_visible_on_registration` SMALLINT( 5 ) NOT NULL DEFAULT '0' COMMENT 'Agreement is required on customer registration'
44+
");
45+
46+
} else {
47+
48+
$installer->getConnection()->addColumn(
49+
$installer->getTable('checkout/agreement'),
50+
'is_visible_on_registration',
51+
array(
52+
'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT,
53+
'unsigned' => true,
54+
'nullable' => false,
55+
'default' => '0',
56+
'comment' => 'Agreement is required on customer registration'
57+
)
58+
);
59+
}
60+
61+
$installer->endSetup();

‎src/app/design/frontend/base/default/layout/germansetup.xml

+8
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,14 @@
503503
</reference>
504504
</checkout_multishipping_overview>
505505

506+
<!-- Customer Terms and Condition Confirmation -->
507+
<customer_account_create>
508+
<reference name="form.additional.info">
509+
<block type="germansetup/customer_account_agreements" name="customer.tc-confirmation"
510+
template="germansetup/customer/form/tc-confirmation.phtml"/>
511+
</reference>
512+
</customer_account_create>
513+
506514
<customer_logged_in>
507515
<reference name="right">
508516
<action method="unsetChild" ifconfig="sales/reorder/hide_sidebar_box">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/**
3+
* This file is part of the FIREGENTO project.
4+
*
5+
* FireGento_GermanSetup is free software; you can redistribute it and/or
6+
* modify it under the terms of the GNU General Public License version 3 as
7+
* published by the Free Software Foundation.
8+
*
9+
* This script is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12+
*
13+
* PHP version 5
14+
*
15+
* @category FireGento
16+
* @package FireGento_GermanSetup
17+
* @author FireGento Team <team@firegento.com>
18+
* @copyright 2012 FireGento Team (http://www.firegento.de). All rights served.
19+
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
20+
* @version $Id:$
21+
* @since 0.1.0
22+
*/
23+
/**
24+
* Checkout Agreements
25+
*
26+
* @category FireGento
27+
* @package FireGento_GermanSetup
28+
* @author FireGento Team <team@firegento.com>
29+
* @copyright 2012 FireGento Team (http://www.firegento.de). All rights served.
30+
* @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
31+
* @version $Id:$
32+
* @since 0.1.0
33+
*/
34+
35+
/**
36+
* @var $this Mage_Checkout_Block_Agreements
37+
*/
38+
39+
/* @var $helper FireGento_GermanSetup_Helper_Data */
40+
$helper = $this->helper( 'germansetup' );
41+
?>
42+
43+
<?php if( !$this->getAgreements() ) return; ?>
44+
45+
<?php foreach( $this->getAgreements() as $_a ): ?>
46+
<li class="control">
47+
<p class="agree">
48+
<?php if( $_a->getIsRequired() ): ?>
49+
<input type="checkbox" id="agreement-<?php echo $_a->getId()?>" name="agreement[<?php echo $_a->getId()?>]" value="1" title="<?php echo $this->htmlEscape( $_a->getCheckboxText() ) ?>" class="checkbox required-entry"/>
50+
<?php endif; ?>
51+
<label <?php if( $_a->getIsRequired() ): ?>for="agreement-<?php echo $_a->getId()?>"<?php endif; ?> style="float:none;"><?php echo $_a->getIsHtml() ? $_a->getCheckboxText() : $this->htmlEscape( $_a->getCheckboxText() ) ?></label>
52+
<a href="<?php echo $helper->getAgreementUrl( $_a ) ?>" onclick="window.open(this.href, '', 'width=600,height=600,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes').focus(); return false;"><?php echo $this->__( '[Show]' ) ?></a>
53+
</p>
54+
</li>
55+
<?php endforeach ?>

‎src/app/locale/de_DE/FireGento_GermanSetup.csv

+5
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,8 @@
119119
"Replace with a link to the shipping costs cms page","Mit einem Link zur CMS-Seite ""Versandkosten"" ersetzen"
120120
"Here you find information regarding the shipping costs.","Hier finden Sie Informationen zu den Versandkosten."
121121
"Hide box ""Last Ordered Items""","Box ""Zuletzt bestellte Artikel"" verstecken"
122+
"Tax Settings","Steuer-Einstellungen"
123+
124+
"Use on Customer Creation","In Benutzerregistrierung verwenden"
125+
"Require Confirmation on Customer Registration","Bestätigung bei Benutzerregistrierung nötig"
126+
"Agreements not confirmed.","Bedingungen wurden nicht bestätigt."

0 commit comments

Comments
 (0)
Please sign in to comment.