From ab39eb0dba7439c95cbddce08e79dc45ae7dbeb7 Mon Sep 17 00:00:00 2001 From: David Alexander Date: Thu, 24 Apr 2014 23:23:44 +0100 Subject: [PATCH] add newsletter subscribe as conversion option --- .../community/THB/ABTest/Model/Observer.php | 21 +++++++++++++++++++ app/code/community/THB/ABTest/etc/config.xml | 10 +++++++++ .../template/abtest/form/settings.phtml | 1 + 3 files changed, 32 insertions(+) diff --git a/app/code/community/THB/ABTest/Model/Observer.php b/app/code/community/THB/ABTest/Model/Observer.php index 2e6bcdd..2b03335 100644 --- a/app/code/community/THB/ABTest/Model/Observer.php +++ b/app/code/community/THB/ABTest/Model/Observer.php @@ -155,6 +155,27 @@ public function conversion_wishlist_add_product($observer) } } + /** + * Registers a conversion when a visitor subscribes to the newsletter + * + */ + public function conversion_newsletter_subscribe($observer) + { + # This runs every time a visitor subscribes, regardless of whether or not + # an AB test is running. + if ( ! Mage::helper('abtest')->isRunning()) + return; + + if ($variations = Mage::helper('abtest/visitor')->getVariationsFromObserver($observer->getEvent()->getName(), 'observer_conversion')) + { + foreach ($variations as $variation) + { + # Get our table name for variations and update the row information + $this->_register_conversion($variation, 0); // send 0 price value for conversion + } + } + } + /** * Registers a conversion when a product is sent to a friend * diff --git a/app/code/community/THB/ABTest/etc/config.xml b/app/code/community/THB/ABTest/etc/config.xml index 94525af..e538a16 100755 --- a/app/code/community/THB/ABTest/etc/config.xml +++ b/app/code/community/THB/ABTest/etc/config.xml @@ -211,6 +211,16 @@ + + + + singleton + abtest/observer + conversion_newsletter_subscribe + + + + diff --git a/app/design/adminhtml/default/default/template/abtest/form/settings.phtml b/app/design/adminhtml/default/default/template/abtest/form/settings.phtml index 10707e2..d61d150 100644 --- a/app/design/adminhtml/default/default/template/abtest/form/settings.phtml +++ b/app/design/adminhtml/default/default/template/abtest/form/settings.phtml @@ -115,6 +115,7 @@ +