Skip to content
This repository has been archived by the owner on Apr 26, 2022. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/2.6.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoffer Lindqvist committed Oct 22, 2015
2 parents 7c5ae02 + faa8acb commit 6584828
Show file tree
Hide file tree
Showing 16 changed files with 299 additions and 78 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
vendor
node_modules
18 changes: 18 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
uglify: {
my_target: {
files: {
'js/iframeHandler.min.js': ['js/src/iframeHandler.js']
}
}
}
});

// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-uglify');

// Default task(s).
grunt.registerTask('default', ['uglify']);
};
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ Open Software License ("OSL") v3.0

## Changelog

### 2.6.6
* Fix account removal for self-signup accounts through the iframe
* Fix uncaught "InvalidArgumentException" exception when order status is missing
a label
* Make order buyer info optional in tagging and API calls

### 2.6.5
* Add "external_order_ref" to order tagging and API requests in order to better
track orders
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/
class Nosto_Tagging_Block_Adminhtml_Iframe extends Mage_Adminhtml_Block_Template
{
const DEFAULT_IFRAME_ORIGIN_REGEXP = '(https:\/\/magento-([a-z0-9]+)\.hub\.nosto\.com)|(https:\/\/my\.nosto\.com)';
const DEFAULT_IFRAME_ORIGIN_REGEXP = '(https:\/\/(.*)\.hub\.nosto\.com)|(https:\/\/my\.nosto\.com)';

/**
* @var string the iframe url if SSO to Nosto can be made.
Expand Down
16 changes: 11 additions & 5 deletions app/code/community/Nosto/Tagging/Model/Export/Collection/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ public function getJson()
'order_status_label' => $item->getOrderStatus()->getLabel(),
'order_statuses' => array(),
'created_at' => Nosto::helper('date')->format($item->getCreatedDate()),
'buyer' => array(
'first_name' => $item->getBuyerInfo()->getFirstName(),
'last_name' => $item->getBuyerInfo()->getLastName(),
'email' => $item->getBuyerInfo()->getEmail(),
),
'buyer' => array(),
'payment_provider' => $item->getPaymentProvider(),
'purchased_items' => array(),
);
Expand All @@ -69,6 +65,16 @@ public function getJson()
$data['order_statuses'][$status->getCode()][] =
date('Y-m-d\TH:i:s\Z', strtotime($status->getCreatedAt()));
}
if ($item->getBuyerInfo()->getFirstName()) {
$data['buyer']['first_name'] = $item->getBuyerInfo()->getFirstName();
}
if ($item->getBuyerInfo()->getLastName()) {
$data['buyer']['last_name'] = $item->getBuyerInfo()->getLastName();
}
if ($item->getBuyerInfo()->getEmail()) {
$data['buyer']['email'] = $item->getBuyerInfo()->getEmail();
}

$array[] = $data;
}
return json_encode($array);
Expand Down
24 changes: 15 additions & 9 deletions app/code/community/Nosto/Tagging/Model/Meta/Order/Buyer.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,25 @@ class Nosto_Tagging_Model_Meta_Order_Buyer extends Mage_Core_Model_Abstract impl
*/
public function __construct(array $args)
{
if (!isset($args['firstName']) || !is_string($args['firstName']) || empty($args['firstName'])) {
throw new InvalidArgumentException(sprintf('%s.firstName must be a non-empty string value.', __CLASS__));
if (isset($args['firstName'])) {
if (!is_string($args['firstName']) || empty($args['firstName'])) {
throw new InvalidArgumentException(sprintf('%s.firstName must be a non-empty string value.', __CLASS__));
}
}
if (!isset($args['lastName']) || !is_string($args['lastName']) || empty($args['lastName'])) {
throw new InvalidArgumentException(sprintf('%s.lastName must be a non-empty string value.', __CLASS__));
if (isset($args['lastName'])) {
if (!is_string($args['lastName']) || empty($args['lastName'])) {
throw new InvalidArgumentException(sprintf('%s.lastName must be a non-empty string value.', __CLASS__));
}
}
if (!isset($args['email']) || !is_string($args['email']) || empty($args['email'])) {
throw new InvalidArgumentException(sprintf('%s.email must be a non-empty string value.', __CLASS__));
if (isset($args['email'])) {
if (!is_string($args['email']) || empty($args['email'])) {
throw new InvalidArgumentException(sprintf('%s.email must be a non-empty string value.', __CLASS__));
}
}

$this->_firstName = $args['firstName'];
$this->_lastName = $args['lastName'];
$this->_email = $args['email'];
$this->_firstName = isset($args['firstName']) ? $args['firstName'] : null;
$this->_lastName = isset($args['lastName']) ? $args['lastName'] : null;
$this->_email = isset($args['email']) ? $args['email'] : null;
}

/**
Expand Down
12 changes: 6 additions & 6 deletions app/code/community/Nosto/Tagging/Model/Meta/Order/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ public function __construct(array $args)
if (!isset($args['code']) || !is_string($args['code']) || empty($args['code'])) {
throw new InvalidArgumentException(sprintf('%s.code must be a non-empty string value.', __CLASS__));
}
if (!isset($args['label']) || !is_string($args['label']) || empty($args['label'])) {
throw new InvalidArgumentException(sprintf('%s.label must be a non-empty string value.', __CLASS__));
if (isset($args['label'])) {
if (!is_string($args['label']) || empty($args['label'])) {
throw new InvalidArgumentException(sprintf('%s.label must be a non-empty string value.', __CLASS__));
}
}
if (isset($args['createdAt'])) {
if (!is_string($args['createdAt']) || strtotime($args['createdAt']) === false) {
Expand All @@ -75,10 +77,8 @@ public function __construct(array $args)
}

$this->_code = $args['code'];
$this->_label = $args['label'];
if (isset($args['createdAt'])) {
$this->_createdAt = $args['createdAt'];
}
$this->_label = isset($args['label']) ? $args['label'] : $args['code'];
$this->_createdAt = isset($args['createdAt']) ? $args['createdAt'] : null;
}

/**
Expand Down
15 changes: 10 additions & 5 deletions app/code/community/Nosto/Tagging/Model/Service/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,7 @@ protected function getOrderAsJson(Nosto_Tagging_Model_Meta_Order $order)
'external_order_ref' => $order->getExternalOrderRef(),
'order_status_code' => $order->getOrderStatus()->getCode(),
'order_status_label' => $order->getOrderStatus()->getLabel(),
'buyer' => array(
'first_name' => $order->getBuyerInfo()->getFirstName(),
'last_name' => $order->getBuyerInfo()->getLastName(),
'email' => $order->getBuyerInfo()->getEmail(),
),
'buyer' => array(),
'created_at' => Nosto::helper('date')->format($order->getCreatedDate()),
'payment_provider' => $order->getPaymentProvider(),
'purchased_items' => array(),
Expand All @@ -107,6 +103,15 @@ protected function getOrderAsJson(Nosto_Tagging_Model_Meta_Order $order)
'price_currency_code' => strtoupper($item->getCurrencyCode()),
);
}
if ($order->getBuyerInfo()->getFirstName()) {
$data['buyer']['first_name'] = $order->getBuyerInfo()->getFirstName();
}
if ($order->getBuyerInfo()->getLastName()) {
$data['buyer']['last_name'] = $order->getBuyerInfo()->getLastName();
}
if ($order->getBuyerInfo()->getEmail()) {
$data['buyer']['email'] = $order->getBuyerInfo()->getEmail();
}
return json_encode($data);
}
}
2 changes: 1 addition & 1 deletion app/code/community/Nosto/Tagging/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<config>
<modules>
<Nosto_Tagging>
<version>2.6.5</version>
<version>2.6.6</version>
</Nosto_Tagging>
</modules>
<global>
Expand Down
5 changes: 2 additions & 3 deletions app/design/adminhtml/default/default/layout/nostotagging.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@
<adminhtml_nosto_index>
<!-- Add JavaScript file -->
<reference name="head">
<action method="addJs"><script>nosto/iframeresizer.min.js</script></action>
<action method="addJs"><script>nosto/NostoIframe.min.js</script></action>
<action method="addJs"><script>nosto/NostoAdmin.js</script></action>
<action method="addJs"><script>nosto/iframeResizer.min.js</script></action>
<action method="addJs"><script>nosto/iframeHandler.min.js</script></action>
</reference>
<!--Set active menu item-->
<reference name="menu">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,50 @@ $params = array('store' => $this->getSelectedStore()->getId(), 'isAjax' => true)
?>
<iframe id="nosto_iframe" src='<?php echo $this->getIframeUrl(); ?>' width='100%' frameborder='0' scrolling='no' style="min-height: 600px;"></iframe>
<script type="text/javascript">
// Define the "Nosto" namespace if not already defined.
if (typeof Nosto === "undefined") {
var Nosto = {};
}
Nosto.settings = {
origin: "<?php echo $this->getIframeOrigin(); ?>",
urls: {
createAccount: "<?php echo $this->getUrl('*/*/createAccount', $params); ?>",
connectAccount: "<?php echo $this->getUrl('*/*/connectAccount', $params); ?>",
deleteAccount: "<?php echo $this->getUrl('*/*/removeAccount', $params); ?>"
},
xhrParams: {form_key: window.FORM_KEY}
};
document.observe("dom:loaded", function() {
// Init the iframe re-sizer.
iFrameResize({heightCalculationMethod : "bodyScroll"});

/**
* Window.postMessage() event handler for catching messages from Nosto.
*
* Supported messages must come from [*.]nosto.com and be formatted
* according to the following example:
*
* '[Nosto]{ "type": "the message action", "params": {} }'
*
* @param {Object} event
*/
function receiveMessage(event) {
var settings = {
iframeId: "nosto_iframe",
urls: {
createAccount: "<?php echo $this->getUrl('*/*/createAccount', $params); ?>",
connectAccount: "<?php echo $this->getUrl('*/*/connectAccount', $params); ?>",
deleteAccount: "<?php echo $this->getUrl('*/*/removeAccount', $params); ?>"
}
};

// Check the origin to prevent cross-site scripting.
var originRegexp = new RegExp("<?php echo $this->getIframeOrigin(); ?>");
if (!originRegexp.test(event.origin)) {
return;
}
// If the message does not start with "[Nosto]", then it is not for us.
if ((""+event.data).substr(0, 7) !== "[Nosto]") {
return;
}

// Pass the info on to a handler if the data seems sane.
var json = (""+event.data).substr(7);
var data = JSON.parse(json);
if (typeof data === "object" && data.type) {
Nosto.handlePostMessage(data, settings);
}
}

// Register event handler for window.postMessage() messages from Nosto.
window.addEventListener("message", receiveMessage, false);
});

</script>
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,15 @@ $priceHelper = Mage::helper('nosto_tagging/price');
<span class="order_status_label"><?php echo $helper->escapeHtml($order->getOrderStatus()->getLabel()); ?></span>
<span class="payment_provider"><?php echo $helper->escapeHtml($order->getPaymentProvider()); ?></span>
<div class="buyer">
<span class="first_name"><?php echo $helper->escapeHtml($order->getBuyerInfo()->getFirstName()); ?></span>
<span class="last_name"><?php echo $helper->escapeHtml($order->getBuyerInfo()->getLastName()); ?></span>
<span class="email"><?php echo $helper->escapeHtml($order->getBuyerInfo()->getEmail()); ?></span>
<?php if ($order->getBuyerInfo()->getFirstName()): ?>
<span class="first_name"><?php echo $helper->escapeHtml($order->getBuyerInfo()->getFirstName()); ?></span>
<?php endif; ?>
<?php if ($order->getBuyerInfo()->getLastName()): ?>
<span class="last_name"><?php echo $helper->escapeHtml($order->getBuyerInfo()->getLastName()); ?></span>
<?php endif; ?>
<?php if ($order->getBuyerInfo()->getEmail()): ?>
<span class="email"><?php echo $helper->escapeHtml($order->getBuyerInfo()->getEmail()); ?></span>
<?php endif; ?>
</div>
<div class="purchased_items">
<?php foreach ($order->getPurchasedItems() as $item): ?>
Expand Down
32 changes: 0 additions & 32 deletions js/NostoAdmin.js

This file was deleted.

1 change: 1 addition & 0 deletions js/iframeHandler.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6584828

Please sign in to comment.