Skip to content

Commit

Permalink
Dev v3.5.5 (#41)
Browse files Browse the repository at this point in the history
* Add admin config to enable/disable learn more from ala

* Bug fix for observer after order confirmation for some non Affirm payments

* version update

* package file updated
  • Loading branch information
nandadubey authored Jun 19, 2018
1 parent 9ef99fa commit 7d74b7a
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dependencies:

package: validate_version
mkdir -p ./var/
cd ./extension && tar -cvf ../var/Affirm_Affirm-3.5.4.tgz *
cd ./extension && tar -cvf ../var/Affirm_Affirm-3.5.5.tgz *
cd ./build && ./magento-tar-to-connect.phar affirm_tar_to_connect_config.php

clean:
Expand Down
6 changes: 3 additions & 3 deletions build/affirm_tar_to_connect_config.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php
return array(
'base_dir' => realpath('../var/'),
'archive_files' => 'Affirm_Affirm-3.5.4.tgz',
'archive_files' => 'Affirm_Affirm-3.5.5.tgz',
'extension_name' => 'Affirm_Magento',
'skip_version_compare' => true,
'extension_version' => '3.5.4',
'archive_connect' => 'Affirm_Affirm-3.5.4.tgz',
'extension_version' => '3.5.5',
'archive_connect' => 'Affirm_Affirm-3.5.5.tgz',
'path_output' => realpath('../var/'),

'stability' => 'stable',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ public function getPriceHtml($product, $displayMinimalPrice = false, $idSuffix =

$mfpValue = $this->helper('affirm/promo_asLowAs')->getAffirmMFPValue(array($productItemMFP), $categoryIds);

$html .= '<div class="affirm-as-low-as" ' . (!empty($mfpValue) ? 'data-promo-id="' . $mfpValue . '"' : '') . ' data-amount="' . $this->helper('affirm/util')->formatCents($price) .'"></div>';
$learnMore = ($this->helper('affirm/promo_asLowas')->isVisibleLearnMore()) ? 'true' : 'false';
$html .= '<div class="affirm-as-low-as" ' . (!empty($mfpValue) ? 'data-promo-id="' . $mfpValue . '"' : '') . ' data-amount="' . $this->helper('affirm/util')->formatCents($price) .'" data-learnmore-show="'.$learnMore.'"></div>';
}

return $html;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ class Affirm_Affirm_Helper_Promo_AsLowAs extends Mage_Core_Helper_Abstract
*/
const MPP_MIN_DISPLAY_VALUE = 'affirmpromo/as_low_as/min_mpp_display_value';

/**
* Visibility of learn more with ala
*/
const AFFIRM_PROMO_LEARN_MORE = 'affirmpromo/as_low_as/learn_more';

protected $_allRules = null;

/**
Expand Down Expand Up @@ -301,4 +306,15 @@ protected function _isAdmin()

return false;
}

/**
* Check is learn-more visible on ala
*
* @param null|Mage_Core_Model_Store $store
* @return boolean
*/
public function isVisibleLearnMore($store = null)
{
return Mage::getStoreConfig(self::AFFIRM_PROMO_LEARN_MORE, $store);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,16 @@ public function reactivateQuote($observer)
$this->_isAffirmOrderSaveAfter = true;
$quote = $observer->getQuote();
$methodInst = $quote->getPayment()->getMethodInstance();
if (!Mage::helper('affirm')->getAffirmTokenCode()) {
Mage::log('Confirm has no checkout token.');
Mage::getSingleton('core/session')->addError('Payment has failed, please reload checkout page and try again. Checkout token is not available.');
Mage::app()->getResponse()->setRedirect(Mage::getUrl('checkout/cart'))->sendResponse();
return;
} else if (($methodInst->getCode() == Affirm_Affirm_Model_Payment::METHOD_CODE) && !$methodInst->redirectPreOrder()) {
$quote->setIsActive(true);
$quote->save();
if(($methodInst->getCode() == Affirm_Affirm_Model_Payment::METHOD_CODE)) {
if (!Mage::helper('affirm')->getAffirmTokenCode()) {
Mage::log('Confirm has no checkout token.');
Mage::getSingleton('core/session')->addError('Payment has failed, please reload checkout page and try again. Checkout token is not available.');
Mage::app()->getResponse()->setRedirect(Mage::getUrl('checkout/cart'))->sendResponse();
return;
} else if (!$methodInst->redirectPreOrder()) {
$quote->setIsActive(true);
$quote->save();
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion extension/app/code/community/Affirm/Affirm/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<config>
<modules>
<Affirm_Affirm>
<version>3.5.4</version>
<version>3.5.5</version>
</Affirm_Affirm>
</modules>
<global>
Expand Down Expand Up @@ -359,6 +359,7 @@
<as_low_as>
<apr_value>0.10</apr_value>
<promo_months>12</promo_months>
<learn_more>1</learn_more>
</as_low_as>
</affirmpromo>
</default>
Expand Down
9 changes: 9 additions & 0 deletions extension/app/code/community/Affirm/Affirm/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,15 @@
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
</min_mpp_display_value>
<learn_more translate="label">
<label>Enable Learn More</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>60</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
</learn_more>
<promo_id_value_default translate="label">
<label>Default Affirm Promo ID</label>
<frontend_type>text</frontend_type>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php
$mfpValue = $this->getMFPValue();
$mfpValue = $this->getMFPValue();
$learnMore = ($this->helper('affirm/promo_asLowas')->isVisibleLearnMore()) ? 'true' : 'false';
?>
<div>
<?php echo '<div class="affirm-as-low-as" ' . (!empty($mfpValue) ? 'data-promo-id="' . $mfpValue . '"' : '') . ' data-amount="' . $this->getCheckoutGrandTotal() .'"></div>'; ?>
<?php echo '<div class="affirm-as-low-as" ' . (!empty($mfpValue) ? 'data-promo-id="' . $mfpValue . '"' : '') . ' data-amount="' . $this->getCheckoutGrandTotal() .'" data-learnmore-show="'.$learnMore.'"></div>'; ?>
</div>

<script type="text/javascript">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,44 @@
<?php
$mfpValue = $this->getMFPValue();
$productId = $this->getProductId();
/**
*
* * BSD 3-Clause License
* *
* * Copyright (c) 2018, Affirm
* * All rights reserved.
* *
* * Redistribution and use in source and binary forms, with or without
* * modification, are permitted provided that the following conditions are met:
* *
* * Redistributions of source code must retain the above copyright notice, this
* * list of conditions and the following disclaimer.
* *
* * Redistributions in binary form must reproduce the above copyright notice,
* * this list of conditions and the following disclaimer in the documentation
* * and/or other materials provided with the distribution.
* *
* * Neither the name of the copyright holder nor the names of its
* * contributors may be used to endorse or promote products derived from
* * this software without specific prior written permission.
* *
* * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/

$mfpValue = $this->getMFPValue();
$productId = $this->getProductId();
$learnMore = ($this->helper('affirm/promo_asLowas')->isVisibleLearnMore()) ? 'true' : 'false';
?>
<div>
<?php echo '<div style="margin-bottom:5px;" class="affirm-as-low-as" id="as-low-as-refreshable" ' . (!empty($mfpValue) ? 'data-promo-id="' . $mfpValue . '"' : '') . ' data-amount="' . $this->getFinalPrice() .'"></div>'; ?>
<?php echo '<div style="margin-bottom:5px;" class="affirm-as-low-as" id="as-low-as-refreshable" ' . (!empty($mfpValue) ? 'data-promo-id="' . $mfpValue . '"' : '') . ' data-amount="' . $this->getFinalPrice() .'" data-learnmore-show="'.$learnMore.'"></div>'; ?>
</div>

<script type="text/javascript">
Expand Down
12 changes: 6 additions & 6 deletions extension/package.xml

Large diffs are not rendered by default.

0 comments on commit 7d74b7a

Please sign in to comment.