diff --git a/Makefile b/Makefile index 047ace6..4b10c6d 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ dependencies: package: validate_version mkdir -p ./var/ - cd ./extension && tar -cvf ../var/Affirm_Affirm-3.5.5.tgz * + cd ./extension && tar -cvf ../var/Affirm_Affirm-3.5.6.tgz * cd ./build && ./magento-tar-to-connect.phar affirm_tar_to_connect_config.php clean: diff --git a/build/affirm_tar_to_connect_config.php b/build/affirm_tar_to_connect_config.php index 858e874..613f4aa 100644 --- a/build/affirm_tar_to_connect_config.php +++ b/build/affirm_tar_to_connect_config.php @@ -1,11 +1,11 @@ realpath('../var/'), -'archive_files' => 'Affirm_Affirm-3.5.5.tgz', +'archive_files' => 'Affirm_Affirm-3.5.6.tgz', 'extension_name' => 'Affirm_Magento', 'skip_version_compare' => true, -'extension_version' => '3.5.5', -'archive_connect' => 'Affirm_Affirm-3.5.5.tgz', +'extension_version' => '3.5.6', +'archive_connect' => 'Affirm_Affirm-3.5.6.tgz', 'path_output' => realpath('../var/'), 'stability' => 'stable', diff --git a/extension/app/code/community/Affirm/Affirm/Block/Product/List.php b/extension/app/code/community/Affirm/Affirm/Block/Product/List.php index 02664fd..2e8f52e 100644 --- a/extension/app/code/community/Affirm/Affirm/Block/Product/List.php +++ b/extension/app/code/community/Affirm/Affirm/Block/Product/List.php @@ -73,7 +73,7 @@ public function getPriceHtml($product, $displayMinimalPrice = false, $idSuffix = $mfpValue = $this->helper('affirm/promo_asLowAs')->getAffirmMFPValue(array($productItemMFP), $categoryIds); $learnMore = ($this->helper('affirm/promo_asLowas')->isVisibleLearnMore()) ? 'true' : 'false'; - $html .= '
'; + $html .= ''; } return $html; diff --git a/extension/app/code/community/Affirm/Affirm/Block/Promo/Pixel/Confirm.php b/extension/app/code/community/Affirm/Affirm/Block/Promo/Pixel/Confirm.php new file mode 100644 index 0000000..c7163f2 --- /dev/null +++ b/extension/app/code/community/Affirm/Affirm/Block/Promo/Pixel/Confirm.php @@ -0,0 +1,110 @@ +getOrderIds(); + if (empty($orderIds) || !is_array($orderIds)) { + return; + } + $collection = Mage::getResourceModel('sales/order_collection') + ->addFieldToFilter('entity_id', array('in' => $orderIds)); + $result = array(); + foreach ($collection as $order) { + $result[] = sprintf("affirm.analytics.trackOrderConfirmed({ +'affiliation': '%s', +'orderId': '%s', +'currency': '%s', +'total': '%s', +'tax': '%s', +'shipping': '%s', +'paymentMethod': '%s' +});", + $this->jsQuoteEscape(Mage::app()->getStore()->getFrontendName()), + $order->getIncrementId(), + $order->getOrderCurrencyCode(), + Mage::helper('affirm/util')->formatCents($order->getBaseGrandTotal()), + Mage::helper('affirm/util')->formatCents($order->getBaseTaxAmount()), + Mage::helper('affirm/util')->formatCents($order->getBaseShippingAmount()), + $order->getPayment()->getMethod() + ); + } + return implode("\n", $result); + } + + /** + * Is ga available + * + * @return bool + */ + protected function _isAvailable() + { + return Mage::helper('affirm/promo_data')->isConfirmPixelEnabled(); + } + + /** + * Render Affirm tracking scripts + * + * @return string + */ + protected function _toHtml() + { + if (!$this->_isAvailable()) { + return ''; + } + return parent::_toHtml(); + } + + public function getCustomerSessionId() + { + $orderIds = $this->getOrderIds(); + if (empty($orderIds) || !is_array($orderIds)) { + return; + } + $collection = Mage::getResourceModel('sales/order_collection') + ->addFieldToFilter('entity_id', array('in' => $orderIds)); + $result = array(); + foreach ($collection as $order) { + $customerId = ($order->getCustomerId()) ? $order->getCustomerId() : $guestId = "CUSTOMER-" . Mage::helper('affirm/promo_data')->getDateMicrotime(); + } + return $customerId; + } +} diff --git a/extension/app/code/community/Affirm/Affirm/Block/Promo/Promo.php b/extension/app/code/community/Affirm/Affirm/Block/Promo/Promo.php index ff7ea26..0f71d97 100644 --- a/extension/app/code/community/Affirm/Affirm/Block/Promo/Promo.php +++ b/extension/app/code/community/Affirm/Affirm/Block/Promo/Promo.php @@ -169,4 +169,28 @@ public function getCheckoutMFPValue() return Mage::helper('affirm/promo_asLowAs')->getAffirmMFPValue($productItemMFP, $categoryIds, $this->helper('checkout/cart')->getQuote()->getGrandTotal()); } + + /** + * Get Page type + * + * @return string + */ + public function getPageType() + { + $currentController = Mage::app()->getFrontController()->getRequest()->getControllerName(); + switch($currentController) { + case 'product': + return 'product'; + break; + case 'category': + return 'category'; + break; + case 'cart': + return 'cart'; + break; + default: + return 'homepage'; + break; + } + } } diff --git a/extension/app/code/community/Affirm/Affirm/Helper/Promo/Data.php b/extension/app/code/community/Affirm/Affirm/Helper/Promo/Data.php index 084eb0d..3238e80 100644 --- a/extension/app/code/community/Affirm/Affirm/Helper/Promo/Data.php +++ b/extension/app/code/community/Affirm/Affirm/Helper/Promo/Data.php @@ -68,6 +68,11 @@ class Affirm_Affirm_Helper_Promo_Data extends Mage_Core_Helper_Abstract */ const AFFIRM_PROMO_DEV_SETTINGS_CONTAINER = 'affirmpromo/developer_settings/container_'; + /** + * Affirm pixel for confirmation page + */ + const AFFIRM_PROMO_PIXEL_CONFIRM = 'affirmpromo/pixel/active_confirm'; + /** * PDP handle */ @@ -242,4 +247,29 @@ public function getPLPAffirmJsScript() } return 'js/affirm/noconf.js'; } + + /** + * Returns is pixel placement for confirmation page enabled + * + * @param null|Mage_Core_Model_Store $store + * @return bool + */ + public function isConfirmPixelEnabled($store = null) + { + return Mage::getStoreConfigFlag(self::AFFIRM_PROMO_PIXEL_CONFIRM, $store); + } + + /** + * get Date with Microtime. + * + * @return string + */ + public function getDateMicrotime() + { + $microtime = explode(' ', microtime()); + $msec = $microtime[0]; + $msecArray = explode('.', $msec); + $date = date('Y-m-d-H-i-s') . '-' . $msecArray[1]; + return $date; + } } \ No newline at end of file diff --git a/extension/app/code/community/Affirm/Affirm/Model/Order/Observer/AfterOrderSuccess.php b/extension/app/code/community/Affirm/Affirm/Model/Order/Observer/AfterOrderSuccess.php new file mode 100644 index 0000000..20541d9 --- /dev/null +++ b/extension/app/code/community/Affirm/Affirm/Model/Order/Observer/AfterOrderSuccess.php @@ -0,0 +1,58 @@ +getEvent()->getOrderIds(); + if (empty($orderIds) || !is_array($orderIds)) { + return; + } + $block = Mage::app()->getFrontController()->getAction()->getLayout()->getBlock('affirm_pixel_javascript'); + if ($block) { + $block->setOrderIds($orderIds); + } + } +} diff --git a/extension/app/code/community/Affirm/Affirm/etc/config.xml b/extension/app/code/community/Affirm/Affirm/etc/config.xml index 133fdcf..9c76705 100644 --- a/extension/app/code/community/Affirm/Affirm/etc/config.xml +++ b/extension/app/code/community/Affirm/Affirm/etc/config.xml @@ -1,8 +1,42 @@ + +