Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

created .gitignore and README

corrected modman-file

first implementation of Tweet-Condition
  • Loading branch information...
commit 2a65e8ba9a5e9d76685e56a049e67c42437ba796 1 parent b807dc2
@Schrank Schrank authored
View
88 app/code/community/Hackathon/DiscountForATweet/Model/Condition/Tweet.php
@@ -0,0 +1,88 @@
+<?php
+/**
+ * Condition-Class for Tweeting
+ *
+ * @category Hackathon
+ * @package Hackathon_DiscountForATweet
+ * @subpackage Setup
+ * @copyright Copyright (c) 2012 Magento Hackathon
+ * @license http://www.gnu.org/licenses/gpl.html GPL, version 3
+ * @version 0.1.0
+ * @link http://magento-hackathon.de
+ * @since File available since Release 0.1.0
+ * @author Hackathon Core Team <core@hackathon>
+ * */
+class Hackathon_DiscountForATweet_Model_Condition_Tweet extends Mage_Rule_Model_Condition_Abstract {
+
+ /**
+ * @TODO for whatever this it, check it and afterwards document it!
+ *
+ * @return Hackathon_DiscountForATweet_Model_Condition_Tweet
+ */
+ public function loadAttributeOptions() {
+ $attributes = array(
+ 'tweetContent' => Mage::helper('hackathon_discountforatweet')->__('Tweet content')
+ );
+
+ $this->setAttributeOption($attributes);
+
+ return $this;
+ }
+
+ /**
+ * @TODO for whatever this it, check it and afterwards document it!
+ *
+ * @return mixed
+ */
+ public function getAttributeElement() {
+ $element = parent::getAttributeElement();
+ $element->setShowAsText(true);
+ return $element;
+ }
+
+ /**
+ * @TODO for whatever this it, check it and afterwards document it!
+ *
+ * @return string
+ */
+ public function getInputType() {
+
+ switch ($this->getAttribute()) {
+ case 'tweetContent':
+ return 'select';
+ }
+ return 'string';
+ }
+
+ /**
+ * @TODO for whatever this it, check it and afterwards document it!
+ * @return string
+ */
+ public function getValueElementType() {
+ return 'text';
+ }
+
+ /**
+ * Validate Tweet Rule Condition
+ *
+ * @param Varien_Object $object
+ *
+ * @return bool
+ */
+ public function validate(Varien_Object $object) {
+ $address = $object;
+ if (!$address instanceof Mage_Sales_Model_Quote_Address) {
+ if ($object->getQuote()->isVirtual()) {
+ $address = $object->getQuote()->getBillingAddress();
+ } else {
+ $address = $object->getQuote()->getShippingAddress();
+ }
+ }
+
+ if ('payment_method' == $this->getAttribute() && !$address->hasPaymentMethod()) {
+ $address->setPaymentMethod($object->getQuote()->getPayment()->getMethod());
+ }
+
+ return parent::validate($address);
+ }
+}
View
11 modman
@@ -0,0 +1,11 @@
+# Config-File
+app/etc/modules/Hackathon_DiscountForATweet.xml app/etc/modules/Hackathon_DiscountForATweet.xml
+# App Files
+app/code/community/Hackathon/DiscountForATweet app/code/community/Hackathon/DiscountForATweet
+# Adminhtml-Layout-XML
+app/design/adminhtml/default/default/layout/hackathon_discountforatweet.xml app/design/adminhtml/default/default/layout/hackathon_discountforatweet.xml
+# Frontend-Layout-XML
+app/design/frontend/default/default/layout/hackathon_discountforatweet.xml app/design/frontend/default/default/layout/hackathon_discountforatweet.xml
+# Locale
+app/locale/de_DE/Hackathon_DiscountForATweet.csv app/locale/de_DE/Hackathon_DiscountForATweet.csv
+app/locale/en_US/Hackathon_DiscountForATweet.csv app/locale/en_US/Hackathon_DiscountForATweet.csv
Please sign in to comment.
Something went wrong with that request. Please try again.